Free Support Forum - aspose.com

HTML to PDF Format issue

Hi,


I am not able to set correct setting for HTML to PDF conversion.

I have attache PDF file. (Not able to attache HTML file)

My Test code :


Aspose.Pdf.Generator.Pdf pdf = new Aspose.Pdf.Generator.Pdf();
Aspose.Pdf.Generator.Section section = pdf.Sections.Add();
StreamReader r = System.IO.File.OpenText(cConstruct.Source);

Aspose.Pdf.Generator.Text text2 = new Aspose.Pdf.Generator.Text(section, r.ReadToEnd());
text2.IfHtmlTagSupportedOverwriteHtmlFontNames = true;
text2.IfHtmlTagSupportedOverwriteHtmlFontSizes = true;
text2.IsHtmlTagSupported = true;
text2.IsHtml5Supported = true;
text2.IsFitToPage = true;
section.Paragraphs.Add(text2);
pdf.Save(“test.pdf”);

Any help would be appreciated !!!

Hi,


It looks like you are using Aspose.Pdf component, so I am moving your thread to Aspose.Pdf forum. One of my fellow colleagues from Aspose.Pdf team will help you soon there.

Thank you.

Hi Jim,


Thanks for your inquiry. Please use new DOM approach for HTML to PDF conversion, it will resolve the issue. However if the issue persist then we need to your test your source HTML document, you can archive your html file and attach to forum post. So we will test the scenario and will guide you accordingly.


Please feel free to contact us for any further assistance.

Best Regards,

Hi Tilal,


Thank you for your quick response.

Dom Approch does not solve the issue.

I have attache HTMLFile.zip , where you can get HTML file.

Thanks !!!

Hi Jim,


Thanks for sharing the resource file.

I have tested the scenario using Aspose.Pdf for .NET 10.7.0 where I have used following code snippet and as per my observations, the resultant file is properly being generated. For your reference, I have also attached the resultant file generated over my end.

For your reference, I have also attached the PDF file generated over my end.

[C#]

// Specify the The base path/url for
the html file which serves as images database
<o:p></o:p>

String basePath = @"C:\pdftest\HTMLFile\HTMLFile\";

HtmlLoadOptions htmloptions = new HtmlLoadOptions(basePath);

// Load HTML file

Document doc = new Document(basePath+"Test.html", htmloptions);

// Save HTML file

doc.Save(basePath + "Test_output.pdf");