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

Free Support Forum - aspose.com

HTML to PDF using InLineHTML

I have an HTML file that doesnt get render properly in the newly created pdf. It looks like the padding\ margins are getting lost. I have attched my html file and the resulting pdf document.

// Instantiate an object PDF class
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(@"C:\testEmailDownload\header.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 = @"C:\testEmailDownload\bc_logo_sm_bgCyan.gif";//Save the pdf document
pdf.Save(@"C:\testEmailDownload\headerOnly.pdf");

Hi Derek,

Thank you for considering Aspose.Pdf.

I have tested the scenario and I am able to notice the same problem. For the sake of correction, I have logged this problem as PDFNEWNET-32954 in our issue tracking system. We will further look into the details of this problem and will keep you updated on the status of correction.

We apologize for your inconvenience.

Thanks & Regards,

Hi Derek,

Thanks for your patience.

I am pleased to share that your reported issue has been fixed in our latest release version of Aspose.Pdf for .NET v6.8. Please try using it and in case you still face any problem or you have any further query, please feel free to contact. We are sorry for your inconvenience.

Thanks & Regards,