Hi,
dysign.ch schrieb:
Hello everybody
I recently started a java project where one of the tasks is to generate
pdf files from some stored texts. As I'm from Switzerland, many texts
contain umlauts like ä,ö or ü. When pdfbox parses my strings with e.g.
contentStream.drawString(str); the result looks qite crappy if the
string contains umlauts, all umlaut characters are replaced with squares
and between everu normal character there is an additional space (string
comes from document with 'normal' ascii coding). If I convert the source
document/string to use UTF 8, the result looks even worse.
How can I tell pdfbox to print such umlauts correctly (it doesn't matter
if I'd have to use embedded fonts or external ttfs, I'm just happy if it
works somehow).
You should use an external ttf which supports umlauts, see [1] how to do that.
Convert your text to UTF-8 before calling drawString().
HTH
Andreas Lehmkühler
[1]
http://svn.apache.org/repos/asf/pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/examples/pdmodel/HelloWorldTTF.java