Convert HTML file to PDF

Hi


I am trying to convert html file to PDF using Aspose.PDF, but the PDF does not look as expected.
I also tried using Aspose.Word - still the PDF file is not look good.

I am expecting that the PDF will look same as if I open the html file in Internet Expoler

HTML and CSS are attached, please save them at same folder

Best regards
Yaniv

Hi Yaniv,

Thanks for your inquiry. Please use the new DOM approach for HTML to PDF conversion, as it will resolve the issue. If you use some external resources (css/fonts/images), you need to pass the file path to HtmlLoadOptions as the base path. Please check the sample code and output for your reference.

// Specify the base path/url for the html file which serves as the image database
String basePath = @"C:\Users\Home\Downloads\CCDA\";

HtmlLoadOptions htmloptions = new HtmlLoadOptions(basePath);

// Load HTML file
Document doc = new Document(@"C:\Users\Home\Downloads\CCDA\Good Health Health Summary.html", htmloptions);

// Save HTML file
doc.Save(basePath + "HTMLtoPDF_output.pdf");

Please feel free to contact us for any further assistance.

Best Regards,

Hi Tilal


I allready tried this code
but I got exception when creating the Document (new Document(…))


exception details are attached
please assist

Thx
Yaniv

Hi Yaniv,

Thanks for considering Aspose. You are getting an evaluation limitation error. Please note that the Aspose.Pdf evaluation version has two limitations: an evaluation watermark and a limit of viewing at most four elements of any collection. Please make a request for a temporary license to evaluate our product without any limitation. It will resolve the issue.

Please feel free to contact us for any further assistance.

Best Regards,

Ahmad


Thanks for you help.
After I set a temporary licence the current problem has resolve, and i can convert HTML document to PDF.

However there are still 2 issues:

  1. html documents cannot open, and i get the follow error: "A table-cell is spanning more rows than available in its parent element."
  2. html is convert to PDF but the table in the PDF doesn’t look as expected


The documents and CSS files are attached
Please assist

Best regards
Yaniv

Hi Yaniv,


Thanks for sharing the resource files. We are working on testing the scenario in our environment and will get back to you soon.

Hi Yaniv,


Thanks for your patience.

I have tested the scenario and have managed to reproduce the same issues.

  • ccd_html.html - Formatting issues when converting file to PDF format. It’s been logged as PDFNEWNET-39271.
  • ccda_html.html - Exception during conversion. Its been logged as PDFNEWNET-39272.

We will further look into the details of these issues and will keep you posted on the status of correction. Please be patient and spare us little time.

We are sorry for this inconvenience.

The issues you have found earlier (filed as PDFNET-39272) have been fixed in Aspose.PDF for .NET 21.4.