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

Can not generate chinese character PDF file

    XMLWordPrintableJSON

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Critical
    • Resolution: Duplicate
    • Affects Version/s: 1.6.0
    • Fix Version/s: 2.0.0
    • Component/s: Writing
    • Labels:
    • Environment:
      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

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

                Dates

                • Created:
                  Updated:
                  Resolved: