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

Free Support Forum - aspose.com

Html to Pdf doesn't work?

My company has purchased the Aspose.Total product. One of the main reasons we bought this product was the HTML-to-PDF conversion capabilities and now that we are attempting to do this conversion, we can’t seem to make it work. We originally did a prototype of this functionality maybe a year and a half ago and it worked fine, but it appears that the API has changed quite a bit with the latest versions.

The code seems fairly straightforward - below is what I’m trying to do. I will attach my sample HTML file as well as the resulting PDF which isn’t even in the ballpark of looking correct. The only support page I can find that seems relevant on HTML to PDF conversion is not helpful (http://www.aspose.com/docs/display/pdfnet/How+to+convert+HTML+to+PDF+using+InLineHTML+approach).

Please let me know if you need our license file so I can email. Also, I can send the snippet of code from the older versions of the Aspose.Pdf.Kit product that we originally used to prototype where this seemed to work.

	    // Get a stream representing the sample html file
Stream wordStream = System.Reflection.Assembly.GetExecutingAssembly().GetManifestResourceStream(SAMPLE_HTML_FILE);
        <span style="color:green;">// Read the contents of HTML file into StreamReader object</span>
        <span style="color:#2b91af;">StreamReader</span> r = <span style="color:blue;">new</span> <span style="color:#2b91af;">StreamReader</span>(htmlStream);

        AsposePdf.Generator.<span style="color:#2b91af;">Pdf</span> pdf = <span style="color:blue;">new</span> AsposePdf.Generator.<span style="color:#2b91af;">Pdf</span>();
        AsposePdf.Generator.<span style="color:#2b91af;">Section</span> section = pdf.Sections.Add();

        AsposePdf.Generator.<span style="color:#2b91af;">Text</span> text = <span style="color:blue;">new</span> AsposePdf.Generator.<span style="color:#2b91af;">Text</span>(section, r.ReadToEnd());
        text.IsHtmlTagSupported = <span style="color:blue;">true</span>;

        pdf.Save(<span style="color:#a31515;">@"C:\content\formtest.pdf"</span>);</pre></div>

Hi Jared,

Thanks for using our products.

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-33932 in
our issue tracking system. We will further look into the details of this
problem and will keep you updated with the status of correction.

We apologize for your inconvenience.


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

The blog post for this release is created over this link

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

Hi Jared,

Thanks for your patience. As informed above, your reported issue has been resolved.

Please use following code snippet, based on new Document Object Model (DOM)., with latest release of Aspose.Pdf for .NET. It will serve the purpose.

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

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

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

htmloptions.PageInfo.Height = 900; // First page contains block higher than A4<o:p></o:p>

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

Document doc = new Document(myDir + “Test.html”, htmloptions);<o:p></o:p>

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



Please feel free to contact us for any further assistance.


<o:p>Best Regards,</o:p>