Search code examples
c#unicodepdfsharpmigradoc

Japanese characters with MigraDoc/PDFsharp


I'm using MigraDoc for generating PDF documents, on my local machine. Japanese characters are not displayed properly.

I'm using the instructions below to generate the document with Unicode.

var document = new MigraDoc.DocumentObjectModel.Document();
//Do stuff...
PdfDocumentRenderer renderer = new PdfDocumentRenderer(true, PdfSharp.Pdf.PdfFontEmbedding.Always);
renderer.Document = document;

This works well for some non ASCII characters (accentuated letters), but not with Japanese characters.

From the examples on PDFsharp's website, I think I'm supposed to use a PdfDocument (and not a Migradoc document) objects, add pages to that document, and fill pages with Migradoc objects

http://www.pdfsharp.net/wiki/MixMigraDocAndPdfSharp-sample.ashx

However, I already have a complex, multipage document structure created with Migradoc; so I'd like to be able to just reuse it as it is (e.g. include it in one go into a PdfDocument)

Any idea?

Thanks


Solution

  • This seems to do the trick

    document.Styles[StyleNames.Normal].Font.Name = "Arial Unicode MS";
    

    It is also possible to embed fonts in the PDF document, to make sure everybody can read it