Search code examples
c#pdf-generationmigradoc

Does MigraDoc support national characters/ unicode characters?


I’m using MigraDoc for generating PDF documents. It works very well but I have 2 problems:

  1. I cannot add Polish characters (especially ł) to text like.
  2. I cannot add pound character (₤) to text.

I tried to change font, but no result.


Solution

  • I solved this on my own:)

    Using Unicode fonts can be set in 2 ways:

    1) by PdfDocumentRenderer constructor:

    PdfDocumentRenderer pdfRenderer = new PdfDocumentRenderer(true, PdfFontEmbedding.Always);
    

    2) by options;

    PdfDocument document = new PdfDocument();
    
        XPdfFontOptions options = new XPdfFontOptions(PdfFontEncoding.Unicode, PdfFontEmbedding.Always);
    

    Additional example here: http://www.pdfsharp.net/wiki/Unicode-sample.ashx