Aspose.Pdf.Generator.Pdf pdf = new Aspose.Pdf.Generator.Pdf(); // add the section to PDF document sections collection Aspose.Pdf.Generator.Section section = pdf.Sections.Add();// Read the contents of HTML file into StreamReader object
StreamReader r = File.OpenText(@“D:/pdftest/HTML2pdf.html”);
//Create text paragraphs containing HTML text
Aspose.Pdf.Generator.Text text2 = new Aspose.Pdf.Generator.Text(section, r.ReadToEnd());
// enable the property to display HTML contents within their own formatting
text2.IsHtmlTagSupported = true;
//Add the text paragraphs containing HTML text to the section
section.Paragraphs.Add(text2);
// Specify the URL which serves as images database
pdf.HtmlInfo.ImgUrl = “D:/pdftest/MemoryStream/”;//Save the pdf document
pdf.Save(“D:/pdftest/MemoryStream/HTML2pdf.pdf”);
Hi Ying,
Thanks for using our products.
I have tested the scenario and I am able to reproduce the same problems that text is missing in resultant PDF and layout of PDF contents is not correct. For the sake of correction, I have logged it in our issue tracking system as PDFNEWNET-35873. We will investigate this issue in details and will keep you updated on the status of a correction.
We apologize for your inconvenience.
Hi, Shahzad
Thank you for replying. Is it possible to change the property of the pdf generated to correct this problem? Or is there any way you can recommend so that we can give a try?
It is very urgent because of the urgent delivery.
Thanks again.
Ying
Hi,
Hi Ying,
The issues you have found earlier (filed as PDFNEWNET-35873) have been fixed in Aspose.Pdf for .NET 9.1.0.
For further details, you may check this blog post.
This message was posted using Notification2Forum from Downloads module by Aspose Notifier.
HI Ying,
Thanks for your patience. You may use new DOM approach for HTML to PDF conversion. Please try following code snippet, it will fix the issue.
HtmlLoadOptions options = new HtmlLoadOptions();<o:p></o:p>
// use the new conversion engine<o:p></o:p>
options.UseNewConversionEngine = true;<o:p></o:p>
// load HTML file<o:p></o:p>
Document pdfDocument = new Document(“Input.html”, options);
// save output as PDF format<o:p></o:p>
pdfDocument.Save(myDir + “Output.pdf”);
<o:p>
</o:p>
<o:p>Please feel free to contact us for any further assistance.</o:p>
Best Regards,