PdfGenerator.GeneratePdf don't work

Jun 4, 2015 at 7:23 PM
Edited Jun 4, 2015 at 7:28 PM
Good afternoon, I will discuss my situation ...

I use HtmlRenderer and PDFsharp to generate pdf from my application. Specifically use versions:
HtmlRenderer v1.5.0.6
PDFsharp v.1.50.3638.0

My problem is that in trying to generate the pdf document with the method:
PdfDocument pdf = PdfGenerator.GeneratePdf (htmlCode, PageSize.Letter); the error occurs:

An exception occurred in the type initializer 'TheArtOfDev.HtmlRenderer.PdfSharp.Adapters.GraphicsAdapter'.

The strange thing is that with previous versions of HtmlRenderer v.1.5.0.5 and PDFsharp v. 1.32.3057.0 worked perfectly.

My code is:
public byte[] GenerarPDFfromHTML(string htmlCode)
    {
        MemoryStream msBody = new MemoryStream();
        PdfDocument pdf = PdfGenerator.GeneratePdf(htmlCode, PageSize.Letter);
        pdf.Save(msBody, false);
        return msCuerpo.ToArray();
    }
I will appreciate your help.