Html to pdf System.ArgumentException was unhandled by user code

Hi

I’m trying to save an HTML email as PDF, but Aspose.PDF throws System.ArgumentException “value”. Here is the code to replicate the issue.

Code:

string b = "<p class=\"MsoNormal\" style=\"text-align: justify;\"><span style=\"font-family: 'Bell MT', serif;\">Dear Mr Test</span></p>";
byte[] correspondenceBytes = Encoding.UTF8.GetBytes(b);
string fileName = "c:\temp\test.pdf";
using (MemoryStream ms = new MemoryStream(correspondenceBytes))
{
    Document document = new Document(ms, new HtmlLoadOptions()); // Exception
    document.Save(fileName, SaveFormat.Pdf);
}

Stack trace:

System.ArgumentException was unhandled by user code
  HResult=-2147024809
  Message=value
  Source=Aspose.Pdf

    at    .   .TryGetValue(String token,    & value)
    at    .   .GetValue(String )
    at    .   .    [T]()
    at    .   .    [T]()
    at    .   .   ()
    at     .    .Initialize(    ,     )
    at     .    ..ctor(     ,     ,     )
    at     .    ..ctor(     ,     )
    at     .    .   (    )
    at     .    .    (    )
    at     .    .   (    )
    at     .    .    (    )
    at     .   .    (    )
    at     .    .    (    )
    at     .    .    (    )
    at     .   .    (    )
    at     .    .    (    )
    at     .    .Convert(    ,      )
    at     .    .Convert(Stream ,      )
    at    .    .Convert(Stream , Document ,     , HtmlLoadOptions )
    at Aspose.Pdf.Document.   (Stream , LoadOptions )
    at Aspose.Pdf.Document..ctor(Stream input, LoadOptions options)

If I remove “background-attachment” etc. from style then PDF is generated.

Thanks

Sourabh

Aspose.Pdf 10.9.0.0

Hi Sourabh,


Thanks for contacting support.

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-40043 in our issue tracking system. We will
further look into the details of this problem and will keep you updated on the
status of correction. Please be patient and spare us little time. We are sorry
for this inconvenience.

The issues you have found earlier (filed as PDFNET-40043) have been fixed in Aspose.PDF for .NET 19.11.