Special characters in iText

I need help using these characters ⎕, ∨, 0, Ʌ etc. But when I create a PDF file with iText, these characters are not displayed.

What can I do to make these characters appear?

+4
source share
4 answers

You must use a font and encoding containing these characters. It is best to use IDENTITY_H for your encoding, as this gives you access to every character in a given font ... but you still have to use the correct font.

There are several examples of font manipulation in fonts in the iText in Action chapter on fonts: http://www.itextpdf.com/book/chapter.php?id=11

Examples down on the right side. Buying a book is likely to help too.

+8
source

I had the same problem and realized that using IDENTITY_H for encoding works fine. For instance:

java.awt.Font f =...; Font font = FontFactory.getFont(f.getName(),BaseFont.IDENTITY_H) 

I do not understand why this does not work with BaseFont.WINANSI. Winansi is the standard Windows Cp1252 character set used by my JVM. So, if char displays correctly in Java, why doesn't this apply to PDF?

+2
source

You can avoid them according to the unicode escape sequence defined in the Java language specification. See http://java.sun.com/docs/books/jls/first_edition/html/3.doc.html

If you use IntelliJ IDEA for your code, you can download the StringManipulation plugin that runs your screens. In the IDEA settings, you can also select the "Transparent native-to-ascii conversion" checkbox in the "File Encodings" section, and this should help do the trick.

+1
source

square in pdf file iText:

 BaseFont bf = BaseFont.createFont("c:/windows/fonts/arialbd.ttf", BaseFont.IDENTITY_H, BaseFont.EMBEDDED); question.add(new Phrase("\u25A1", new Font(bf, 26))); 

You can see the pdf example file here

0
source

All Articles