Converting advanced html files to PDF does not work

We have downloaded the latest versions available on nuget as of 24.08.2015, this means we use version 10.7.0 of Aspose.Pdf.

When trying to convert a html file generated by Office 2015 Outlook, Aspose fails.

Method 1 tried:
This method has been described in documentation and should be the easiest way to convert a html document to PDF.
Code block:

var htmlOptions = new HtmlLoadOptions();
fileToConvert = “424_FIX.HTML”;
var doc = new Aspose.Pdf.Document(fileToConvert, htmlOptions);

Exception message:
See first attachment

This error message is not helpful at all. What is wrong?

Method 2 tried:
Code block:

fileToConvert = “424_FIX.HTML”;
var pdfDocument = new Pdf();
var file = File.ReadAllText(fileToConvert, Encoding.UTF7);
var sec1 = pdfDocument.Sections.Add();
var text1 = new Aspose.Pdf.Generator.Text(file)
IsHtmlTagSupported = true

Exception message:
See second attachment

The error message in method 2 is correct, the html file does indeed contain mso-margin-top-alt. This is css styling that Office 2015 outlook is generating automaticly.

We need a fix on this problem as this problem is urgent.

Do you have any workaround available right now?

Hi Marius,

Thanks for using our API’s.

Can you please share the resource HTML so that we can test the scenario in our environment. We are sorry for this inconvenience.

However you may consider directly converting outlook emails to PDF format while using Aspose.Email and Aspose.Words API. For more information, please visit Saving a MSG as PDF

See attachment for an unconvertable html example

Hi Marius,

Thanks for sharing the resource file.

I have tested the conversion using following code snippet with Aspose.Pdf for .NET 10.7.0 in VisualStudio 2012 project with .NET Framework 4.0 running over Windows 7 (x64) and I am unable to notice any issue. As per your observations, the resultant file is properly being generated. For your reference, I have also attached the resultant file generated over my end.


Aspose.Pdf.Document doc = new Aspose.Pdf.Document(@“C:\pdftest\unconvertable.html”, new HtmlLoadOptions());<o:p></o:p>

// Save updated document containing table object