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

Free Support Forum - aspose.com

HTML to PDF conversion with floats

Hi


I’m trying to convert an HTML file to a PDF and getting some problems with the results. Can I use css floats in the HTML or are they unsupported? There also appear to be some problems with padding and margins being ignored.

The code I’m using to do the conversion is as follows.

Aspose.Pdf.Generator.Pdf pdf = new Aspose.Pdf.Generator.Pdf();

pdf.PageSetup.PageWidth = 612F;
pdf.PageSetup.PageHeight = 792F;
pdf.PageSetup.Margin.Top = 21.6F;
pdf.PageSetup.Margin.Bottom = 54F;
pdf.PageSetup.Margin.Left = 72F;
pdf.PageSetup.Margin.Right = 72F;

Aspose.Pdf.Generator.Section section = pdf.Sections.Add();
Aspose.Pdf.Generator.Text text2 = new Aspose.Pdf.Generator.Text(section, strHTML);
text2.IsHtmlTagSupported = true;
section.Paragraphs.Add(text2);

pdf.Save(pdfFileName);

I have attached the HTML file I’m trying to convert.

Thanks for your help.

Russell

Hi Russell,


Thanks
for using our products.<o:p></o:p>

I have tested the scenario and I am able to reproduce the same problem. For the sake of correction, I have logged it in our issue tracking system as PDFNEWNET-34967. We will investigate this issue in details and will keep you updated on the status of a correction.

We apologize for your inconvenience.

Hi


Is there any update on this issue?

Thanks

Hi Russell,


Thanks for your patience.

The development team has been busy resolving other priority issues and I am afraid the issue reported earlier is not yet resolved. Please note that as soon as we have made some progress towards the resolution of this issue, we would be more than happy to update you with the status of correction.

Please be patient and spare us little time. We are sorry for this delay and inconvenience.

Is there any update on this yet? I’ve attached another example HTML file if that helps.


Thank you.

Carl Steffen

Side Comments - other toolkits seem to have it working very well - is there anything to be learned from them?
http://pdfcrowd.com/#convert_by_input
http://www.html-to-pdf.net/free-html-to-pdf-converter.aspx

I’ve found a free (opensource) .net toolkit that works fantastically… It’s probably not the best in terms of resource utilization (I’ve not looked into it that far) but the result is nearly perfect.


https://github.com/tuespetre/Pechkin


Hi Carl,


Thanks for contacting support.

I have tested the scenario using following code snippet with Aspose.Pdf for .NET 8.8.0 and I am able to notice the formatting issues in resultant PDF file. For the sake of correction, I have logged this problem
as
PDFNEWNET-36227 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. Please be patient and spare us little time. We are sorry for
this inconvenience.

Since HTML to PDF conversion is a complex functionality, so in some scenarios, this feature encounters some issues. Nevertheless, the development team is working hard on making this feature stable and robust enough so that it can generate the output identical to input file.

[C#]

// load source HTML<o:p></o:p>

Document doc = new Document(@"C:\pdftest\html2PDF\html2PDF.htm", new HtmlLoadOptions() { UseNewConversionEngine = true });

// save the output file

doc.Save(@“C:\pdftest\html2PDF\html2PDF.pdf”);

The issues you have found earlier (filed as PDFNET-34967) have been fixed in Aspose.PDF for .NET 19.6.

The issues you have found earlier (filed as PDFNET-36227) have been fixed in Aspose.PDF for .NET 20.8.