pdfbox-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Horn, Reinhard" <reinhard.h...@dataport.de>
Subject How to write UTF-8 encode PDF-Files?
Date Wed, 12 Sep 2012 16:04:06 GMT
Hi,

I want to write an pdf file with utf-8 encoding. I tried to do it with the following code
but it is not written correctly.
Your help is appreciated.

Thanks.


      PDDocument doc = new PDDocument();
      PDPage page = new PDPage();
      doc.addPage(page);
      PDPageContentStream stream = new PDPageContentStream(doc, page);
      stream.beginText();


      PDFont font = PDTrueTypeFont.loadTTF(doc, new File("arialuni.ttf"));
      font.setFontEncoding(new PdfDocEncoding());
      stream.setFont(font, 14);
      stream.moveTextPositionByAmount(80, 700);

      stream.drawString("\uc2bc");
      stream.endText();

      stream.close();
      doc.save("test.pdf");

      doc.close();










Mit freundlichen Grüßen
Reinhard Horn
Anwendungsentwickler Einwohnerwesen
_______________________________
Dataport
Altenholzer Straße 10-14, 24161 Altenholz
Internet: www.dataport.de
E-Mail: Reinhard.Horn@dataport.de
Telefon: 0431 3295-6655


Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message