Note that there are some explanatory texts on larger screens.

plurals
  1. POiText doesn't like my special characters
    primarykey
    data
    text
    <p>I'm trying to generate a pdf file using iText.<br> The file gets produced just fine, but I can seem to use special characters like german ä, ö, ...<br> The sentence I want to be written is (for example) </p> <blockquote> <p>■ ...ä...ö...</p> </blockquote> <p>but the output is </p> <blockquote> <p>â– ...ä...ö...</p> </blockquote> <p>(I had to kind of blur the sentences, but I guess you see what I'm talking about...)</p> <p>Somehow this black block-thing and all "Umlaute" can't be generated ...<br> The font used is the following:</p> <pre><code>private static Font smallBold = new Font(Font.FontFamily.TIMES_ROMAN, 12, Font.BOLD); </code></pre> <p>So there should be no problem about the font not having these characters...<br> I'm using IntelliJ Idea to develop, the encoding of the .java file is set to UTF-8, so there should be no problem too... </p> <p>I'm kind of lost here; does anyone know what i may do to get it working?</p> <p>Thanks in advance and greetz gilaras</p> <p><strong>---------------UPDATE---------------</strong></p> <p>So here's (part of) the code: </p> <pre><code>@Controller public class Generator { ... Font font = new Font(Font.FontFamily.TIMES_ROMAN, 9f, Font.BOLD); ... Paragraph intro = new Paragraph("Ich interessiere mich für ...!", font_12_bold); Paragraph wantContact = new Paragraph("■ Ich hätte gerne ... ", font); ... Phrase south = new Phrase("■ Süden □ Ost-West ..."); ... @RequestMapping(value = "/generatePdf", method = RequestMethod.POST) @ResponseBody public String generatePdf(HttpServletRequest request) throws IOException, DocumentException, com.lowagie.text.DocumentException { Document document = new Document(); PdfWriter.getInstance(document, new FileOutputStream(FILE)); addMetaData(document); document.open(); addContent(document, request); document.add(new Paragraph("äöü")); document.close(); return ""; } private void addContent(Document document, HttpServletRequest request) throws DocumentException { Paragraph preface = new Paragraph(); preface.setAlignment(Element.ALIGN_JUSTIFIED); addEmptyLine(preface, 1); preface.add(new Paragraph("Rückantwort", catFont)); addEmptyLine(preface, 2); preface.add(intro); addEmptyLine(preface, 1); if (request.getParameter("dec1").equals("wantContact")) { preface.add(wantContact); } else { ... } document.add(preface); } private static void addEmptyLine(Paragraph paragraph, int number) { for (int i = 0; i &lt; number; i++) { paragraph.add(new Paragraph(" ")); } } private static void addMetaData(Document document) { document.addTitle("..."); document.addSubject("..."); document.addKeywords("..."); document.addAuthor("..."); document.addCreator("..."); } } </code></pre> <p>I had to take some things out, but I kept some Umlaut-character and other special characters, so that you can see, where the problem occurs ... :-)</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload