Example_02

Drawing Japanese, Korean, Simplified Chinese and Traditional Chinese text with embedded IBM Plex Sans fonts.

Example_02.pdf — the PDF this example creates.

/*
 * Example_02.cs
 *
 * Copyright (c) 2026 PDFjet Software
 * Licensed under the MIT License. See LICENSE file in the project root.
 */
using System;
using System.IO;
using System.Diagnostics;
using PDFjet.NET;

/**
 * Example_02.cs
 */
public class Example_02 {
    public Example_02() {
        PDF pdf = new PDF(new BufferedStream(
                new FileStream("Example_02.pdf", FileMode.Create)));

        Font f1 = new Font(pdf, IBMPlexSansJP.Regular);
        f1.SetSize(14f);

        Font f2 = new Font(pdf, IBMPlexSansKR.Regular);
        f2.SetSize(14f);

        Font f3 = new Font(pdf, IBMPlexSansSC.Regular);
        f3.SetSize(14f);

        Font f4 = new Font(pdf, IBMPlexSansTC.Regular);
        f4.SetSize(14f);

        Page page = new Page(pdf, Letter.PORTRAIT);

        TextBlock textBlock = new TextBlock(
                f1, Content.OfTextFile("data/languages/japanese.txt"));
        textBlock.SetLocation(50f, 50f);
        textBlock.SetWidth(415f);
        textBlock.DrawOn(page);

        page = new Page(pdf, Letter.PORTRAIT);

        textBlock = new TextBlock(
                f2, Content.OfTextFile("data/languages/korean.txt"));
        textBlock.SetLocation(50f, 50f);
        textBlock.SetWidth(415f);
        textBlock.DrawOn(page);

        page = new Page(pdf, Letter.PORTRAIT);

        textBlock = new TextBlock(
                f3, Content.OfTextFile("data/languages/simplified-chinese.txt"));
        textBlock.SetLocation(50f, 50f);
        textBlock.SetWidth(415f);
        textBlock.DrawOn(page);

        page = new Page(pdf, Letter.PORTRAIT);

        textBlock = new TextBlock(
                f4, Content.OfTextFile("data/languages/traditional-chinese.txt"));
        textBlock.SetLocation(50f, 50f);
        textBlock.SetWidth(415f);
        textBlock.DrawOn(page);

        pdf.Complete();
    }

    public static void Main(String[] args) {
        Stopwatch sw = Stopwatch.StartNew();
        long time0 = sw.ElapsedMilliseconds;
        new Example_02();
        long time1 = sw.ElapsedMilliseconds;
        sw.Stop();
        Console.WriteLine($"Example_02 => {time1 - time0,4} ms");
    }
}   // End of Example_02.cs

©2026 PDFjet Software.