pdfbox-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Rakshit Ashtekar <araks...@tibco.com>
Subject Re: Supporting Unicode characters to fill in an existing PDF with Acroforms
Date Wed, 19 Aug 2015 01:24:11 GMT
Thanks a lot Mauran.

After I set the default appearance on the text field on which I need to set
the Unicode, it worked! I also had to set the setNeedAppearances to true()
to make it work.

> 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,


​A
 clarification question, when you said
​ yes for the above question, did you mean that the .TTF file will be
packaged along with the final PDFBox jar file?

Also, is there a way through which multiple .ttf files can be loaded and
used since a single .ttf file will not support all Unicode
characters/multiple languages that we need to support?

Thanks in advance,
Rakshit

On Tue, Aug 18, 2015 at 1:11 AM, Maruan Sahyoun <sahyoun@fileaffairs.de>
wrote:

> 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
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message