Uploaded image for project: 'PDFBox'
  1. PDFBox
  2. PDFBOX-1071

Can not generate chinese character PDF file

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Critical
    • Resolution: Duplicate
    • 1.6.0
    • 2.0.0
    • Writing
    • Windows XP
      Oracle JDK 1.6

    Description

      I practice the PDF generate code for chinese character and load the chinese font ttf, but can not get the chinese PDF with correct display.'
      The code is as below: The font coding is UTF-8

      doc = new PDDocument();
      PDPage page = new PDPage();
      doc.addPage( page );
      PDFont font = PDTrueTypeFont.loadTTF(doc, "d:\\temp\\ttf
      fireflysung.ttf");
      PDPageContentStream contentStream = new PDPageContentStream(doc, page);
      contentStream.beginText();
      contentStream.moveTextPositionByAmount(100, 700);
      contentStream.setFont(font,12);

      contentStream.drawString("中文測試");
      contentStream.endText();
      contentStream.close();
      doc.save("d:\\temp
      helloworld.pdf");

      Attachments

        1. fireflysung.zip
          6.49 MB
          Linus Tseng

        Issue Links

          Activity

            People

              Unassigned Unassigned
              linus tseng Linus Tseng
              Votes:
              0 Vote for this issue
              Watchers:
              0 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: