[poppler] Patches for form choice fields

Fabio D'Urso fabiodurso at hotmail.it
Sun Oct 14 07:26:02 PDT 2012


On Sunday, October 14, 2012 11:17:19 AM Carlos Garcia Campos wrote:
> Excerpts from Fabio D'Urso's message of dom oct 14 03:21:18 +0200 2012:
Hi Carlos,

> > 0002
> > [...]
> > This patch adds support to write the /I field, which is the list of the
> > indices of the selected items. According to PDF specs, it is mandatory
> > only under some circumstances, but tests showed that acroread always
> > require it.
> 
> Even for non multiselect form choice fields? The spec says "This entry
> should not be used for choice fields that do not allow multiple
> selection", so I think we should not write the I entry when
> isMultiSelect is false.

I had tested it, but acroread then failed to recognize the currently selected 
item: it correctly shows the value (eg "Green") but doesn't highlight it in 
the dropdown box. In other words, I guess that acroread thinks that "Green" is 
a value typed by the user.
I'm attaching test1.diff for you to test yourself.

At first I tought that it was that same encoding issue we have (ie we write 
UTF16 but acroread expects PdfDocEncoding), so I had also tested test2.diff, 
which didn't work either.

Now, I've just made a new test (test3.diff), that writes the export value 
instead of the option name. This is the same incorrect behavior (*) as foxit 
but, suprisingly, it works.
* = See the last paragraph in 12.7.4.4 "Choice fields"

To sum up, yesterday it seemed to me that acroread always expects /I, even 
when the specs say it shouldn't. Actually acroread doesn't, but it incorrectly 
expects /V to contain the "export value" instead of the "option name", and 
that's why my tests showed that /V was ignored.
If /I is present, acroread gives it precedence over /V [test4.diff] (once 
again, against the specs, see last line in table 231).
Quite confusing... :D

So we have two working options:
 - Always write /I, not matter if multiselect is true or false (current
   approach in my 0002 patch)
 - Only write /I if multiselect is true, but write export values instead of
   option names in /V, which is also against the specs [alternative0002.patch]

> 
> [...]

> > 0004
> 
> I think we should fix this anyway for documents containing single
> selection choice fields, or previously saved by poppler.

Sure we can, especially if we decide not to write /I if !multiselect.
On the other hand, I'd not consider old poppler-saved documents a priority 
because those documents never worked properly: neither acroread nor poppler 
itself could read them back correctly.

> > I could have changed this piece of code to make it aware of different
> > encodings but it seemed to me that reading /I is a more robust option for
> > two
> > 
> > reasons:
> >  - it better deals with duplicate items (ie items with the same value)
> >  - foxit reader stores the wrong value in /V: it writes what we call
> >  
> >    "exportVal" instead of what we expect ("optionName"). The /I field is
> >    always correct instead.
> 
> I guess we shouldn't decide our code based on foxit bugs.

I agree in general, in this specific case this "workaround" came at no cost.
Now, given the results of test3.diff and alternative0002.patch, I begin to 
doubt it was a foxit bug at all...

Fabio
-------------- next part --------------
A non-text attachment was scrubbed...
Name: test1.diff
Type: text/x-patch
Size: 414 bytes
Desc: not available
URL: <http://lists.freedesktop.org/archives/poppler/attachments/20121014/74f4f931/attachment-0005.bin>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: test2.diff
Type: text/x-patch
Size: 1484 bytes
Desc: not available
URL: <http://lists.freedesktop.org/archives/poppler/attachments/20121014/74f4f931/attachment-0006.bin>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: test3.diff
Type: text/x-patch
Size: 1556 bytes
Desc: not available
URL: <http://lists.freedesktop.org/archives/poppler/attachments/20121014/74f4f931/attachment-0007.bin>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: test4.diff
Type: text/x-patch
Size: 1578 bytes
Desc: not available
URL: <http://lists.freedesktop.org/archives/poppler/attachments/20121014/74f4f931/attachment-0008.bin>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: alternative0002.patch
Type: text/x-patch
Size: 2489 bytes
Desc: not available
URL: <http://lists.freedesktop.org/archives/poppler/attachments/20121014/74f4f931/attachment-0009.bin>


More information about the poppler mailing list