I am using itext-7.0.1 on top of Linux Mint 17.1
I am trying to add Non-ASCII text (Hebrew) to a PdfDocument, but all the Hebrew letters are missing from the text:
private void writePdf(Entity entity, OutputStream outputStream) throws IOException {
PdfWriter pdfWriter = new PdfWriter(outputStream);
PdfDocument pdfDocument = new PdfDocument(pdfWriter);
Document document = new Document(pdfDocument);
PdfFont font = PdfFontFactory.createRegisteredFont("open sans", "UTF-8"); //A correctly registered font
document.add(new Paragraph("Some English Letters").setFont(font)); //This will appear well inthe PDF
document.add(new Paragraph(entity.getName()).setFont(font)); //This will appear as a blank line
System.out.println(entity.getName()); //Written correctly to stdout
document.add(new Paragraph(entity.getId()).setFont(font)); //This will appear correctly in the PDF
document.close();
System.exit(-1);
}
Summing the code above: All the ASCII text (English and digits) is written correctly to the PDF, but the Hebrew letters (entity.getName()
) is written as a blank line.
The above font is correctly typed in a word processor, however in order to verify this, I have tried other fonts that caused the same result.
There a lot of socumentation in itext-5. Should I switch to itext-5 instead of 7?