[jira] [Commented] (PDFBOX-3597) PDAcroForm.refreshAppearances() does not respect updated fonts

2016-11-30 Thread Matt Wise (JIRA)

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

Matt Wise commented on PDFBOX-3597:
---

Thanks Maruan, yes the form will be flattened and is intended for printing 
after filling out the fields from my backend app so I want to reduce the file 
size as much as possible.  Embedding the entirety of ArialUnicodeMs adds about 
15mb to the resulting PDF which is excessive.

> PDAcroForm.refreshAppearances() does not respect updated fonts
> --
>
> Key: PDFBOX-3597
> URL: https://issues.apache.org/jira/browse/PDFBOX-3597
> Project: PDFBox
>  Issue Type: Bug
>  Components: PDModel
>Affects Versions: 2.0.3
>Reporter: Matt Wise
>
> I have attached example files in the External issue URL link.
> I am trying to embed a subset of a font into my pdf after populating the 
> fields.  If I don't run refreshAppearances() the values will be put into the 
> fields, but will only be visible when the field is selected (likely another 
> bug).
> To work around this, I am trying to set the default appearance on the fields 
> manually to reflect the embedded font.  If I embed the whole font, it works 
> as expected, however when I try to embed a subset of the font it fails:
> Exception in thread "main" java.lang.IllegalArgumentException: No glyph for 
> U+540D in font AAWTXC+ArialUnicodeMS
>   at 
> org.apache.pdfbox.pdmodel.font.PDCIDFontType2.encode(PDCIDFontType2.java:400)
>   at 
> org.apache.pdfbox.pdmodel.font.PDType0Font.encode(PDType0Font.java:351)
>   at org.apache.pdfbox.pdmodel.font.PDFont.encode(PDFont.java:316)
>   at org.apache.pdfbox.pdmodel.font.PDFont.getStringWidth(PDFont.java:345)
>   at 
> org.apache.pdfbox.pdmodel.interactive.form.PlainTextFormatter.format(PlainTextFormatter.java:195)
>   at 
> org.apache.pdfbox.pdmodel.interactive.form.AppearanceGeneratorHelper.insertGeneratedAppearance(AppearanceGeneratorHelper.java:422)
>   at 
> org.apache.pdfbox.pdmodel.interactive.form.AppearanceGeneratorHelper.setAppearanceContent(AppearanceGeneratorHelper.java:288)
>   at 
> org.apache.pdfbox.pdmodel.interactive.form.AppearanceGeneratorHelper.setAppearanceValue(AppearanceGeneratorHelper.java:170)
>   at 
> org.apache.pdfbox.pdmodel.interactive.form.PDTextField.constructAppearances(PDTextField.java:263)
>   at 
> org.apache.pdfbox.pdmodel.interactive.form.PDAcroForm.refreshAppearances(PDAcroForm.java:318)
>   at test_pdfbox.TestPDFBox.main(TestPDFBox.java:45)
> It would appear that after I call form.setDefaultResources with the updated 
> font, refreshAppearances is still trying to use the old font as the 
> appearance, although I may be wrong.
> Expected:
> appearances are updated, subset of font is embedded.



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



[jira] [Commented] (PDFBOX-3597) PDAcroForm.refreshAppearances() does not respect updated fonts

2016-11-28 Thread Maruan Sahyoun (JIRA)

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

Maruan Sahyoun commented on PDFBOX-3597:


I haven't checked the code in detail but compared the PDFs which were 
generated. I'll look at the code later today. In the current form the DA uses 
ArialUnicodeMS for both the original template and the updated template. As the 
DA uses a name which is already existing in the fields resource entry a 
possibly update font in the AcroForm DR entry will not be read. 

Again I will check the code to see if there is an issue there.

Now to the question of subsetting a font for an interactive field. This will 
only make sense if you are sure that there will be no subsequent change to the 
fields value as there might be glyphs missing for a future new value entered by 
a user or another automated process.. 

