You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@pdfbox.apache.org by "Axel Howind (Jira)" <ji...@apache.org> on 2023/10/17 03:12:00 UTC

[jira] [Updated] (PDFBOX-5701) Upgrading fontbox will cause an exception to be thrown

     [ https://issues.apache.org/jira/browse/PDFBOX-5701?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Axel Howind updated PDFBOX-5701:
--------------------------------
    Attachment: image.png

> 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, image.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-unsubscribe@pdfbox.apache.org
For additional commands, e-mail: dev-help@pdfbox.apache.org