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

Free Support Forum - aspose.com

BindHtml to convert html to pdf


I am using inline html to convert to pdf.
For that I am using pdf.BindHtml(filename, basepath) function.

I have got all styles applied to pdf, but having issue with cellpadding and page break.

for cellpadding I am using

for page-break I am using

but it’s not working. Please help me, I am struggling with this from 2 days.
Please note I am using version 6.9, I have got license for that, so I cannot upgrade for now.

Hi Nidhi,

Thanks for your inquiry. The subjected issues has been fixed in new DOM approach of HTML to PDF conversion. Please download and try latest version of Aspose.Pdf for the purpose. Hopefully it will help you to accomplish the requirements.

Moreover in reference to old version support, I would like to update you that we maintain a single code base of Aspose Components. All the fixes and new features/enhancements are implemented in latest version of DLL. So we are unable to provide any hotfix for older versions so we recommend customers to use latest versions.

We are sorry for the inconvenience caused.

Best Regards,

Hi Tilal,

Thanks for your reply.
Unfortunately I cannot use any version later than 8.2.

I will have to find some other way for page break, I think I will find some workaround for that.

But if you can give me some solution for cellpadding it would be good. My all data in table, which is converted to pdf. When I check pdf, there is not any space between text and it looks crap.

Can you help me to add space/margin/padding anything for table and cell, which make my pdf looks good.

Hi Nidhi,

Thanks for your feedback. I am afraid we have fixed the issue in new DOM approach not in old Generator ( Aspose.Pdf.Generator). We can not suggest you any workaround for the old version. If you have Aspose.Total licence then you can try some legitimate version of Aspose.Words for the HTML to PDF conversion.

Document doc = new Document(MyDir

  • @“in.html”);<o:p></o:p>

doc.Save(MyDir + @"out.pdf");

We are sorry for the inconvenience caused.

Best Regards,

I had tried that, but that doesn’t work.

It’s ok I come up with this and it works for me for page break

private static byte[] ConvertHTMLToPDF(string astrHTML)
Aspose.Pdf.License lobjLicense = new Aspose.Pdf.License();
//Location of license file
lobjLicense.SetLicense(@“C:\Program Files (x86)\Aspose\Aspose.Total.lic”);
MemoryStream lmsOutput = new MemoryStream();
Pdf ldocPdf = new Pdf();
Aspose.Pdf.Generator.Section lobjSection = ldocPdf.Sections.Add();
lobjSection.PageInfo.PageWidth = Aspose.Pdf.Generator.PageSize.LetterWidth;
lobjSection.PageInfo.PageHeight = Aspose.Pdf.Generator.PageSize.LetterHeight;

String[] lstrHtmlPages = astrHTML.Split(new string[] { “[PAGEBREAK]” }, StringSplitOptions.None);
Int32 lintCount = 0;
foreach (String lstrHtmlPage in lstrHtmlPages)
Text ltxtText = new Text(lobjSection, lstrHtmlPage);
ltxtText.IsHtmlTagSupported = true;
if (lintCount > 0)
lobjSection.Paragraphs.Add(new Aspose.Pdf.Generator.Text(lobjSection, “#$NP”));
catch (Exception excep)
throw (excep);
return lmsOutput.GetBuffer();

Now only one issue is pending that;'s cellpadding

Hi Tilal,

My table style is this,

but it’s not adding any padding for any td or th.

Can you give me solution for that?

Hi Nidhi,

Thanks for your feedback. It is good to know that you had find a workaround for one of the problem. You may google for other problem as well. Please check this link for the purpose.

However, we highly recommend you to upgrade to latest version of Aspose.Pdf for .NET. As it support the subjected features and you do not need any extra coding to address these separately.

Please feel free to contact us for any further assistance.

Best Regards,