Convert HTML to PDF not respecting CSS/ IsFitToPage

Hello. When I try to convert a HTML file to PDF, the Aspose component hasn’t been able to adjust the contents to fit in the page that contains a wide table with some images and the CSS isn’t being fully respected. Below it’s our code sample:

Aspose.Pdf.Generator.Pdf pdf = new Aspose.Pdf.Generator.Pdf();
Aspose.Pdf.Generator.Section section = pdf.Sections.Add();
section.IsLandscape = true;
StreamReader r = File.OpenText(@“D:\test.html”);
Aspose.Pdf.Generator.Text text2 = new Aspose.Pdf.Generator.Text(section, r.ReadToEnd());
text2.IsHtmlTagSupported = true;
text2.IsFitToPage = true;
pdf.IsLandscape = true;
section.Paragraphs.Add(text2);
pdf.HtmlInfo.ImgUrl = @“D:”;
pdf.Save(@“D:\test.pdf”);

I’m trying to perform something similar like a browser print that’s possible to do through browser Print Options->Fit-To-Page.

Thank you.
Victor

Hi Victor,


Thanks for your interest in our products.

Can you please share the source PDF file so that we can test the scenario at our end. We are sorry for this inconvenience.

The MyExample.zip file contains one html page and a converted pdf through the aspose. On this example, you can see that some html components don’t show in the pdf file. And the table doesn’t fit in the page.

Hi Victor,

Thank you for sharing the template file.

I am able to generate your mentioned issue after an initial test. Your issue has been registered in our issue tracking system with issue id: PDFNEWNET-34111. You will be notified via this forum thread regarding any update against your issue.

Sorry for the inconvenience,

The issues you have found earlier (filed as PDFNEWNET-34111) have been fixed in Aspose.Pdf for .NET 10.2.0.


This message was posted using Notification2Forum from Downloads module by Aspose Notifier.