Oh, you know it - I'm offering up a second pay-pal'd ice-cream to anyone who
can solve this one; I'm even willing to spring for extra fudge sauce at this
point - either that or our project is really doomed this time! :)
Basically, pdf forms that are enabled for user rights, and then pre-filled via
iText, lose their user rights after the first offline save in Adobe Reader: you
get the dreaded "the document has changed since it was created and these rights
are no longer valid" message. I just tested now with
enabled_form_prefilled.pdf posted on the FAQ page at
http://www.1t3xt.info/examples/browse/?page=example&id=348. I'm using Adobe
Reader 8.1.2 on WinXP SP 2. Several key points observed so far surrounding
this issue:
*
I just ran an "isXfaPresent()" on this form from the FAQ, and it returned true,
so this may be the same XFA issue observed last week by '1T3XT info' (is that
Bruno?), in response to my problem with reading the Form fields after offline
saving. To quote from
http://www.nabble.com/Re%3A-Can%27t-read-Acro-XFA-fields-after-offline-saving-p18138681.html
(bold emphasis mine):
I compared the XFA stream in both documents:
[1] in the PDF that was filled using iText
[2] in the PDF that was filled manually in Adobe Reader and then saved.
[1]
<?xml version="1.0" encoding="UTF-8"?>
<xdp:xdp timeStamp="2008-06-26T13:25:45Z"
uuid="76ae0ec7-3fb6-45a8-9c3e-672542aa72e5"
xmlns:xdp="http://ns.adobe.com/xdp/">...</xdp:xdp>
[2]
<?xml version="1.0" encoding="UTF-8"?>
<?xfa generator="XFA2_4" APIVersion="2.6.7120.0"?>
<xdp:xdp xmlns:xdp="http://ns.adobe.com/xdp/"
timeStamp="2008-06-26T13:25:45Z"
uuid="76ae0ec7-3fb6-45a8-9c3e-672542aa72e5">...</xdp:xdp>
Apparently when you save such a form using Adobe Reader,
an extra processing instruction is added. It was that
processing instruction that made iText choke and throw
a NullPointerException.
So perhaps Reader is seeing the "adding of an extra processing instruction"
(namely, <?xfa generator="XFA2_4" APIVersion="2.6.7120.0"?>) that gets added
after the first save, and is taking this to mean that the document itself (and
not simply a form field value) has changed. What do you think?
*
User rights are not lost when pre-filling the form manually (confirmed by
editing enabled_form.pdf from the FAQ page), or when simply copying the form
without any calls to setField (confirmed by simply removing all calls to
setField in FillEnabledForm.java from the FAQ page). So something's going on
in setField; perhaps this further implicates XFA? To read the form data, the
solution in the above thread was to explicitly remove the XFA from the
PDFDictionary before calls to getField (I just tried the same thing in
FillEnabledForm.java before creating the stamper and getting the form; as you
might expect, it renders the setField calls powerless - nothing gets set).
*
I also tried form.getXFA().setChaned(true), to no effect. Is there possibly
some other way to get the xfa to update itself with this extra processing
instruction, or add it to the xfa file directly?
*
FYI, there are other causes of this 'breaking after first save' error, most
notably a bug that was fixed in Reader 8.1.2 this year: see issue #1573793 in
the 8.1.2 release notes:
http://kb.adobe.com/selfservice/viewContent.do?externalId=kb403079&sliceId=1.
I'm using 8.1.2, however.
*
The other lesser-known cause is not embedding fonts in your form, which can
forces a user's Reader to add them in on first save, thereby altering the
document structure. I'm creating and testing on the same PC though, so this is
not the cause here.
Any suggestions are most welcome! If this ends up being an unresolveable
XFA-related issue, I'd still consider switching to a pure Acro form, but my
problem with that so far has been finding a way to convert from XFA to Acro (we
have a 4-page static XFA form with lots of fields). Worst-case scenario if XFA
is the problem, and we can't convert: we could re-design the whole form from
scratch using Acrobat (non-Pro) - but that would be a difficult task for our
designer.
Thanks and regards,
-Peter Demling
Lexington, MA
-------------------------------------------------------------------------
Check out the new SourceForge.net Marketplace.
It's the best place to buy or sell services for
just about anything Open Source.
http://sourceforge.net/services/buy/index.php
_______________________________________________
iText-questions mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/itext-questions
Do you like iText?
Buy the iText book: http://www.1t3xt.com/docs/book.php
Or leave a tip: https://tipit.to/itexttipjar