Hi
I am trying to convert a small html file to pdf for poc but style's is not working. I have attached the html file in zip folder. We are using following code for conversion
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(infilename);
//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;
text2.IfHtmlTagSupportedOverwriteHtmlFontSizes = true;
text2.IfHtmlTagSupportedOverwriteHtmlFontNames = true;
//Add the text paragraphs containing HTML text to the section
section.Paragraphs.Add(text2);
pdf.HtmlInfo.BadHtmlHandlingStrategy = BadHtmlHandlingStrategy.TreatAsPlainText;
pdf.HtmlInfo.ShowUnknownHtmlTagsAsText = true;
//Save the pdf document
pdf.Save(outFileName);
We also tried other APIs but didnot work.
We have full lincense (Fidelity Worldwide). Please suggest best way to handle that.
Hi Ashish,
Thanks for your inquiry. It is recommend to use new
DOM approach for HTML to PDF conversion. But unfortunately it is malfunctioning with your sample HTML. So we have logged a ticket PDFNEWNET-38133 in our issue tracking system for further investigation and resolution. We will notify you as soon as it is resolved.
We are sorry for the inconvenience caused.
Best Regards,
Hi Tilal,
Is there any updated on the above?
Also I tried another approach as you suggested but it is not working as expected. Used the below code
string contents = File.ReadAllText(infilename);
HtmlLoadOptions htmlLoadOptions = new HtmlLoadOptions(@"C:\NewData\");
// Load HTML string
Document doc = new Document(new MemoryStream(Encoding.UTF8.GetBytes(contents)), htmlLoadOptions);
// Save PDF file
doc.Save(@"C:\NewData\Test3.pdf");
but it is creating a blank pdf. The same html is used here as well.
Please can you check and let me know best approach with sample code, which converts the html as expected. Let me know if you need any other information.
Thanks
Hi Ashish,
Thanks for your inquiry. I am sorry for the confusion. I have already noticed the issue with new DOM approach as well and logged in our issue tracking system, as I stated above. We will keep you updated about the issue resolution progress within this forum thread.
tilal.ahmad:
It is recommend to use new
DOM approach for HTML to PDFconversion. But unfortunately it is malfunctioning with your sample HTML. So we have logged a ticket PDFNEWNET-38133 in our issue tracking system for further investigation and resolution. We will notify you as soon as it is resolved.
We are sorry for the inconvenience caused.
Best Regards,
Hi Ashish,
Thanks for your inquiry. I am afraid the reported issue is still not resolved due to other issues already under investigation and resolution. However we have requested our product team to investigate the issue and share an ETA at their earliest. We will notify you as soon as we get a feedback.
Thanks for your patience and cooperation.
Best Regards,
The issues you have found earlier (filed as PDFNEWNET-38133) have been fixed in Aspose.Pdf for .NET 10.6.0.
This message was posted using Notification2Forum from Downloads module by Aspose Notifier.