[
https://issues.apache.org/jira/browse/PDFBOX-6172?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=18062395#comment-18062395
]
ASF subversion and git services commented on PDFBOX-6172:
---------------------------------------------------------
Commit 1932121 from Tilman Hausherr in branch 'pdfbox/branches/2.0'
[ https://svn.apache.org/r1932121 ]
PDFBOX-6172: avoid ClassCastException with SourceSansProBold.otf from FOP 2432
> PDF displays garbled characters in Adobe Reader but renders correctly in web
> browsers
> -------------------------------------------------------------------------------------
>
> Key: PDFBOX-6172
> URL: https://issues.apache.org/jira/browse/PDFBOX-6172
> Project: PDFBox
> Issue Type: Bug
> Affects Versions: 2.0.35, 3.0.6 PDFBox
> Reporter: bai yuan
> Assignee: Tilman Hausherr
> Priority: Major
> Labels: OTF
> Fix For: 2.0.36, 3.0.7 PDFBox, 4.0.0
>
> Attachments: NotoSansSC-Regular.otf,
> image-2026-03-02-15-59-36-196.png, image-2026-03-02-16-00-28-488.png,
> output.pdf, screenshot-1.png
>
>
> When exporting a PDF document, some characters appear as garbled text or
> square boxes when the file is opened in Adobe Acrobat Reader. However, the
> same PDF renders correctly when opened in web browsers such as Chrome or Edge.
> {code:java}
> try (PDDocument document = new PDDocument()) {
> PDPage page = new PDPage();
> document.addPage(page);
> OpenTypeFont otf = new OTFParser().parse("NotoSansSC-Regular.otf");
> PDFont font = PDType0Font.load(document, otf, false);
> PDPageContentStream contentStream = new PDPageContentStream(document,
> page);
> contentStream.beginText();
> contentStream.setFont(font, 12);
> contentStream.newLineAtOffset(100, 700);
> contentStream.showText("手机号码");
> contentStream.endText();
> contentStream.close();
> document.save("output.pdf");
> } catch (IOException e) {
> e.printStackTrace();
> } {code}
> !image-2026-03-02-16-00-28-488.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]