> PDAcroForm.refreshAppearances() does not respect updated fonts
> --
>
> Key: PDFBOX-3597
> URL: https://issues.apache.org/jira/browse/PDFBOX-3597
> Project: PDFBox
>  Issue Type: Bug
>  Components: PDModel
>Affects Versions: 2.0.3
>Reporter: Matt Wise
>
> I have attached example files in the External issue URL link.
> I am trying to embed a subset of a font into my pdf after populating the 
> fields.  If I don't run refreshAppearances() the values will be put into the 
> fields, but will only be visible when the field is selected (likely another 
> bug).
> To work around this, I am trying to set the default appearance on the fields 
> manually to reflect the embedded font.  If I embed the whole font, it works 
> as expected, however when I try to embed a subset of the font it fails:
> Exception in thread "main" java.lang.IllegalArgumentException: No glyph for 
> U+540D in font AAWTXC+ArialUnicodeMS
>   at 
> org.apache.pdfbox.pdmodel.font.PDCIDFontType2.encode(PDCIDFontType2.java:400)
>   at 
> org.apache.pdfbox.pdmodel.font.PDType0Font.encode(PDType0Font.java:351)
>   at org.apache.pdfbox.pdmodel.font.PDFont.encode(PDFont.java:316)
>   at org.apache.pdfbox.pdmodel.font.PDFont.getStringWidth(PDFont.java:345)
>   at 
> org.apache.pdfbox.pdmodel.interactive.form.PlainTextFormatter.format(PlainTextFormatter.java:195)
>   at 
> org.apache.pdfbox.pdmodel.interactive.form.AppearanceGeneratorHelper.insertGeneratedAppearance(AppearanceGeneratorHelper.java:422)
>   at 
> org.apache.pdfbox.pdmodel.interactive.form.AppearanceGeneratorHelper.setAppearanceContent(AppearanceGeneratorHelper.java:288)
>   at 
> org.apache.pdfbox.pdmodel.interactive.form.AppearanceGeneratorHelper.setAppearanceValue(AppearanceGeneratorHelper.java:170)
>   at 
> org.apache.pdfbox.pdmodel.interactive.form.PDTextField.constructAppearances(PDTextField.java:263)
>   at 
> org.apache.pdfbox.pdmodel.interactive.form.PDAcroForm.refreshAppearances(PDAcroForm.java:318)
>   at test_pdfbox.TestPDFBox.main(TestPDFBox.java:45)
> It would appear that after I call form.setDefaultResources with the updated 
> font, refreshAppearances is still trying to use the old font as the 
> appearance, although I may be wrong.
> Expected:
> appearances are updated, subset of font is embedded.



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



[jira] [Commented] (PDFBOX-3597) PDAcroForm.refreshAppearances() does not respect updated fonts

2016-11-28 Thread Matt Wise (JIRA)

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

Matt Wise commented on PDFBOX-3597:
---

Thank you for your quick response Maruan.  Please correct me as I seem to 
misunderstand.  As I understood, since I am subsetting the font it is being 
added as a separate resource, when running the provided script, the initial 
font is indeed ArialUnicodeMS, however after calling font.subset() the name 
returned is F3.  Also, since I then set the DA to reflect the updated name, I 
am still confused why it is trying to use the original name as the appearance.

Also, since my use case is to load the values from an xfdf file, gather the 
added characters and embed a subset of the font that matches the field values, 
is there a better way to generate a subset of a font without adding it to the 
DR entry of the AcroForm?  Or will I be forced to manually parse the input and 
set the values by hand after adding the subset to the AcroForm's DR entry?

> PDAcroForm.refreshAppearances() does not respect updated fonts
> --
>
> Key: PDFBOX-3597
> URL: https://issues.apache.org/jira/browse/PDFBOX-3597
> Project: PDFBox
>  Issue Type: Bug
>  Components: PDModel
>Affects Versions: 2.0.3
>Reporter: Matt Wise
>
> I have attached example files in the External issue URL link.
> I am trying to embed a subset of a font into my pdf after populating the 
> fields.  If I don't run refreshAppearances() the values will be put into the 
> fields, but will only be visible when the field is selected (likely another 
> bug).
> To work around this, I am trying to set the default appearance on the fields 
> manually to reflect the embedded font.  If I embed the whole font, it works 
> as expected, however when I try to embed a subset of the font it fails:
> Exception in thread "main" java.lang.IllegalArgumentException: No glyph for 
> U+540D in font AAWTXC+ArialUnicodeMS
>   at 
> org.apache.pdfbox.pdmodel.font.PDCIDFontType2.encode(PDCIDFontType2.java:400)
>   at 
> org.apache.pdfbox.pdmodel.font.PDType0Font.encode(PDType0Font.java:351)
>   at org.apache.pdfbox.pdmodel.font.PDFont.encode(PDFont.java:316)
>   at org.apache.pdfbox.pdmodel.font.PDFont.getStringWidth(PDFont.java:345)
>   at 
> org.apache.pdfbox.pdmodel.interactive.form.PlainTextFormatter.format(PlainTextFormatter.java:195)
>   at 
> org.apache.pdfbox.pdmodel.interactive.form.AppearanceGeneratorHelper.insertGeneratedAppearance(AppearanceGeneratorHelper.java:422)
>   at 
> org.apache.pdfbox.pdmodel.interactive.form.AppearanceGeneratorHelper.setAppearanceContent(AppearanceGeneratorHelper.java:288)
>   at 
> org.apache.pdfbox.pdmodel.interactive.form.AppearanceGeneratorHelper.setAppearanceValue(AppearanceGeneratorHelper.java:170)
>   at 
> org.apache.pdfbox.pdmodel.interactive.form.PDTextField.constructAppearances(PDTextField.java:263)
>   at 
> org.apache.pdfbox.pdmodel.interactive.form.PDAcroForm.refreshAppearances(PDAcroForm.java:318)
>   at test_pdfbox.TestPDFBox.main(TestPDFBox.java:45)
> It would appear that after I call form.setDefaultResources with the updated 
> font, refreshAppearances is still trying to use the old font as the 
> appearance, although I may be wrong.
> Expected:
> appearances are updated, subset of font is embedded.



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



