PDF-Form Text hidden unless clicked
Asked Answered
S

9

5

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?

Supersonic answered 30/8, 2012 at 14:5 Comment(1)
I hesitate to ask... is the text perhaps white (the same color as the background)?Fernandina
I
11

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);
Indeterminacy answered 5/1, 2016 at 12:15 Comment(4)
Adding the "NeedAppearances" line did not resolve the problem for me with pdfbox 1.8.x. Upgrading to pdfbox 2 and setting form.setNeedAppearances(true) fixed itWinona
@Dónal weird, I actually didn't even test it with pdfbox 2, just read the API. But I did test it with 1.8.10 and it resolved the issue for me. Of course, there could be other issues here as well. I also remove the AP values for the form fields before, maybe that's relevant?Indeterminacy
Both methods works for me - 1.8 and 2.0.0-RC3. Thanks, you saved my life (mental health at least). I just wonder why it's not true by default.Hangman
The /NeedAppearances setting in a PDF means that the viewer should create the appearances. PDFBox 2.0.* should create good appearances itself (in theory). The only weakness that I remember are RTL languages (e.g. hebrew, arabic) and languages with complex scripts (e.g. thai and some indian languages).Vaporescence
R
4

I had this exact problem with a form I was filling with PDFBox in Java.

I fixed it by opening the original (blank) PDF form in Acrobat Pro and changing some options for each of the problem text fields. The options might vary for you, but here's what worked for me:

In the Acrobat Pro menu bar go to Forms > Add or edit fields. Right click the text field in Acrobat Pro and select properties, then:

In the 'Options' tab:

  • Untick all options except 'scroll long text'
  • Add a few space characters in to the Default Value box

In the 'Appearance' tab:

  • Set the font size to 'auto'

Click 'close form editing' and save the file.

Field Options

Room answered 26/2, 2013 at 22:8 Comment(0)
R
2

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

Roumell answered 12/10, 2012 at 10:2 Comment(0)
M
2

I just ran across this and tried a combination of things before one very simple thing worked. I have Adobe Acrobat 9.0 and I couldn't find some of the options written here.

What I ended up doing was a two-pronged process: I went to Forms > Manage Form Data > Export Data; I then saved that file on my desktop. Next, I went back to Forms > Manage Form Data but instead selected Import Data, and selected that file I'd just saved. Bingo! Everything filled in properly.

Mediant answered 28/10, 2014 at 19:24 Comment(1)
Apologies, it looks like someone previously mentioned this too!Mediant
R
1

I don't quite know how you can stop it happening in the future but a resolution to getting the file working, similar to g-eorge is to open it in adobe acrobat pro, in tools on the right hand menu select "Interactive objects" and choose select object.

When you highlight the first field you want to fix, you should then be able to control-a to select all interactive objects. Once all are selected, right click on one field and select properties.

In the "general" tab the bottom option should have "common properties" which has the option "form field" change this to hidden and then back to visible. This will then restore all visibility to the form.

This has worked for me on all the rare instances when I receive this, and hasn't failed me once. Hope it does the same for you,

BoB

Revamp answered 17/12, 2013 at 10:22 Comment(0)
L
1

in the appearance tab of each erroneously hidden object you will see the "fill color" set to none. set it to none again (just click on it) and save the PDF and these fields will show up normally. I can't believe adobe has let this error persist for so long. It happens constantly when viewing/saving with multiple pdf readers.

Laconism answered 22/4, 2014 at 15:40 Comment(1)
How can you be sure this is an Adobe error? I've seen quite a lot of PDFs with an issue as described by the OP, and often the problem was due to some error in the PDF (produced by non-Adobe software).Instillation
D
0

Nothing I tried here worked - except to change software.

I was using PDFElement 6 Pro (trial) and couldn't make it work. Tried all sorts of things with PDFBox plus all suggestions above.

Ended up trying https://www.pdfescape.com/ and it all worked just fine.

Duelist answered 20/8, 2019 at 6:44 Comment(1)
It would still be interesting to see your file... if possible, upload it on a sharehoster and post the address here or on the users mailing list, and mention what field you are trying to set. See also the comment I made on the accepted answer.Vaporescence
E
0

In my case I solved it by changing the font to Arial (or one of the standard in windows set), in the 'Appearance' tab, in properties. Before, it was set Helvetica which was not embedded in the file and that I think generated the problem.

Expose answered 27/2, 2021 at 12:0 Comment(0)
O
0

Map over all text form fields and programmatically nuke DA, MK and AP entries in a PDF dictionary - those are references to styles so they can include things like fonts that other machine might not have installed and therefore by default they displays as blanks.

Orpington answered 17/5, 2023 at 6:41 Comment(1)
Nuking AP without replacement in a PDF 2.0 document makes it invalid.Instillation

© 2022 - 2024 — McMap. All rights reserved.