pdfbox-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "□?Tango□" <org.java.ta...@gmail.com>
Subject Questions about the Chinese garbled
Date Tue, 15 Jul 2014 14:00:27 GMT
hi,PDFBox Support‍ :


          Your product is great, I loaded the local ttf file to "contentStream" write Chinese
characters, pdf files garbled, I ask how to solve?


---------------------
‍ 
    @Test
    public void testLocalFont() throws IOException, COSVisitorException {
        PDDocument document = null;
        PDPageContentStream contentStream = null;
        try {
            document = new PDDocument();
            PDPage page = new PDPage();
            document.addPage(page);
            //
            PDFont font = PDTrueTypeFont.loadTTF(document, "方正大标宋简体.ttf");
            //PDFont font = PDType1Font.HELVETICA_BOLD;
            contentStream = new PDPageContentStream(document, page);
            contentStream.beginText();
            contentStream.setFont(font, 12);
            contentStream.moveTextPositionByAmount(100, 700);
            contentStream.drawString("方正大标宋简体");
            contentStream.endText();
            contentStream.close();
            document.save("local-font-test.pdf");
        } finally {
            document.close();
        }
    }‍
‍
Mime
  • Unnamed multipart/alternative (inline, 8-Bit, 0 bytes)
View raw message