I need to use this https://reference.aspose.cloud/pdf/#/Convert/PutHtmlInStorageToPdf to call this method
PUT/pdf/{name}/create/html Convert HTML file (located on storage) to PDF format and upload resulting file to storage.
I need to do it .net C#. I am new to aspose. Please help to implement this.
@niku2023
First, please check the quick start article from documentation and following unit test from the GitHub repo, then you can use the Aspose.PDF Cloud SDK for .NET from NuGet for HTML to PDF conversion. Please feel free to contact us for any further assistance…
using (var response = PdfApi.GetHtmlInStorageToPdf(Path.Combine(TempFolder, name), htmlFileName, height, width))
{
Assert.That(response.Length, Is.GreaterThan(0));
}
}
/// <summary>
/// Test PutHtmlInStorageToPdf
/// </summary>
[Test]
public void PutHtmlInStorageToPdfTest()
{
string name = "HtmlWithImage.zip";
UploadFile(name, name);
string htmlFileName = "HtmlWithImage.html";
int height = 650;
int width = 250;
string resultName = "fromHtml.pdf";
var response = PdfApi.PutHtmlInStorageToPdf(resultName, Path.Combine(TempFolder, name), htmlFileName, height, width, dstFolder: TempFolder);
Assert.That(response.Code, Is.EqualTo(200));
1 Like
Thank you very much I will try this
1 Like
If I need to download the file to the local then how to get it
@niku2023
As suggested in your another post, please double check the file path in cloud storage and use the DownloadFile method as following.
// Download file Cloud storage
var downloadResponse = pdfApi.DownloadFile(cloudFolder + "/" + cloudFileName);
var fileStream = System.IO.File.Create("C:/Temp/Test.pdf");
downloadResponse.CopyTo(fileStream);
fileStream.Close();
1 Like