How To Create PDF with Unicode and CJK Support

This sample shows how to create PDF Document in .NET with Unicode and CJK fonts.

Unicode and CJK fonts

C#:

 

using PDFMosaic;
using System.Drawing;

namespace Fonts
{
    class Fonts
    {
        static void Main()
        {
            PDFDocument document = new PDFDocument();
            document.Pages.Add(new PDFPage(PDFPaperFormat.A4));
            PDFCanvas canvas = document.Pages[0].Canvas;

            PDFBrush brush = new PDFSolidBrush();

            PDFFont font = new PDFFont("Arial", 12);

            canvas.DrawString("English -- Hello, World!", font, brush, 10, 10);
            canvas.DrawString("Russian -- ??????, ???!", font, brush, 10, 30);
            canvas.DrawString("French -- Vous êtes le Phénix des hôtes de ces bois.", font, brush, 10, 50);
            canvas.DrawString("German -- In ihrem Aufgabenbereich lag die komplette Organisation des Sekretariat des Geschäftsführers", font, brush, 10, 70);
            canvas.DrawString("Spanish -- Texto de ejemplo", font, brush, 10, 90);
	    canvas.DrawString("Arabic -- ????? ???? ???? ??? ????? ??? ???? ??????", font, brush, 10, 110);
            canvas.DrawString("Turkish  -- Yukarda mavi gök, asa??da ya??z yer yarat?ld?kta", font, brush, 10, 130);
			
	    font = new PDFFont("Gulim", 12);
	    canvas.DrawString("Korean -- ?? ????? ??? ? ?? ????. ??? ??? ?? ???. ??? ??? ??? ?????. ??? ?? ?? ??? ??? ?????? ?????. ?? ?? ??? ??? ???? ?? ???.", font, brush, 10, 150);
            canvas.DrawString("Chinese -- ?????", font, brush, 10, 180);
            
	    font = new PDFFont("MS Gothic", 12);
	    canvas.DrawString("Japanese -- ??????????????", font, brush, 10, 210);

            document.Save("Fonts.pdf", true);
        }
    }
}