In jasper-reports section there is this jasper-report-character-encoding-in-pdf question.
The problem can not be solved in jasper report since it seems to be an itext problem (using iText v. 5.5.4)
Example code:
public class FontTest {
/** The resulting PDF file. */
public static final String RESULT = "pdf/fontTest.pdf";
/** the text to render. */
public static final String TEST = "u1005u101Bu1004u103Au1038u1021u1004u103Au1038u1019u103Bu102Cu1038u1011u100Au103Au101Eu103Du1004u103Au1038u1001u103Cu1004u103Au1038";
public void createPdf(String filename) throws IOException, DocumentException {
Document document = new Document();
PdfWriter writer = PdfWriter.getInstance(document, new FileOutputStream(filename));
document.open();
BaseFont bf = BaseFont.createFont(
"lib/mm3.ttf", BaseFont.IDENTITY_H, BaseFont.EMBEDDED);
Font font = new Font(bf, 20);
ColumnText column = new ColumnText(writer.getDirectContent());
column.setSimpleColumn(36, 730, 569, 36);
column.addElement(new Paragraph(TEST, font));
column.go();
document.close();
}
public static void main(String[] args) throws IOException, DocumentException {
new FontTest().createPdf(RESULT);
}
}
The font can be downloaded at mm3.ttf
Will render incorrectly as:
it should render as (in browser using same ttf
)
Just out of curiosity what is happening? (seems like certain char, with dotted circles should move backwards but this is not happening).
Is this a problem with .tff
or that iText does not support these kind of fonts?
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…