pdfbox-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Maruan Sahyoun <sahy...@fileaffairs.de>
Subject Re: Supporting Unicode characters to fill in an existing PDF with Acroforms
Date Tue, 18 Aug 2015 08:11:25 GMT
Hi,

> Am 18.08.2015 um 00:49 schrieb Rakshit Ashtekar <arakshit@tibco.com>:
> 
> Hello,
> 
> I am using PDFBox 2.0 dev snapshot to support Unicode characters. I have
> few questions:
> 
> I want to write an existing PDF file which have few PDTextField with
> Unicode characters.
> 
> I am using PDType0Font to load an external .ttf file
> (Arial-Unicode-Regular.ttf) and setting the new font object to the
> PDResources. Code snippet below:
> 
> PDType0Font font = PDType0Font.load(pdfDocument, new
> File("Arial-Unicode-Regular.ttf"));
> // Add and set the resources and default appearance at the form level
> PDResources res = new PDResources();
> COSName fontName = res.add(font);
> acroForm.setDefaultResources(res);
> String da = "/" + fontName.getName() + " 12 Tf 0 g";
> acroForm.setDefaultAppearance(da);
> 
> But I am getting below exception
> java.io.IOException: Could not find font: /CourierNewPSMT
> at
> org.apache.pdfbox.pdmodel.interactive.form.PDAppearanceString.getFont(PDAppearanceString.java:126)

the reason is very likely that the field you are trying to fill has a default appearance where
the font is set to CourierNewPSMT. You need to also set the default appearance for the field
to use the loaded font.

If you could upload your file to a public location I can take a closer look.

> 
> I saw a similar ticket - https://issues.apache.org/jira/browse/PDFBOX-2848
> 
> *My questions:*
> 1. Does PDFBox 2.0 supports Unicode characters values to be set on an
> existing PDF file which has PDTextField using setValue(String value) of the
> PDTextField? I saw an example where Unicode characters are supported but
> that PDF is created from scratch and it did not have AcroForms.

Unicode for field values is supported as of PDFBox 2.0

> 
> 2. Will the .ttf file currently in sources of /
> pdfbox/src/main/resources/org/apache/pdfbox/resources/ttf/ be packaged with
> the final PDFBox jar? or the developers have to load it externally?

Yes,

BR
Maruan

> 
> Appreciate your help.
> 
> Thanks,
> Rakshit


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@pdfbox.apache.org
For additional commands, e-mail: users-help@pdfbox.apache.org


Mime
View raw message