Comments (8)
Same issue here.
Text for field is ok. But checkbox doesn't work
from fpdm.
Any progress on this issue. Still facing issues with checkboxes
from fpdm.
any possible solution this issue. still now 2022
from fpdm.
Did you tried like this ?
$fields = array( 'name' => 'My name', 'address' => 'My address', 'city' => 'My city', 'phone' => 'My phone number', 'checkbox1' => true );
It works fine for me.Is you setting in properties checkbox?
not work in my case
from fpdm.
Hi, I have the same issue. I dig into the code and see that parser 'parsePDFEntries' is not finding the 'checkbox_yes' and 'checkbox_no' values, or they are simply not in my PDF file.
My PDF file was generated with AcrobarReaderPro and treated with pdftk.
How to properly prepare a pdf file to correctly fill checkbox fields via fpdm?
from fpdm.
I had the same issue; turns out that the checkbox_no
and checkbox_yes
infos were not populated, which are used by FPDM to detect the right values for on/off states. I harcoded the states to Off
and Yes
to workaround the issue.
This the modified set_field_checkbox
function:
fpdm/src/fpdm.php
line 940
public function set_field_checkbox($name, $value)
{
/* START HARDCODE THE checkbox_no AND checkbox_yes VALUES */
if (!isset($this->value_entries["$name"]["infos"]["checkbox_no"])) $this->value_entries["$name"]["infos"]["checkbox_no"] = "Off";
if (!isset($this->value_entries["$name"]["infos"]["checkbox_yes"])) $this->value_entries["$name"]["infos"]["checkbox_yes"] = "Yes";
/* END HARDCODE THE checkbox_no AND checkbox_yes VALUES */
//------------------------------------
$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 "<br>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 "<br>Change checkbox value aborted, parsed checkbox definition incomplete.";
}
}
} else {
if ($verbose_set) {
echo "<br>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;
}
The function will afterwards use the hardcoded checkbox_yes
value ("Yes") when a value is provided, or checkbox_no
("Off") in case there is no value provided (i.e empty, false, etc)
Example usage:
$fields = array(
"CHECKBOX_FIELD_NAME" => true //or any value that is not empty/false/0/etc
);
$fpdm = new FPDM('fillable_pdf_example.pdf');
$fpdm->useCheckboxParser = true;
$fpdm->Load($fields, true);
$fpdm->Merge();
$fpdm->Output();
from fpdm.
Did you tried like this ?
$fields = array( 'name' => 'My name', 'address' => 'My address', 'city' => 'My city', 'phone' => 'My phone number', 'checkbox1' => true );
It works fine for me.
from fpdm.
Did you tried like this ?
$fields = array( 'name' => 'My name', 'address' => 'My address', 'city' => 'My city', 'phone' => 'My phone number', 'checkbox1' => true );
It works fine for me.
Is you setting in properties checkbox?
from fpdm.
Related Issues (20)
- FPDF-Merge Error: No more resource to execute the command
- PHP 7.4 Deprecated function : Array and string offset access syntax with curly braces is deprecated HOT 1
- PHP 7.4 Warning: implode(): Invalid arguments passed in \fpdm\fpdm->get_buffer()
- Don't replace fields containing parentheses
- Checkboxes in a parent group can not be addressed HOT 2
- a new version is released by fpdf.org
- Question, can we extracted list of fields(names) of the template pdf HOT 2
- radiobuttons (checkbox-groups) added HOT 1
- Checkboxes not checked correctly. HOT 5
- FPDF-Merge Error: Object streams are not supported HOT 2
- Link on textbox is not working
- php 8.1.5 from php 7.4 FPDF-Merge Error: field Speciality not found HOT 1
- uppgrading from php 7.4 to php 8.1.5. Fields contatining åäö FPDF-Merge Error: field Månader not found HOT 8
- Sign PDF with FPDM ?
- FilterFlateDecode: invalid stream data error HOT 1
- FPDM Output Not Saving File HOT 1
- FPDF-Merge Error: Number of objects (277) differs with number of xrefs (280), something , pdf xref table is corrupted :(
- Mapping fields in the template with the values in Array
- Compatibility with php 8.1 HOT 1
- New release of original script (v2.10) HOT 3
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from fpdm.