Displaying Japanese Characters in PDF in Edge, Chrome

Posted by: Swapnil.Walwadkar on 24 February 2022, 8:13 am EST

    • Post Options:
    • Link

    Posted 24 February 2022, 8:13 am EST

    Hi

    I am creating a PDF file by using C1PdfDocument. The PDF file contains a combination of Japanese and English characters.

    When I open that PDF file in Acrobat reader, all the characters gets displayed correctly. However, when I open that PDF file in Microsoft Edge/Chrome, Japanese characters do not get displayed. Only English characters get displayed.

    I am attaching the sample PDF file.

    The following is the code to create a PDF file.

    	C1.C1Pdf.C1PdfDocument pdf = new C1.C1Pdf.C1PdfDocument();
                Font font = new Font("MS Gothic", 9, FontStyle.Regular);
    
                pdf.PaperKind = System.Drawing.Printing.PaperKind.A4;
                RectangleF rect = pdf.PageRectangle;
                rect.Inflate(-48, -48);
    
                pdf.Security.AllowCopyContent = false;
                pdf.Security.AllowEditContent = false;
                pdf.Security.AllowEditAnnotations = false;
    
                while (true)
                {
                    int nextChar = pdf.DrawString(data, font, Brushes.Black, rect);
                    if (nextChar >= data.Length)
                    {
                        break;
                    }
                    data = data.Substring(nextChar);
                    pdf.NewPage();
                }
                pdf.Save(path);
    

    Please let me know what could be the problem with the PDF created by C1PdfDocument.

  • Posted 25 February 2022, 6:53 am EST

    Hi Swapnil,

    Thanks for providing the code snippet.

    In order to display Japanese character(in Pdf) in Chrome/Edge, you need to set FontType as Embedded while creating Pdf. (see code snippet)

    
     pdf.FontType = PdfFontType.Embedded;
    
    

    Please refer the attached sample for the same: PdfDemo.zip

    Best Regards,

    Nitin

Need extra support?

Upgrade your support plan and get personal unlimited phone support with our customer engagement team

Learn More

Forum Channels