Can not generate chinese character PDF file
-------------------------------------------

                 Key: PDFBOX-1071
                 URL: https://issues.apache.org/jira/browse/PDFBOX-1071
             Project: PDFBox
          Issue Type: Bug
          Components: Writing
    Affects Versions: 1.6.0
         Environment: Windows XP
Oracle JDK 1.6

            Reporter: Linus Tseng
            Priority: Critical
         Attachments: fireflysung.zip

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");

--
This message is automatically generated by JIRA.
For more information on JIRA, see: http://www.atlassian.com/software/jira


Reply via email to