[jira] [Commented] (PDFBOX-3597) PDAcroForm.refreshAppearances() does not respect updated fonts

2016-11-27 Thread Maruan Sahyoun (JIRA)

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

Maruan Sahyoun commented on PDFBOX-3597:


What happens is this. When you set the value for the first time the DR entry of 
the AcroForm is read and the font resource is put into the appearance 
dictionary. Now, after you have set the value you are changing the DR font 
resource, the DA string and you are calling {{refreshAppearances()}}. 

As the name of the already existing resource is the same as the name of the 
newly set resource in the DA string  {{ArialUnicodeMS}} that rescue is already 
existing in the fields resources and as a result not read again from the 
AcroForm DR entry, which is inline with the specification.

So either make sure that the names are not the same or replace the AcroForm DR 
entry before setting the initial field value.

> PDAcroForm.refreshAppearances() does not respect updated fonts
> --
>
> Key: PDFBOX-3597
> URL: https://issues.apache.org/jira/browse/PDFBOX-3597
> Project: PDFBox
>  Issue Type: Bug
>  Components: PDModel
>Affects Versions: 2.0.3
>Reporter: Matt Wise
>
> I have attached example files in the External issue URL link.
> I am trying to embed a subset of a font into my pdf after populating the 
> fields.  If I don't run refreshAppearances() the values will be put into the 
> fields, but will only be visible when the field is selected (likely another 
> bug).
> To work around this, I am trying to set the default appearance on the fields 
> manually to reflect the embedded font.  If I embed the whole font, it works 
> as expected, however when I try to embed a subset of the font it fails:
> Exception in thread "main" java.lang.IllegalArgumentException: No glyph for 
> U+540D in font AAWTXC+ArialUnicodeMS
>   at 
> org.apache.pdfbox.pdmodel.font.PDCIDFontType2.encode(PDCIDFontType2.java:400)
>   at 
> org.apache.pdfbox.pdmodel.font.PDType0Font.encode(PDType0Font.java:351)
>   at org.apache.pdfbox.pdmodel.font.PDFont.encode(PDFont.java:316)
>   at org.apache.pdfbox.pdmodel.font.PDFont.getStringWidth(PDFont.java:345)
>   at 
> org.apache.pdfbox.pdmodel.interactive.form.PlainTextFormatter.format(PlainTextFormatter.java:195)
>   at 
> org.apache.pdfbox.pdmodel.interactive.form.AppearanceGeneratorHelper.insertGeneratedAppearance(AppearanceGeneratorHelper.java:422)
>   at 
> org.apache.pdfbox.pdmodel.interactive.form.AppearanceGeneratorHelper.setAppearanceContent(AppearanceGeneratorHelper.java:288)
>   at 
> org.apache.pdfbox.pdmodel.interactive.form.AppearanceGeneratorHelper.setAppearanceValue(AppearanceGeneratorHelper.java:170)
>   at 
> org.apache.pdfbox.pdmodel.interactive.form.PDTextField.constructAppearances(PDTextField.java:263)
>   at 
> org.apache.pdfbox.pdmodel.interactive.form.PDAcroForm.refreshAppearances(PDAcroForm.java:318)
>   at test_pdfbox.TestPDFBox.main(TestPDFBox.java:45)
> It would appear that after I call form.setDefaultResources with the updated 
> font, refreshAppearances is still trying to use the old font as the 
> appearance, although I may be wrong.
> Expected:
> appearances are updated, subset of font is embedded.



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