We're sorry Aspose doesn't work properply without JavaScript enabled.

Free Support Forum - aspose.com

HTML to PDF conversion broken in 10.1.0

I was happy to see that the PDFNEWNET-37636 issue was fixed in the latest release of Aspose.Pdf for .NET (10.1.0).
Unfortunately the HTML to PDF conversion seems to be broken in this new version.

With the previous version of Aspose.Pdf for .NET, the following code produces a PDF file with 5 pages with a header on each page.

With the 10.1.0 version of Aspose.Pdf for .NET, only the 2 first pages comes out as expected, page 3 and forward are all blank(!)


String html = “”;
html += “”;
html += “”;
html += “.page { width: 210mm; height: 297mm; margin: 0; padding: 0; }”;
html += “”;
html += “

PAGE 1

”;
html += “

PAGE 2

”;
html += “

PAGE 3

”;
html += “

PAGE 4

”;
html += “

PAGE 5

”;
html += “”;

HtmlLoadOptions options = new HtmlLoadOptions();
options.PageInfo.Margin.Top = 0;
options.PageInfo.Margin.Right = 0;
options.PageInfo.Margin.Bottom = 0;
options.PageInfo.Margin.Left = 0;
options.PageInfo.IsLandscape = false;
options.PageInfo.Width = Aspose.Pdf.PageSize.A4.Width;
options.PageInfo.Height = Aspose.Pdf.PageSize.A4.Height;
Document doc = new Document(new MemoryStream(System.Text.Encoding.UTF8.GetBytes(html)), options);
doc.Save(“c:/TEMP/test.pdf”);


Any suggestions on a work-around to fix this issue would be most welcome since we really want to upgrade to get rid of that html-character bug.


Hi Patrick,


Thanks for your inquiry. We have tested your source code and noticed missing text last three pages. We have logged a ticket PDFNEWNET-38255 in our issue tracking system for further investigation and resolution. We will keep you updated about the issue resolution progress.

Moreover, can you please confirm in which Aspose.Pdf for .NET this code was working as expected. It will help us to investigate the issue.

Best Regards,
Thank you for your response.
I think I'll have to take back my statement about this working in a previous version (v 9.4.0.0) though.
After some more testing we see the same behaviour in both versions.
We have just also found a work-around, which is to remove the body margin and padding:

html += "body { margin: 0; padding: 0; }"; // PUT BETWEEN STYLE TAGS
There's still seems to be a bug though, since saving this html code as PDF in Chrome
(from the Print dialogue) produces a correct PDF with text on all 5 pages.


Hi Patrick,


pigetto:
I think I'll have to take back my statement about this working in a previous version (v 9.4.0.0) though. 
After some more testing we see the same behaviour in both versions.


Thanks for confirming that it is not a regression issue.

pigetto:

We have just also found a work-around, which is to remove the body margin and padding:

html += "body { margin: 0; padding: 0; }"; // PUT BETWEEN STYLE TAGS
There's still seems to be a bug though, since saving this html code as PDF in Chrome
(from the Print dialogue) produces a correct PDF with text on all 5 pages.



Thanks for your finding. We have also passed it to our development team and they will be considered this information in issue investigation and resolution.


Best Regards,

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