We have purchased a Site Small Business license for Aspose Total for .NET, mainly for an invoicing process that takes .docx files, replaces text, and produces PDF. For this, it seems to be working wonderfully.
However, we are running into issues with another small project which will take as input HTML pages and output a PDF.
I have tried using the Document.Save methods in both Aspose Words and Aspose PDF, as well as the InLine HTML method (should be top hits in google when searching for ‘Aspose HTML to PDF’).
We are still consistently getting rendering issues. Aspose Words seems to work the best for this conversion, but we still get HTML pages that were not converted, and are just spit out in raw HTML, as well as many elements on the page being shifted to the right or left after PDF conversion. To fix the shifting I am saving to a temporary .html file (so i can set the htmlsaveoptions.tablewidthoutputmode to none) before re-opening this temp file to save as PDF.
One of the major issues (and why we are using Aspose Words for this and not Aspose PDF) is that the mouse-over dropdown menus (that often appear for navigation on HTML pages), are being rendered over the actual text on the page, as if I had moused over the dropdown. Obviously, this covers some of the actual page text, and that is unwanted. Aspose Words does not seem to have this dropdown issue, but Aspose PDF does.
I was wondering if you have a best suggested method at the moment to convert HTML pages to PDF. I am copying below the current code I am using for this (using Aspose.Words as I said before). Please let me know if you have any suggestions.
Document doc = new Document(fileLocation);
HtmlSaveOptions htmlsave = new HtmlSaveOptions();
htmlsave.TableWidthOutputMode = HtmlElementSizeOutputMode.None;
string modhtml = fileLocation.Replace(".html", “modified.html”);
doc.Save(modhtml, htmlsave);
Document doc2 = new Document(modhtml);
string newLocation = fileLocation.Replace(".html", “.pdf”);
doc2.Save(newLocation);
string filepath = new FileInfo(fileLocation).Directory.FullName;
string filename = Path.GetFileName(fileLocation);
var files = new DirectoryInfo(filepath).GetFiles(filename.Replace(".html", “modified*”));
foreach (var f in files) { f.Delete();}
return newLocation;