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

Chinese, Korean - MultiByte Character displayed incorrectly

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Blocker
    • Resolution: Duplicate
    • Affects Version/s: 1.7.0, 1.8.0, 1.8.1
    • Fix Version/s: None
    • Component/s: FontBox, JempBox
    • Environment:
      Java, Mac OS, Linux

      Description

      While trying using Chinese Character to write to a PDF, it Displays incorrectly. Sample Code tried .
      Also tried with other TTF Files fireflysung.ttf,gbsn00lp.ttf, 金梅毛行书.TTF, SimSun.ttf . Have also tried Modifying the Encoding in PDTrueTypeFont.java loadTTF(PDDocument doc, InputStream stream) method.

      PDDocument pdDocument = new PDDocument();
      pdDocument.addPage(new PDPage());
      BufferedImage bi = new BufferedImage(10, 10, 10);
      Points point = new Points(300, 500);
      @SuppressWarnings("unchecked")
      List<PDPage> list = pdDocument.getDocumentCatalog().getAllPages();
      PDPage pdPage = list.get(list.size() - 1);
      String fontPathName = "sazanami-gothic.ttf";
      PDFont fonta = PDTrueTypeFont.loadTTF(pdDocument,
      Sample.class.getClassLoader()
      .getResource(fontPathName).openStream() );

      PDJpeg ximage = new PDJpeg(pdDocument, bi);
      PDPageContentStream contentStream = new PDPageContentStream(pdDocument,
      pdPage, true, true);
      contentStream.beginText();
      contentStream.setFont(fonta,18);
      contentStream.moveTextPositionByAmount(point.getX(), point.getY() - 10 );
      contentStream.setNonStrokingColor(Color.black);
      contentStream.drawString("悲しい");
      contentStream.endText();
      contentStream.close();
      pdDocument.save("test/Test.pdf");
      pdDocument.close();

      I also looked into other issues reported PDFBOX-1071, PDFBOX-1302 , PDFBOX-491, PDFBOX-696,PDFBOX-725

        Attachments

        1. Test.pdf
          4.38 MB
          Harippriya Parameswaran

          Issue Links

            Activity

              People

              • Assignee:
                lehmi Andreas Lehmkühler
                Reporter:
                harippriya Harippriya Parameswaran
              • Votes:
                0 Vote for this issue
                Watchers:
                2 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved: