Html to PDF conversion results in PDF of source code

Hello,

We are using your assemblies to convert office file formats to PDF. We’re not doing anything special.

We’ve run across a scenario where we are converting .html files. Thus, we’re using the Aspose.Words (tried version 14.2.0.0) assembly. The odd thing is, some files are converted properly (resulting in a PDF of a web type page), while others are not recognized as html and are interpreted as straight text…resulting in a PDF that shows the source code (i.e. xml code).

I’m attaching an example of one that works and one that does not.

I’m interested to know what is required for Aspose.Word to recognize that a file is correctly formatted for html.

Thanks,

Jeff

Hi Jeff,

Thanks for your inquiry. I have converted the shared input HTML document to Pdf using latest version of Aspose.Words for .NET 14.2.0 and have not found any issue. I have attached the output Pdf file with this post for your kind reference.

I suggest you please load the HTML document into Aspose.Words.Document with LoadOptions as shown below.

Document doc = new Document(MyDir + "HtmlThatDoesNotWork.html",
    new LoadOptions(LoadFormat.Html, "", ""));

Please let us know if you have any more queries.

Thank you for your reply and suggestion…that worked!

Hi Jeff,

Thanks for your feedback. Please feel free to ask if you have any question about Aspose.Words, we will be happy to help you.