[ https://issues.apache.org/jira/browse/PDFBOX-2774?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=14512138#comment-14512138 ]
John Hewson commented on PDFBOX-2774: ------------------------------------- The fonts used in the fields specify WinAnsiEncoding, however that encoding does not contain the Euro symbol, which is why there is an exception. We could do something like overwrite Encoding in the Font's dictionary but we should probably look at how Acrobat handles this case first. This is a problem specific to filling out form fields. However, the two "small tests" do not reproduce the problem, they're calling quite different methods which happen to result in the same exception because PDTrueTypeFont.loadTTF creates a font which uses WinAnsiEncoding, while PDType0Font.load supports full Unicode. There's no bugs in those examples and this behaviour is expected and not relevant to the form-filling bug which I mention in the previous paragraph. > Encoding issue in PDTrueTypeFont for Euro symbol > ------------------------------------------------ > > Key: PDFBOX-2774 > URL: https://issues.apache.org/jira/browse/PDFBOX-2774 > Project: PDFBox > Issue Type: Bug > Components: PDModel > Affects Versions: 2.0.0 > Reporter: Maruan Sahyoun > Attachments: ArialMT.ttf, PdfTest.java, test.pdf, test2.pdf > > > From the users mailing list when trying to set a field value to the Euro sign > the following exception occurs > {code} > Exception in thread "main" java.lang.IllegalArgumentException: No glyph for > U+20AC in font Arial > at > org.apache.pdfbox.pdmodel.font.PDTrueTypeFont.encode(PDTrueTypeFont.java:267) > 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.insertGeneratedAppearance(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.generateFieldAppearances(AppearanceGenerator.java:61) > at > org.apache.pdfbox.pdmodel.interactive.form.PDField.updateFieldAppearances(PDField.java:121) > at > org.apache.pdfbox.pdmodel.interactive.form.PDTextField.setValue(PDTextField.java:289) > {code} > A small test loading the extracted font {{ArialMT}} directly with > {code} > PDTrueTypeFont font2 = PDTrueTypeFont.loadTTF(document, new > File("ArialMT.ttf")); > font2.encode("€"); > {code} > gives the same error whereas using > {code} > PDType0Font font = PDType0Font.load(document, new File("ArialMT.ttf")); > font.encode("€"); > {code} > the error doesn't happen. -- This message was sent by Atlassian JIRA (v6.3.4#6332) --------------------------------------------------------------------- To unsubscribe, e-mail: dev-unsubscr...@pdfbox.apache.org For additional commands, e-mail: dev-h...@pdfbox.apache.org