0
我正在使用Times New Roman字體來獲取數學符號。我得到了大部分,但無法通過使用unicode符號\u00F7
或通過直接打印÷
符號。它打印一些其他的符號。 這裏是我的代碼:iText:無法打印÷符號
PdfWriter writer = PdfWriter.getInstance(document, new FileOutputStream("/home/adeel/experiment.pdf"));
TableHeader event = new TableHeader("Header");
writer.setPageEvent(event);
document.open();
Resource resource = new ClassPathResource("/TimesRoman.ttf");
String FONT = null;
try {
FONT = resource.getFile().getPath();
} catch (IOException e1) {
// TODO Auto-generated catch block
e1.printStackTrace();
}
BaseFont bfTimes = null;
try {
bfTimes = BaseFont.createFont(FONT, BaseFont.IDENTITY_H, BaseFont.NOT_EMBEDDED);
} catch (IOException e) {
e.printStackTrace();
}
Font fontnormal = new Font(bfTimes, 12);
String text = "Divide by example : 45 \u00F7; 3";
// String text = "Divide by example : 45 ÷ 3";
Paragraph para = new Paragraph(text, fontnormal);
document.add(para);
document.close();
writer.close();
*它的打印別的東西。* - 你沒有嵌入你的字體。可能替換字體您的查看器使用,而不是有一個不同的符號(別的東西),你的字體資源有劃分的標誌。 – mkl
字體TimesRoman.ttf是否包含字符? –