You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@pdfbox.apache.org by "John Hewson (JIRA)" <ji...@apache.org> on 2015/04/25 03:17:38 UTC

[jira] [Comment Edited] (PDFBOX-2774) Can't encode Euro in field with WinAnsiEncoding

    [ https://issues.apache.org/jira/browse/PDFBOX-2774?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=14512138#comment-14512138 ] 

John Hewson edited comment on PDFBOX-2774 at 4/25/15 1:17 AM:
--------------------------------------------------------------

The fonts used in the fields specify WinAnsiEncoding, however that encoding does not contain the Euro symbol *[edit: actually it does - more research needed]*, 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.

Note that 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 issue which I mention in the previous paragraph.


was (Author: jahewson):
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.

Note that 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 issue which I mention in the previous paragraph.

> Can't encode Euro in field with WinAnsiEncoding
> -----------------------------------------------
>
>                 Key: PDFBOX-2774
>                 URL: https://issues.apache.org/jira/browse/PDFBOX-2774
>             Project: PDFBox
>          Issue Type: Bug
>          Components: AcroForm
>    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-unsubscribe@pdfbox.apache.org
For additional commands, e-mail: dev-help@pdfbox.apache.org