Hi, this seems to be a bug in PDFBOX 2.0.0 - I've created https://issues.apache.org/jira/browse/PDFBOX-2771 <https://issues.apache.org/jira/browse/PDFBOX-2771> for that.
BR Maruan > Am 19.04.2015 um 22:01 schrieb Frank Buss <[email protected]>: > > I would expect that Arial works, most other programs can use it without > problems, for example I have no problem generating PDFs with Apache FOP with > Arial. But I tried other fonts, and the same problem. Looks like there are > more problems with encodings in pdfbox, maybe this problem is related? > > http://w3facility.org/question/pdfbox-encode-symbol-currency-euro/ > > I can't use the hack described in the article, because I want to > programmatically type some text in a field, unless I calculate the Euro sign > position and use the appendRawCommands trick to draw it, but this sounds very > ugly :-) > > >> -----Original Message----- >> From: Gilad Denneboom [mailto:[email protected]] >> Sent: Sunday, April 19, 2015 10:17 AM >> To: [email protected] >> Subject: Re: Euro not set in text field >> >> Maybe try using a different font? >> >> On Sun, Apr 19, 2015 at 2:51 AM, Frank Buss <[email protected]> wrote: >> >>> When I do this, it prints this exception: >>> >>> Exception in thread "main" java.lang.IllegalArgumentException: U+8364 is >>> not available in this font's Encoding >>> at >>> >> org.apache.pdfbox.pdmodel.font.PDTrueTypeFont.encode(PDTrueTypeFont >> .java:260) >>> at org.apache.pdfbox.pdmodel.font.PDFont.encode(PDFont.java:268) >>> at >>> org.apache.pdfbox.pdmodel.font.PDFont.getStringWidth(PDFont.java:297) >>> at >>> >> org.apache.pdfbox.pdmodel.interactive.form.AppearanceGeneratorHelper. >> calculateHorizontalOffset(AppearanceGeneratorHelper.java:564) >>> at >>> >> org.apache.pdfbox.pdmodel.interactive.form.AppearanceGeneratorHelper.i >> nsertGeneratedAppearance(AppearanceGeneratorHelper.java:305) >>> at >>> >> org.apache.pdfbox.pdmodel.interactive.form.AppearanceGeneratorHelper. >> createAppearanceContent(AppearanceGeneratorHelper.java:228) >>> at >>> >> org.apache.pdfbox.pdmodel.interactive.form.AppearanceGeneratorHelper. >> setAppearanceValue(AppearanceGeneratorHelper.java:203) >>> at >>> >> org.apache.pdfbox.pdmodel.interactive.form.AppearanceGenerator.genera >> teFieldAppearances(AppearanceGenerator.java:61) >>> at >>> >> org.apache.pdfbox.pdmodel.interactive.form.PDField.updateFieldAppearan >> ces(PDField.java:121) >>> at >>> >> org.apache.pdfbox.pdmodel.interactive.form.PDTextField.setValue(PDTextF >> ield.java:286) >>> at PdfTest.main(PdfTest.java:15) >>> >>> which looks wrong, because as you can see in the the first text field in >>> the sample PDF, it is possible to use the Euro sign, it is part of the >>> Arial font. And I can open Word, set Arial as the font, then type Alt-8364 >>> and the Euro sign appears, so looks like it is part of the font's Encoding. >>> >>> This bug is a show stopper for my application, because the Euro sign is >>> required for a business application. >>> >>> >>>> -----Original Message----- >>>> From: Gilad Denneboom [mailto:[email protected]] >>>> Sent: Saturday, April 18, 2015 5:39 PM >>>> To: [email protected] >>>> Subject: Re: Euro not set in text field >>>> >>>> Maybe try specifying the unicode value directly, like so: >>>> test2.setValue("\u8364"); >>>> >>>> On Sat, Apr 18, 2015 at 12:57 PM, Frank Buss <[email protected]> wrote: >>>> >>>>> I have a PDF document with a text field and I want to enter an euro >>> symbol >>>>> (€) with a program, but I'll get a strange character (¬). This is the >>> code: >>>>> >>>>> import java.io.*; >>>>> import org.apache.pdfbox.pdmodel.*; >>>>> import org.apache.pdfbox.pdmodel.interactive.form.*; >>>>> >>>>> public class PdfTest { >>>>> >>>>> public static void main(final String args[]) throws Exception { >>>>> // load test document >>>>> PDDocument pdfDocument = PDDocument.load(new >>>>> File("test.pdf")); >>>>> PDDocumentCatalog docCatalog = >>>>> pdfDocument.getDocumentCatalog(); >>>>> PDAcroForm acroForm = docCatalog.getAcroForm(); >>>>> >>>>> // get test2 field and set Euro >>>>> PDFieldTreeNode test2 = acroForm.getField("test2"); >>>>> test2.setValue("€"); >>>>> >>>>> // save as new document >>>>> pdfDocument.save("test2.pdf"); >>>>> pdfDocument.close(); >>>>> } >>>>> } >>>>> >>>>> See http://www.frank-buss.de/tmp/pdfTest.zip for the test.pdf and >> the >>>>> generated test2.pdf. I'm using the latest snapshot >>>>> (pdfbox-app-2.0.0-20150418.010411-1224.jar), but the same problem >> was >>>> in a >>>>> snapshot from January, too. How can I solve the problem? I can try to >>> fix >>>>> it in the library, too, if someone can give me a hint where to search. >>>>> >>>>> >>>>> --------------------------------------------------------------------- >>>>> To unsubscribe, e-mail: [email protected] >>>>> For additional commands, e-mail: [email protected] >>>>> >>>>> >>> >>> >>> --------------------------------------------------------------------- >>> To unsubscribe, e-mail: [email protected] >>> For additional commands, e-mail: [email protected] >>> >>> > > > --------------------------------------------------------------------- > To unsubscribe, e-mail: [email protected] > For additional commands, e-mail: [email protected] >

