简体   繁体   中英

acroform field values is not working in icepdf

I am working on a project that should read a pdf file/form that contains value filled up by a Java code.

form.setField("permitnumber", p.getApplicationorno());
            form.setField("amountpaid", p.getAmount_app());
            form.setField("estimatedfeet", "56");
            form.setField("receiptnumber", "123415");
            form.setField("validity", "5");

Now my problem is, the values that were set on the fields of the pdf form worked perfectly on Adobe PDF Reader but not on the ICEPdf Viewer. What I am missing here? Why is it that the values from PDF form can't be displayed by ICEPdf?

While setting the field values using iText, If af is your AcroFields instance, try to do

af.setGenerateAppearances(true);

before setting values.


The PDF specification ISO 32000-1 defines a NeedAppearances flag, cf. Table 218 – Entries in the interactive form dictionary . If it is set to true , a PDF viewer knows that it has to create appearance streams for form fields.

iText interprets that flag and only creates appearance streams while filling in forms if the flag is not true (if true , the viewer is expected to re-create such appearances anyways).

Ooo at least used to create PDF forms with that flag set to true . Adobe Reader does respect the flag and creates appearances if true . Probably your PDF viewer does not respect the flag, probably it always expects appearances to already exist in documents.

Using setGenerateAppearances(true) you can enforce appearance stream generation. If the above assumption is correct, this should fix your problem.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM