Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>If you are using iText, it has quite good support.</p> <p>In iText in Action (chapter 2.2.2) you can read more.</p> <p>You have to download some unicode Fonts like <strong>arialuni.ttf</strong> and do it like this :</p> <pre><code> public static File fontFile = new File("fonts/arialuni.ttf"); public static void createITextDocument(File from, File to) throws DocumentException, IOException { Document document = new Document(); PdfWriter writer = PdfWriter.getInstance(document, new FileOutputStream(to)); document.open(); writer.getAcroForm().setNeedAppearances(true); BaseFont unicode = BaseFont.createFont(fontFile.getAbsolutePath(), BaseFont.IDENTITY_H, BaseFont.EMBEDDED); FontSelector fs = new FontSelector(); fs.addFont(new Font(unicode)); addContent(document, getParagraphs(from), fs); document.close(); } private static void addContent(Document document, List&lt;String&gt; paragraphs, FontSelector fs) throws DocumentException { for (int i = 0; i &lt; paragraphs.size(); i++) { Phrase phrase = fs.process(paragraphs.get(i)); document.add(new Paragraph(phrase)); } } </code></pre> <p>arialuni.ttf fonts work for me, so far I checked it support for</p> <pre><code>BG, ES, CS, DA, DE, ET, EL, EN, FR, IT, LV, LT, HU, MT, NL, PL, PT, RO, SK, SL, FI, SV </code></pre> <p>and only PDF in Romanian language wasn't created properly...</p> <p>With <strong>PDFBox</strong> it's almost the same:</p> <pre><code>private void createPdfBoxDoc() throws IOException, FileNotFoundException, COSVisitorException { PDDocument document = new PDDocument(); PDPage page = new PDPage(); document.addPage(page); PDPageContentStream contentStream = new PDPageContentStream(document, page); PDFont font = PDTrueTypeFont.loadTTF(document, "fonts/arialuni.ttf"); contentStream.setFont(font, 12); contentStream.beginText(); contentStream.moveTextPositionByAmount(100, 400); contentStream.drawString("š"); contentStream.endText(); contentStream.close(); document.save("test.pdf"); document.close(); } </code></pre> <p>However as Gagravarr says, it doesn't work because of this issue <a href="https://issues.apache.org/jira/browse/PDFBOX-903" rel="noreferrer">PDFBOX-903</a> . Even with 1.6.0-SNAPSHOT version. Maybe trunk will work. I suggest you to use iText. It works there perfectly.</p>
    singulars
    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.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      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