0

I have a PDF with forms defined in it. One field in the form is a multi line text field.

The value in the text field is populated by a java program using Apache PDFBox.

The issue is when the value is of around 5 to 6 lines, the text box displays the text automatically. But if it is more than 6 lines, the text box does not display the value. I had to specifically click on the text field to display the text. If I click outside the text box again, the text disappears.

The text field is read only with Multi Line and Scrolling options enabled.

Any ideas what is causing this weird issue?

I have Adobe Acrobat Pro 11, Adobe Acrobat XI and Adobe Reader to view the files. All have the same issue.

Tilman Hausherr
  • 17,731
  • 7
  • 58
  • 97
SRCM
  • 271
  • 2
  • 14
  • I checked http://stackoverflow.com/questions/32398302/saved-text-field-value-is-not-displayed-properly-in-pdf-generated-using-pdfbox, https://www.itsupportguides.com/tech-tips-tricks/text-hidden-on-pdf-form-fields-until-clicked-on/, https://forums.adobe.com/thread/1019513 without much luck. – SRCM Aug 12 '16 at 10:23
  • 1
    Add this to the code that fills the form: `acroForm.setNeedAppearances(true);` – Tilman Hausherr Aug 15 '16 at 14:00
  • which version of PDFBox are you using? Could you share the PDF and a little sample how you ware populating the form field? – Maruan Sahyoun Aug 15 '16 at 14:09
  • Can you share code and pdf? – mkl Aug 15 '16 at 19:49

1 Answers1

2

It sounds like a typical "appearance" problem. There's no form field appearance in the field widget dictionary so when you click in the field, the raw string data is shown but when you click out there is no appearance to display so you get a blank. You can test this out by toggling the multi-line setting in the field properties in Acrobat so it generates an appearance. If that fixes it, then you the problem is the one I describe.

You can use PDFBox to set the "needs appearances" flag in the file that will tell Adobe viewers to regenerate field appearances when the file is opened but that doesn't work for all PDF viewers. To make the field value visible in all PDF viewers, it's best to generate appearances when you populate the field values.

The Datalogics PDF Java Toolkit can automatically generate appearances based on field values. Full disclosure, I represent Datalogics.

joelgeraci
  • 4,606
  • 1
  • 12
  • 19