0

I am trying to generate a PDF using HTML with iText. The html contains some cyrillic letters. And everything works fine on my windows 7 OS.

Here is how I generate the PDF:

// Registers the fonts folder.
    FontFactory.registerDirectory(fontFolder);

    Set<String> registeredFonts = FontFactory.getRegisteredFonts();
    LOGGER.info("Registered fonts : " + registeredFonts);

    // Adds wrapper HTML and BODY tags.
    content = "<HTML><BODY style=\"font-family: " + fontFamily + "\">" + content + "</BODY></HTML>";
    content = content.replace(NEW_LINE_SEPARATOR, "<br />");

    // Create input stream from the html content
    InputStream stream = new ByteArrayInputStream(content.getBytes("UTF-8"));
    // convert to PDF
    XMLWorkerHelper worker = XMLWorkerHelper.getInstance();
    worker.parseXHtml(writer, document, stream, Charset.forName("UTF-8"));

The font folder variable contains path to arial fonts and fontFamily variable contains the String "arial".

The problem is, that when I deploy the web application on remote linux jboss server this bit of code won't display the cyrillic symbols (the latin ones and the numbers are just fine).

I guess the problem is with missing fonts but can't figure out what exactly is causing it as my configuration on the server seems fine.

4

0 回答 0