4

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.

1 Answer 1

7

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

3
  • 1
    can this be done entirely in MigraDoc or do I need to convert everything to PDFSharp? I'm trying to use the character \u260E and I'm having a bit of trouble with it.
    – whossname
    Jul 9, 2016 at 10:00
  • The first solution doesn't work for me. It seems MigraDoc document doesn't play nicely with PdfSharp's document renderer. Whole story: net-c-sharp-migradoc-how-to-change-document-charset Jul 15, 2016 at 19:38
  • 1
    This option is now obsolote, please use it with only single parameter pass true if it is used unicode characters else pass false will be used WinAnsi encoding PdfDocumentRenderer pdfRenderer = new PdfDocumentRenderer(true);
    – Nazim
    Jul 30, 2019 at 10:58

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.