我试图用PDFBox将一些孟加拉文本写成pdf,但是遇到一些问题U + 0053没有字形。我不知道字形。
File file = new File("xyz.pdf");
PDDocument document = PDDocument.load(file);
PDPage page = document.getPage(0);
PDPageContentStream contentStream = new PDPageContentStream(document, page);
contentStream.beginText();
PDFont font = PDType0Font.load(document, BengaliPdfGenerationHelloWorld.class.getResourceAsStream("/textloc/Lohit-Bengali.ttf"),true);
contentStream.setFont(font,12);
contentStream.newLineAtOffset();
contentStream.showText(text);
contentStream.endText();
System.out.println("Content added");
contentStream.close();
document.save(new File("new.pdf"));
Exception in thread "main" java.lang.IllegalArgumentException: No glyph for U+0053 (S) in font Lohit-Bengali
at org.apache.pdfbox.pdmodel.font.PDCIDFontType2.encode(PDCIDFontType2.java:366)
at org.apache.pdfbox.pdmodel.font.PDType0Font.encode(PDType0Font.java:415)
at org.apache.pdfbox.pdmodel.font.PDFont.encode(PDFont.java:342)