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

Free Support Forum - aspose.com

Issue Converting HTML to PDF

Hi,

I am not able to convert the attached HTML to PDF using Aspose.PDF. The converted PDF file is not retaining any formatting specified in the HTML tag.

To rule out issues with a malformed HTML I used the same file in several other online conversion tool and the file converted correctly to PDF without any formatting issues.

Here is the code(using Aspose.PDF version 7.1):

Dim strHTML As String = File.ReadAllText("C:\testingRPT.html")

Dim oPDF As Pdf.Generator.Pdf = New Pdf.Generator.Pdf

Dim license As Aspose.Pdf.License = New Aspose.Pdf.License

license.SetLicense("Aspose.Total.lic")

oPDF.BindHTML(strHTML)

oPDF.IsLandscape = True

oPDF.Save("C:\ddxxhh.pdf")

Any help is truely appreciated.

Sid

Note: The file extension is renamed from .html to .txt to allow for uploading to the forum.

Hi,


Thanks for contacting support.

I
have tested the scenario and I am able to notice the same problem that formatting is not preserved when converting HTML file to PDF format. For the sake
of correction, I have logged this problem as PDFNEWNET-36148 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.<o:p></o:p>

The issues you have found earlier (filed as PDFNEWNET-36148) have been fixed in Aspose.Pdf for .NET 9.1.0.

For further details, you may check this blog post.


This message was posted using Notification2Forum from Downloads module by Aspose Notifier.

HI Seddesh,

Thanks for your patience. You may use new DOM approach for HTML to PDF conversion. Please try following code snippet, it will fix the issue.

HtmlLoadOptions options = new HtmlLoadOptions();<o:p></o:p>

// use the new conversion engine<o:p></o:p>

options.UseNewConversionEngine = true;<o:p></o:p>

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

Document pdfDocument = new Document(“Input.html”, options);

// save output as PDF format<o:p></o:p>

pdfDocument.Save(myDir + “Output.pdf”);

<o:p>
</o:p>

<o:p>Please feel free to contact us for any further assistance.</o:p>


Best Regards,