HTML to PDF Conversion in C# throws 404 not found

this is my code.

PdfApi api = new PdfApi("xxxxxxxxxxxxxxxxxxxxxxxxx", "xxxxxx-xxxx-xxxxx-xxxx-xxxxxxxx");

string localFolder = "C:/Temp/";
string TempFolder = "Temp";
string name = "blankpages.zip";
string htmlFileName = "blankpages.html";
var file = System.IO.File.OpenRead(localFolder + name);
await api.UploadFileAsync(TempFolder + "/" + name, file);
   int height = 650;
   int width = 250;
   string resultName = "fromHtml.pdf";

var response = api.PutHtmlInStorageToPdf(resultName, Path.Combine(FolderName, name), htmlFileName, height, width, dstFolder: FolderName);

When I call this I am getting this error.

Aspose.Pdf.Cloud.Sdk.Client.ApiException: 'Error calling PutHtmlInStorageToPdf: {"RequestId":"72571779-2b5f-48b4-9901-310af657750f","Error":{"Code":"errorWindowsAzureStorage","Message":"Windows Azure Storage exception: The remote server returned an error: (404) Not Found.","Description":"Operation Failed. Windows Azure Storage Error.","DateTime":"2023-12-20T05:54:50.2829783Z","InnerError":null}}'

image.png (29.5 KB)

image.png (17.8 KB)

@niku2023

It seems you are unable to find the folder/file in your cloud storage. Please double check that you have configured your cloud storage correctly in the aspose.cloud dashboard and you can browse it in dashboard files tab.

I found the issue…

// Convert HTML file to PDF
var convertResponse = pdfApi.PutHtmlInStorageToPdf(name: manifest.Output.OutputFileName, srcPath: manifest.Template.DocumentTemplate, height: height, width: width, marginLeft: left_margin, marginBottom: bottom_margin, marginRight: right_margin, marginTop: top_margin);

This srcPath: manifest.Template.DocumentTemplate is in another container called templates. When I call this its looking this file inside outputcontainer. I tried to pass local html file for this as below.

string filePath = Path.Combine(parentPath, @"home\site\wwwroot\");
htmlFilePath = Path.Combine(filePath, manifest.RequestId + ".html");

This one also getting same error. If I upload my html file into outputcontainer then its converted into pdf. please help to fix this.

`

If I dont want to upload to converted pdf file into storage. then which api need to use?

@niku2023

As suggested above that please double check that you have configured your cloud storage in aspose.cloud dashboard correctly and can view your storage files folders in it.

@niku2023

You can try the ConvertDocument API method of Aspose.Words Cloud. It converts documents without involving cloud storage.