Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

PDF-Form Text hidden unless clicked

In my application I have to fill a predefined PDF form with data from DB. We are using Java and Pdfbox. The filling itself is not a problem.

The problem is that in resulting PDF-file all texts in the form are invisible (or hidden, also grey rectangles) unless field clicked.

How can I solve this problem?

like image 261
codejitsu Avatar asked Nov 30 '22 05:11

codejitsu


2 Answers

I had the same problem when I tried to programmatically fill PDF forms using pdfbox. I add this answer to a rather old question as all the other answers manipulate the original PDF, which is not always an option.

The problem with invisible form fields just appeared in Acrobat PDF, other PDF renderers showed it fine. If using pdfbox 1.8.x you have to set Need Appearances as explained here:

PDAcroForm form = docCatalog.getAcroForm();
form.getDictionary().setItem(COSName.getPDFName("NeedAppearances"), COSBoolean.TRUE);

If using pdfbox 2 this is simplified to:

PDAcroForm form = docCatalog.getAcroForm();
form.setNeedAppearances(true);
like image 59
dirkk Avatar answered Dec 02 '22 20:12

dirkk


I read this on a forum and worked for me:

Using Adobe Acrobat Pro, I exported the form using "Export Data" to a XML and then imported it back from XML-file with "Import Data". Those commands are under Forms/Manage Forms Data

This is the link to the post: http://forums.adobe.com/thread/637421

like image 27
Zalia Avatar answered Dec 02 '22 19:12

Zalia