bai yuan created PDFBOX-5701:
--------------------------------

             Summary: Upgrading fontbox will cause an exception to be thrown
                 Key: PDFBOX-5701
                 URL: https://issues.apache.org/jira/browse/PDFBOX-5701
             Project: PDFBox
          Issue Type: Bug
    Affects Versions: 2.0.29
            Reporter: bai yuan
         Attachments: image-2023-10-17-10-58-46-050.png, msyh.ttc

Upgrading fontbox from 2.0.19 to 2.0.29, The following code will throw the 
exception in 2.0.29,but it is correct in 2.0.19.
{code:java}
        PDDocument doc = new PDDocument();
        PDPage page = new PDPage();
        doc.addPage(page);
        PDPageContentStream stream = new PDPageContentStream(doc, page);
        TrueTypeCollection trueTypeCollection = new TrueTypeCollection(new 
File("msyh.ttc"));
        TrueTypeFont ttFont = 
trueTypeCollection.getFontByName("MicrosoftYaHei");
        PDFont font = PDType0Font.load(doc, ttFont, false);
        stream.setFont(font, 14);
        stream.beginText();
        stream.newLineAtOffset(100, 700);
        stream.setNonStrokingColor(Color.BLACK);
        String text = "Lazy dog";
        stream.showText(text);
        stream.endText();
        stream.stroke();
        stream.close();        
        
        doc.save("test.pdf");
        doc.close(); {code}
 

!image-2023-10-17-10-58-46-050.png!



--
This message was sent by Atlassian Jira
(v8.20.10#820010)

---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to