codeshell / fpdm

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

Checkbox not working #27

Closed vishwajit76 closed 4 years ago

vishwajit76 commented 4 years ago

Please provide some examples with a checkbox. checkbox check and uncheck not working.

mhuch commented 4 years ago

Hi, i looked into the function set_field_checkbox and see that the $value is not used. So i think this is the reason because its not work.

vishwajit76 commented 4 years ago

i think $value is used in if condidtion to set $state.

public function set_field_checkbox($name, $value) { //------------------------------------ $offset_shift=0; $verbose_set=($this->verbose&&($this->verbose_level>1)); //Get the line(s) of the misc field values if (isset($this->value_entries["$name"])) { if (isset($this->value_entries["$name"]["infos"]["checkbox_state_line"]) && isset($this->value_entries["$name"]["infos"]["checkbox_no"]) && isset($this->value_entries["$name"]["infos"]["checkbox_yes"])) { $field_checkbox_line=$this->value_entries["$name"]["infos"]["checkbox_state_line"]; if ($field_checkbox_line) { if ($verbose_set) { echo "
Change checkbox of the field $name at line $field_checkbox_line to value [$value]"; } $state = $this->value_entries["$name"]["infos"]["checkbox_no"]; if ($value) { $state = $this->value_entries["$name"]["infos"]["checkbox_yes"]; } $CurLine =$this->pdf_entries[$field_checkbox_line]; $OldLen=strlen($CurLine); $CurLine = '/AS /'.$state; $NewLen=strlen($CurLine); $Shift=$NewLen-$OldLen; $this->shift=$this->shift+$Shift; //Saves $this->pdf_entries[$field_checkbox_line]=$CurLine; return $Shift; // $offset_shift=$this->_set_field_value($field_checkbox_line, $state); } else { if ($verbose_set) { echo "
Change checkbox value aborted, parsed checkbox definition incomplete."; } } } else { if ($verbose_set) { echo "
Change checkbox value aborted, the field $name has no checkbox definition."; } } } else { $this->Error("set_field_checkbox failed as the field $name does not exist"); } return $offset_shift; }

what are the changes in this function?

vishwajit76 commented 4 years ago

I found the solution - https://github.com/theChaosCoder/fpdm it worked when a checkbox's id and tooltip have the same value.

thank man. this library is very useful.

oneapple300690 commented 4 years ago

Hi vishwajit! Could you please help? I tried to put same name for checkbox's id and tooltip but it did not work.

vishwajit76 commented 4 years ago

use this ---> https://www.pdfescape.com for PDF form