Populate PDF's checkbox

I had this question after viewing PDFTK - filling this PDF but got an error.

After talking with the others on this project, we decided it's ok to have the final PDF as read-only and it doesn't need to be editable.

I ran the commands below I can populate the PDF but not the checkbox. Joe (if you're reading this)....is this because of the LiveCycle issue that the checkboxes don't get checked?  If it is, I got approval to buy LiveCycle. I'll get it and see what's going on.

I tried "No" for value, "On", "1" but I don't see the checkbox checked.

1. i-765 is the orig file

2. notsigned.pdf is the file I QPDF-ed to get rid of the password error message

3. Ran this pdftk.exe notsigned.pdf fill_form i-765.txt output OutputFilled.pdf

4. outputfilled.pdf is the populated PDF.
i-765.pdf
notsigned.pdf
OutputFilled.pdf
LVL 8
CamilliaAsked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Joe Winograd, Fellow&MVEDeveloperCommented:
Hi Camilla,
Would be helpful if you attach i-765.txt. Thanks, Joe
0
CamilliaAuthor Commented:
Yes, I forgot. It's attached.
i-765.txt
0
CamilliaAuthor Commented:
0
Starting with Angular 5

Learn the essential features and functions of the popular JavaScript framework for building mobile, desktop and web applications.

Joe Winograd, Fellow&MVEDeveloperCommented:
Camilla,
I ran this with the two files you posted:

pdftk.exe notsigned.pdf fill_form i-765.txt output OutputFilledJW.pdf

The file that it created is attached. It has nothing filled in. I'll continue to experiment. Regards, Joe
OutputFilledJW.pdf
0
CamilliaAuthor Commented:
The file you attached has the name populated so that's working. I wonder why the checkbox doesn't get populated.
0
Joe Winograd, Fellow&MVEDeveloperCommented:
> The file you attached has the name populated so that's working.

Well, this is very interesting. When I open the file in Adobe Acrobat XI Pro and Nuance Power PDF Advanced, the Family Name field is not populated. When I open it in Adobe Reader DC, Google Chrome, Nitro Reader, and PDF-XChange Editor, the Family Name field is populated. I cannot explain that.
0
CamilliaAuthor Commented:
Odd but how about the checkboxes...why can't they be populated? I'll get LiveCyle if I have to.
0
Joe Winograd, Fellow&MVEDeveloperCommented:
Probably because it's an XFA form. Try putting this as the last parameter on your PDFtk generate_fdf and fill_form commands:

drop_xfa

Of course, then all the check-boxes will be clickable (and #15 won't work) in the generated PDF, but it should show the populated check-boxes in the generated PDF. Btw, the Wikipedia article on XFA is worth a read:
https://en.wikipedia.org/wiki/XFA
It helps to explain the viewing variances in PDF products that I mentioned earlier. Regards, Joe
0
CamilliaAuthor Commented:
let me see. I'll post back. I read about XFA the other day.
This turned out more difficult than I expected!
0
Joe Winograd, Fellow&MVEDeveloperCommented:
> This turned out more difficult than I expected!

Yes, LiveCycle/XFA makes it more difficult than a plain, ol' PDF form.
0
CamilliaAuthor Commented:
Going to try this now. Will post back
0
CamilliaAuthor Commented:
I've attached the FDF I created with drop_xfa.

How do , for example, set Gender? It looks like this
<<
/V /
/T (Gender[1])
>>

Open in new window


I think I need to put "On" or "Off"

For this field, I did it like this and it worked

<<
/V (Smith)
/T (Line1_FamilyName[0])
>>

Open in new window


I've attached the files.

1. i765.pdf is the orig file

2. dec765.pdf is the decrypted file  using this qpdf --decrypt i-765.pdf dec765.pdf

3. i765.txt is the FDF using this  pdftk.exe i-765.pdf generate_fdf output i-765.txt drop_xfa

4. i-765populated.pdf is the filled form using this pdftk.exe dec765.pdf fill_form i-765.txt output i-765Populated.pdf drop_xfa
i-765.pdf
dec765.pdf
i-765.txt
i-765Populated.pdf
0
Joe Winograd, Fellow&MVEDeveloperCommented:
OK, but please understand that this is what happens with the drop_xfa parameter:

(1) The form will be filled.

(2) You will see the checkboxes with an X, such as #7 (Gender) and #8 (Marital Status).

(3) You will see text fields, such as #1 (Family Name, First Name, Middle Name).

(4) You will see the expanded fields, such as #15 (the Yes checkbox, the text in USCIS Office, the Dates, and the Results).

BUT...here's the caveat...it is not really a working form. You'll be able to tick both Genders, all Marital Status choices, etc. Dropping the XFA means that it isn't going to perform as a form the way LiveCycle intended.

If you simply need to display/print/view the form after being filled in via PDFtk fill_form, this method should work for you; but if you need it to be a working form after being filled in via PDFtk fill_form, this method will not work for you.

Regards, Joe
1
Joe Winograd, Fellow&MVEDeveloperCommented:
Our messages just crossed. I haven't read your whole post yet, but here's what the Gender lines look like in my FDF:

/V /F
/T (Gender[1])

That fills in fine.

Heading for dinner now. Will check back in here in about an hour or two. Regards, Joe
0
CamilliaAuthor Commented:
Let me try.

but if you need it to be a working form after being filled in via PDFtk fill_form, this method will not work for you.

It's ok if the final form is read-only and not editable. I asked the team.

Enjoy dinner :) let me try and I'll post back.
0
CamilliaAuthor Commented:
I get this error

<<
/V /
F/T (Gender[1])
>>

Open in new window


Unhandled Java Exception in create_output():
java.lang.ClassCastException: pdftk.com.lowagie.text.pdf.PdfNull cannot be cast to pdftk.com.lowagie.text.pdf.PdfDictionary
   at 0x0059a84e (Unknown Source)
   at 0x0059ad42 (Unknown Source)
   at 0x005e9bd4 (Unknown Source)
   at 0x005ba4a4 (Unknown Source)
   at 0x005b2044 (Unknown Source)
   at 0x0059231e (Unknown Source)
   at 0x004723f1 (Unknown Source)
   at 0x00472045 (Unknown Source)
   at 0x004df3e2 (Unknown Source)
   at 0x004df38a (Unknown Source)
   at 0x00471e74 (Unknown Source)



I've attached the FDF file
i-765.txt
0
Joe Winograd, Fellow&MVEDeveloperCommented:
Your lines are like this:

/V /
F/T (Gender[1])

Mine are like this:

/V /F
/T (Gender[1])

Mine work perfectly (my FDF is attached).
JW-FDF.txt
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
CamilliaAuthor Commented:
How do you add it. I open the text file in notepad and then add the "F". Looks like this.

fdf
0
CamilliaAuthor Commented:
Your FDF works. Yours looks like this. What do you open it with ? I open mine with notepad.

joe fdf
0
CamilliaAuthor Commented:
I can open it with Visual Studio and keeps its format (looks like your FDF). I'll play around with it some more.
0
Joe Winograd, Fellow&MVEDeveloperCommented:
I never use Notepad. I use a text editor called KEDIT...been using it for 20+ years...it's a PC look-alike of IBM's VM/CMS editor called XEDIT, which I used in my mainframe days. But I don't recommend KEDIT at this time to others...note this comment at their website (copied here under "Fair Use"):
Mansfield Software Group is no longer actively working on major upgrades of KEDIT. We are in the process of gradually winding the company down, and have limited support resources. For these reasons, we generally do not recommend KEDIT to new users or organizations not already familiar with the program.
Anyway, I know very little about Notepad. You may want to try Notepad++, which is free and generally gets rave reviews:
https://notepad-plus-plus.org/
1
CamilliaAuthor Commented:
Visual Studio worked. Thank you so much for all your help.

I have it to the point that I can generate the PDF in a read only format, populated but I get that popup "document enabled extended features". It's not a showstopper for now.
1
Joe Winograd, Fellow&MVEDeveloperCommented:
> Visual Studio worked.

Glad to hear it.

> Thank you so much for all your help.

You're very welcome.

> I have it to the point that I can generate the PDF in a read only format, populated

Great news!

> but I get that popup "document enabled extended features". It's not a showstopper for now.

That's a shame, but good to know that it's not a showstopper.

Regards, Joe
0
CamilliaAuthor Commented:
thanks :)
0
CamilliaAuthor Commented:
> but I get that popup "document enabled extended features". It's not a showstopper for now.

That's a shame, but good to know that it's not a showstopper.

I got rid of the popup. I used that "cat out" command of PDFtk. But this makes the PDF editable with the messed up checkboxes. I run the PDF thru iTextsharp and set the fields to readonly. It worked!
1
Joe Winograd, Fellow&MVEDeveloperCommented:
> I used that "cat out" command of PDFtk.
> I run the PDF thru iTextsharp and set the fields to readonly. It worked!

Very nice! Thanks for letting me know — clever trick!
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
.NET Programming

From novice to tech pro — start learning today.