Convert Microsoft Word DOC to PDF in C# issue

Refer below code, I am unable to trace the namespaces for highlighted classes. I am using aspose.cloud as a namespace for below code

string appSID = “******************”;
string appKey = “******************”;
string fileName = “MyFile.docx”;

//build URI to convert MS Word file to other format using storage
string strURI = “http://api.aspose.com/v1.1/words/” + fileName + “?format=pdf”;

//Use the following line to use API version 1.1
//string strURI = “http://api.aspose.com/v1.1/words/” + fileName + “?format=pdf”;

//sign URI
string signedURI = Sign(strURI, appSID, appKey);

//get response stream
Stream responseStream = ProcessCommand(signedURI, “GET”);
using (Stream fileStream = System.IO.File.OpenWrite(“c:\temp\MyFile.pdf”))
{
CopyStream(responseStream, fileStream);
}
responseStream.Close();

Hi Raju,


Thanks for your inquiry. Please see attached Utils.cs. You can use Aspose.Cloud.Common namespace. I hope, this helps.

Best regards,

@hcm440

Kindly note the latest API Version 4.0 is very much optimized and simplified. Now it uses JSON Web Token Authentication instead of singing URL and OAuth2.0 methods. Please find the updated code to Convert Microsoft Word DOC to PDF in C# using Aspose.Words Cloud SDK for .NET.

Convert Microsoft Word DOCX to PDF in C#

// Get App Key and App SID from https://dashboard.aspose.cloud/
WordsApi wordsApi = new WordsApi(MyAppKey, MyAppSid);

var request = new ConvertDocumentRequest(
    document: File.OpenRead("C:/Temp/Test File.docx"),
    format: "pdf"
);

var convertDOCXtoPDFResult = wordsApi.ConvertDocument(request);
var fileStream = System.IO.File.Create("C:/Temp/Test.pdf");
convertDOCXtoPDFResult.CopyTo(fileStream);
fileStream.Close();