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 (
https://docs.aspose.com/pdf/net/convert-html-to-pdf/).
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>;
section.Paragraphs.Add(text);
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 the following code snippet, based on the new Document Object Model (DOM), with the latest release of Aspose.Pdf for .NET. It will serve the purpose.
HtmlLoadOptions htmloptions = new HtmlLoadOptions();
// use the new conversion engine
htmloptions.UseNewConversionEngine = true;
htmloptions.PageInfo.Height = 900; // First page contains block higher than A4
// load HTML file
Document doc = new Document(myDir + "Test.html", htmloptions);
// Save HTML file
doc.Save(myDir + "HTMLtoPDFDOM.pdf");
Please feel free to contact us for any further assistance.
Best Regards,