I'm new to PDF but we want to prefill some fields in an existing document from an application, so I am trying out a few things.
I tried to run the FillForm example against a document. The field was updated correctly, but when I opened the document with Adobe Reader the new value was not displayed until I touched the field - either with the mouse (not just rollover) or by tabbing into it. Then it displays nicely.
If I add "text1" to the field in the original document (with Adobe Reader) and the run the example (adding "text2", I see the old value ("text1") until I touch the field. Then i see "text2".
As far as I can see the fields lack an appearance attribute (there is no /AP attibute in the dictionary). I think it will be alright if I supply a NormalAppearance, but how do I do that?
I thought I could just add
but PDAppearance cannot be instantiated directly.
So what do I do?
I know it would be a great help for you if I could send you the document and let you try it out yourselves, but unfortunately the document is confidential and I haven't been able to get my hands on a non-confidential copy.
first of all, thank you for trying jPod.
Forms and PDF contents rendering are two separated concepts in PDF. Every PDF viewer just displays the page contents including its annotations. So it is the acroform's job to provide an appearance representing its current state. If you change the field's state inside an application, the appearance is regenerated and becomes visible. That is what happens, when you click or tab into the field.
If you change an acroform field's value inside your application, then you have two choices to make the changes visible:
1. Set the acroform flag "NeedAppearances". This tells the renderer, that acroform field appearances are missing and should be regenerated (all of them). This consequently changes the document every time it is opened in a PDF viewer. Method de.intarsys.pdf.pd.PDAcroForm.setNeedAppearances(boolean) sets this flag.
2. Render an appearance representing the new field state. Right now, the open sourced version of jPod doesn't contain ready to use annotation appearance renderers, but all the infrastructure to implement your own ones.
Take a look at the references and implementors of de.intarsys.pdf.app.appearance.IAppearanceCreator. The basic rendering examples can also be applied to rendering field state appearances.
An overview of jPod and associated libraries can be found at
Hopefully my hints will help you to find a solutions for your problem.