bai yuan created PDFBOX-6172:
--------------------------------
Summary: 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
Reporter: bai yuan
Attachments: NotoSansSC-Regular.otf, image-2026-03-02-15-59-36-196.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}
--
This message was sent by Atlassian Jira
(v8.20.10#820010)
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]