[ https://issues.apache.org/jira/browse/PDFBOX-5701?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17776003#comment-17776003 ]
bai yuan commented on PDFBOX-5701: ---------------------------------- [~tilman] OK, i understand, you can close this bug. > 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 > Priority: Major > 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: dev-unsubscr...@pdfbox.apache.org For additional commands, e-mail: dev-h...@pdfbox.apache.org