GrapeCity.Documents.Pdf -> Add elements throw exceptions

Posted by: gerd.greiner on 3 May 2018, 10:40 pm EST

  • Posted 3 May 2018, 10:40 pm EST

    Hi Guys,

    I'm using the brand new GrapeCity.Documents.Pdf (V. nuget package in my
    .Net Standard 2.0 project.
    I have problems with adding elements to the document (see code below g.DrawString(..)).
    I always get following exception:
    "An unhandled exception of type 'System.AccessViolationException' occurred in Grapecity.Documents.Common.dll. Attempted to read or write protected memory. This is often indication that other memory is corrupt."

    I have also downloaded the Visual Studio sample project but there the same exception occurs.

    Example Code: The exception occurs at g.DrawString

    // Create a new PDF document:
    GcPdfDocument doc = new GcPdfDocument();
    // Add a page, get its graphics:
    GcPdfGraphics g = doc.NewPage().Graphics;
    // Render a string into the page:
    g.DrawString("Hello, World!",
    // Use a standard font (the 14 standard PDF fonts are built into GcPdf
    // and are always available):
    new TextFormat() { Font = StandardFonts.Times, FontSize = 12 },
    // GcPdf page coordinates start at top left corner, using 72 dpi by default:
    new PointF(72, 72));
    // Save the PDF:

    Kind regards,
  • Replied 6 May 2018, 6:18 pm EST

    Hello Gerd,

    Thank you for choosing GrapeCity Documents for PDF.
    We tried the same code snippet but could not replicate the error at our end.
    Please try using the latest packages from ( with the attached sample and inform if the issue persists.
    If you still observe the issue, please share the modified sample for us to assist you further.

  • Replied 6 May 2018, 11:03 pm EST


    I can confirm the problem described above. I tried the attached zip without modification and got the System.AccessViolationException error. I also tried changing the version of the package to after the first try failed with the same result.

    I'm using Windows 10 and also tried to execute the program in Admin Mode. If you need further system information or anything please ask.

    Thanks and best regards
  • Replied 7 May 2018, 2:37 am EST

    Guys, could you please build and run this small utility:

    and let us know what happens. On initialization GcPdf tries to build the system font collection, and currently the only idea we have is that maybe there is some font in your systems that breaks our font parser. This utility will list system fonts using the same logic as GcPdf, and if it breaks on some font(s) we should be able to find the problem.

  • Replied 7 May 2018, 6:50 pm EST


    I had run the 'EnumFonts' test application. The program breaks at a specific font.

    It breaks at 'Parsing C:\Windows\Fonts\arimon__.ttf'. The Exception is "An unhandled exception of type 'System.AccessViolationException' occurred in GrapeCity.Documents.Common.dll'
    Attempted to read or write protected memory. This is often an indication that other memory is corrupt."

    The Error occurs at method 'QuickParseFontFile' Font.From(path, true). The exception is not handled in the catch block. Afterwards the program stops.

    Kind regards,

    Enumerating System Fonts (quick check)
    parsing C:\WINDOWS\Fonts\3OF9_NEW.TTF (done)
    parsing C:\WINDOWS\Fonts\AGENCYB.TTF (done)
    parsing C:\WINDOWS\Fonts\AGENCYR.TTF (done)
    parsing C:\WINDOWS\Fonts\ahronbd.ttf (done)
    parsing C:\WINDOWS\Fonts\ALGER.TTF (done)
    parsing C:\WINDOWS\Fonts\andlso.ttf (done)
    parsing C:\WINDOWS\Fonts\angsa.ttf (done)
    parsing C:\WINDOWS\Fonts\angsab.ttf (done)
    parsing C:\WINDOWS\Fonts\angsai.ttf (done)
    parsing C:\WINDOWS\Fonts\angsau.ttf (done)
    parsing C:\WINDOWS\Fonts\angsaub.ttf (done)
    parsing C:\WINDOWS\Fonts\angsaui.ttf (done)
    parsing C:\WINDOWS\Fonts\angsauz.ttf (done)
    parsing C:\WINDOWS\Fonts\angsaz.ttf (done)
    parsing C:\WINDOWS\Fonts\ANTQUAB.TTF (done)
    parsing C:\WINDOWS\Fonts\ANTQUABI.TTF (done)
    parsing C:\WINDOWS\Fonts\ANTQUAI.TTF (done)
    parsing C:\WINDOWS\Fonts\aparaj.ttf (done)
    parsing C:\WINDOWS\Fonts\aparajb.ttf (done)
    parsing C:\WINDOWS\Fonts\aparajbi.ttf (done)
    parsing C:\WINDOWS\Fonts\aparaji.ttf (done)
    parsing C:\WINDOWS\Fonts\arabtype.ttf (done)
    parsing C:\WINDOWS\Fonts\arial.ttf (done)
    parsing C:\WINDOWS\Fonts\arialbd.ttf (done)
    parsing C:\WINDOWS\Fonts\arialbi.ttf (done)
    parsing C:\WINDOWS\Fonts\ariali.ttf (done)
    parsing C:\WINDOWS\Fonts\ARIALN.TTF (done)
    parsing C:\WINDOWS\Fonts\ARIALNB.TTF (done)
    parsing C:\WINDOWS\Fonts\ARIALNBI.TTF (done)
    parsing C:\WINDOWS\Fonts\ARIALNI.TTF (done)
    parsing C:\WINDOWS\Fonts\ARIALUNI.TTF (done)
    parsing C:\WINDOWS\Fonts\ariblk.ttf (done)
    parsing C:\WINDOWS\Fonts\arimonbd.ttf (done)
    parsing C:\WINDOWS\Fonts\arimon__.ttf
  • Replied 7 May 2018, 11:00 pm EST

    Hi Gerd,

    Many thanks for your reply/info. Could you please do the following: send me the arimon__.ttf that you have (we tried it with a arimon__.ttf that we found, but it doesn't crash, so possibly you have a different version), and remove the font from the system (copy the physical file somewhere first of course so that you can reinstall it afterwards) and see if that helps?

    My email is

    Your help with this issue is very much appreciated!

  • Replied 9 May 2018, 4:51 am EST

    Update: we found a version of arimon__.ttf which triggered this error. In that particular file, the post table contained invalid data, which caused the crash. We changed our code to deal with such situations, as soon as the update is available on NuGet I'll post a note here. The temporary workaround for anybody experiencing this problem is to run the EnumFonts test app, and uninstall the font at which it stops (so far I'm not aware of any other fonts besides certain arimon__.ttf's that cause this).

  • Replied 14 May 2018, 9:25 pm EST


    I can confirm that it works once I remove the arimon_.ttf font so thanks for providing this workaround.
    Another question:
    How does the licensing work? We have a ComponentOne Ultimate subscription so I'm thinking this includes the Documents library. I found the statement in the documentation that I can pass the key in the constructor like this:
    var doc = new GcPdfDocument(key)

    So I tried creating an App key for an ASP .NET Core app and set it as the key but I got an invalid license key error for that. So how do I get a valid license key?

    Thanks and best regards
  • Marked as Answer

    Replied 15 May 2018, 3:52 am EST


    The access violation has been fixed in the new build which is now available on NuGet:

    As for licensing: you're right that in order to have a licensed GcPdf, you need to use the ctor that accepts a license key. Alternatively, you can call the static method GcPdfDocument.SetLicenseKey(key) and all instances of GcPdfDocument will be licensed while the program runs. But, AFAIK, Documents for PDF is not included in the current subscriptions. Please contact our sales for details.

Need extra support?

Upgrade your support plan and get personal unlimited phone support with our customer engagement team

Learn More

Forum Channels