codeshell / fpdm

PDF form filling using FPDM Class written by FPDF author Olivier (+multifile-filling-fix, +checkboxes)
MIT License
114 stars 66 forks source link

Checkboxes not checked correctly. #56

Open Shravya9506 opened 2 years ago

Shravya9506 commented 2 years ago

For the checkboxes, if I pass true or a string value or 1, the checkbox is not checked rather if I pass false or an empty string or 0 it gets checked. So I believe the functionality is working in the reverse order contradictory to the documentation provided. Can you please verify this.

pacerdev commented 2 years ago

I can't get them to work either. I have tried all sorts of combinations. Can you please provide a working code example so we can use that as a reference? It may be of note that my array has checkboxes, but also text areas that I need to populate and those are being passed along without issue.

pacerdev commented 2 years ago

Same here. Doesn't matter what I use, the fields simply won't populate checkboxes. If the developer can give us the sample pdf and code they used to verify the checkbox function as working, I'm sure I could pull that apart to understand the proper syntax.

Can we get a little bit more info on the checkboxes, please?

Vincent-HD commented 2 years ago

Well, I also have the same problem, but not exactly sure why, I have a PDF with forms and checkboxes, I can fill them using the library (I got it from someone in my company, but he is not here anymore), but once I edit the PDF through Adobe Acrobat DC or a online PDF editor, the checkbox cannot be filled anymore.

So I'm wondering if the PDF needs to be "encoded" in a specific format (or at least the format on checkbox is changing after editing) and that's why it's not working.

By enabling verbose mode in the library

$pdf->verbose = true;
$pdf->verbose_level = 3;
$pdf->useCheckboxParser = true;

With the old checkbox I got this output:

Change checkbox of the field chpb at line 9387 to value [Oui]
Change checkbox of the field chlu at line 9458 to value [Oui]
Change checkbox of the field chim at line 9426 to value [0]
Change checkbox of the field chgl at line 9490 to value [0]

And with the edited one through Adobe Acrobat DC and converted back with pdftk old.pdf output new.pdf it's not recognizing the checkboxes anymore:

Change checkbox value aborted, the field chpb has no checkbox definition.
Change checkbox value aborted, the field chlu has no checkbox definition.
Change checkbox value aborted, the field chim has no checkbox definition.
Change checkbox value aborted, the field chgl has no checkbox definition.

So I'm guessing there is something wrong with the format of checkboxes

pacerdev commented 2 years ago

Running pdftk will break the "checkbox definition" somehow. I have set tooltip and name correctly in Acrobat CC, turned off fast web view an compression, set it all the way down to Acrobat 5.0+ compatible, and on and on...

Right now, I can either format it in Acrobat and get a "field not found" error, or run pdftk on it, and get the dreaded "no checkbox definition" error. :p'''''''

The problem here is that this developer got checkboxes working, but didn't give anyone specs on the PDF. If they developer could simply post a working demo that we can download and pull apart, then the rest is not hard to figure out. But there seems to be some sort of specific setup to the document that must be in place for the "checkbox definition" to be present.

Vincent-HD commented 2 years ago

Ok so I managed to get it working. (idk why tho) So I started to look into the PR and the fork, I found this one: https://github.com/cedson61/fpdm Which seems to work at first glance, but I got weird behavior after, and one of my checkboxes doesn't get recognize anymore. So I rolled back to this repo

So for whatever reason, I edited the PDF with Acrobat DC, I deleted the checkboxes, save the PDF, and I re-added them with the same names and save.

I made sure that I had nothing into the tooltip like said in the repo above: Just make sure you don't have any alt text on your fields like so (or your checkboxes will come out blank)

I converted the PDF with pdftk like said in the readme of the repo pdftk old.pdf output new.pdf

And now it's working, the only thing that I noticed is that to have the checkbox correctly checked I needed to inverse the boolean True or "anything" = checkbox unchecked False or "" = checkbox checked To solves this (idk how I managed to find that first try) I changed the export Value in the checkbox properties to something else than "Yes", I put "Oui" (french) and now True = checked Acrobat_cES8eTDOVC

I can't share this PDF, I will try to share a working one today. I'm happy to see someone active on this repo, the odds that you had the same problem as me today are quite low 😅

TheOtherOther commented 2 months ago

i started working with fpdm today and ran into the same issue. Is there someone who solved this problem without recreating the checkboxes? I can see, that if i try to change the value of the check box, that it is slightly changed (a inner border inside the checkbox) And i found out, that the value fpdm is trying to put into the checkbox is "1" instead of true. Any help would be great :)

Or has someone an example where it worked?