When converting Japanese text containing surrogate pairs to PDF, it is displayed as blank spaces.
Is there a way to display it correctly?
Below is a sample code.
* If the text contains surrogate pair characters, an error may occur when posting to the forum, so the corresponding characters are written in Unicode.
★: U+20BB7
- Code: Select all
PdfDocument doc = new PdfDocument();
PdfPageBase page = doc.getPages().add();
PdfTrueTypeFont font = new PdfTrueTypeFont(new Font("Yu Mincho", Font.BOLD, 18));
page.getCanvas().drawString("★田 髙茂", font, PdfBrushes.getBlack(), 0, 0);
doc.saveToFile("output.pdf");
doc.close();