Git Product home page Git Product logo

fpdm's Introduction

PDF Form Filling with FPDM

Package

The FPDM class allows to fill out PDF forms, i.e. populate fields of a PDF file. It is developed by Olivier Plathey, author of the FDPF Library, and has been released as Skript 93.

I created this repository for the following reasons:

  • make the current FPDM source available via composer, autoload via classmaps
  • bugfixing
    • FIX: compatibility issues with PHP 7.x e376dc1 v2.9.1
    • FIX: filling forms in multiple files (wrong buffer usage, invalid offsets) e376dc1 v2.9.1
    • FIX: convert ASCII object names to utf-8 1eddba7 v2.9.2
  • improvements (changes to the original codebase are prefixed with //FIX: change description and ended with //ENDFIX)
    • ADD: support for checkboxes (disabled by default, activate with $pdf->useCheckboxParser = true;) 0375dd9 v2.9.2

Version

Based on version 2.9 (2017-05-11) available from fpdf.org/en/script/script93.php.

Note: If you find that a new version has been hosted on fpdf.org, please do not hesitate to drop me a short note to make sure I do not miss it out.

This repository only contains the separate php class written for form filling (FPDM). If you are looking for a repository containing the main FPDF Library, please head over to github.com/Setasign/FPDF.

Once again, all credits to Olivier Plathey for providing an easy to use script for form filling in addition to his FPDF library!

Installation

Composer

The preferred way of making FPDM available in your app is to install it via composer with

composer require tmw/fpdm

Usage

Composer (autoload)

autoload FPDM class files by adding this to your code:

require 'vendor/autoload.php';

Standalone Script (legacy)

Load the top level entry point by calling

require_once '/abolute/path/to/fpdm.php';

or

require_once './relative/path/to/fpdm.php';

Customization to original code

classmaps vs. psr-4 (or: legacy code vs modern frameworks á la Laravel)

Autoloading classes with namespaces and following PSR-4: Autoloader would be desireable. Especially reducing the risk of naming conflicts by using vendor namespaces.

However, FPDM has been around for a long time and as such is used in many projects that use non-namespaced code (I refer to them as legacy projects). Legacy projects instantiate FPDM by calling $mypdf = new FPDM() which is unqualified but defaults to the global namespace with non-namespaced code.

Using psr-4 would autoload the class to a subnamespace (e.g. \codeshell\fpdm\FPDM) instead of the global namespace (e.g. \FPDM) thus breaking any legacy code no matter if it used new FPDM() or new \FPDM().

Classmaps are a compromise. They allow taking advantage of composers autoloading and dependency management. Yet classes are added to the global namespace. Legacy projects can switch to composer without having to refactor their code. Newer projects (e.g. utilizing frameworks like laravel, that heavily rely on namespaces) can still use legacy classes by using the fully qualified name (in this case the class name prefixed with global prefix operator as in new \FPDM()).

That's my reasoning for using classmaps over psr-4 for FPDM. Please let me know if there are use cases where classmaps won't work with modern frameworks.

Checkboxes

I added support for checkboxes. The feature is not heavily tested but works for me. Can be enabled with useCheckboxParser = true like so:

<?php
$fields = array(
    'my_checkbox'    => 'anything that evaluates to true.', // checkbox will be checked;  Careful, that includes ANY non-empty string (even "no" or "unchecked")
    'another_checkbox' => false, // checkbox will be UNchecked; empty string or 0 work as well
);

$pdf = new FPDM('template.pdf');
$pdf->useCheckboxParser = true; // Checkbox parsing is ignored (default FPDM behaviour) unless enabled with this setting
$pdf->Load($fields, true);
$pdf->Merge();
$pdf->Output();

You don't have to figure out the technical names of checkbox states. They are retrieved during the parsing process.

Original Info Page

Everything below is mirrored from http://www.fpdf.org/en/script/script93.php .

Information

Author: Olivier

License: FPDF

Description

This script allows to merge data into a PDF form. Given a template PDF with text fields, it's possible to inject values in two different ways:

  • from a PHP array
  • from an FDF file

The resulting document is produced by the Output() method, which works the same as for FPDF.

Note: if your template PDF is not compatible with this script, you can process it with PDFtk this way:

pdftk modele.pdf output modele2.pdf

Then try again with modele2.pdf.

Example

This example shows how to merge data from an array:

<?php

/***************************
  Sample using a PHP array
****************************/

$fields = array(
    'name'    => 'My name',
    'address' => 'My address',
    'city'    => 'My city',
    'phone'   => 'My phone number'
);

$pdf = new FPDM('template.pdf');
$pdf->Load($fields, false); // second parameter: false if field values are in ISO-8859-1, true if UTF-8
$pdf->Merge();
$pdf->Output();
?>

View the result here.

fpdm's People

Contributors

codeshell avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar

fpdm's Issues

checkox no working

Hello,

after multiple test, i think that we have some trouble with checkbox.

1 . Checbox must be have "exported value" ( don't now wording exact ) set. ( see that with : https://www.pdfescape.com )

  1. After multi dump/verbose etc etc , i see that

`
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) {  
                        var_dump('change state plop : ' . $state);
                    }
                    $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;

`

when we dump var_dump($this->value_entries["$name"]["infos"]) and $this->pdf_entries ( script in and out )
we can see that value of checkox is not changed . Script change state ( $CurLine = '/AS /'. $state; ) but not the value .

So..my pdf checbox is never change.

now if u add :
$this->pdf_entries[$field_checkbox_line - 1]= '/V /' . $state; ( i change value )
It's working !!

But... maybe it's not good and cause trouble.. i don't know.
I

WordPress Issue

Cannot open PDF file when within Wordpress structure (within plugins specifically).

How to read data fields?

pdftk dump_field_data_fields works fine on my test.pdf returning all field data correctly.

How to achieve this with fpdm? Fields returning empty array:

image

Checkbox tick is not working

Hi

I am using updated FPDM library to tick checkbox on editable form. But its not working for me. Can you please or send me an example so that i can.\

Thanks

field not found for duplicated fields only

Writing values to fpdm with array from the test script works great for fields if field only occurs once. My form has duplicated fields so that they will copy from one page to another. They are named Address#0 Address#1 Address#2
The hashtag and number are added by Acrobat, not me and are only on duplicated fields. I get field Address not found error when I try to run the merge script. (runs fine if I don't use duplicated fields)
I try using Address, Address#0, Address#0 and numerous iterations.
Is this even possible? Any advice please?
pdftk shows the above field name as Address

require_once './fpdm.php';
$fields = array ('Address' => '999 Brook Drive S', 'City' => 'Zooland' );
$pdf = new FPDM('../testOp2.pdf');
$pdf->Load($fields,false ); // second parameter: false if field values are in ISO-8859-1, true if UTF-8
$pdf->Merge();
$pdf->Output(F,'/home1/rect/bin/fpdf182/newFile.pdf');
?>

Accent in FieldName gives FPDF-Merge Error: field *** not found

Hello,

I have an pdf and got field name from pdftk as "FieldName: 02_Prescri&#231;&#227;o"

So, several field names works, but thin in particular gives a "FPDF-Merge Error: field 02_Prescrição not found" error. I think it's because the accent in "Prescrição".

Note that "02_Prescri&#231;&#227;o" tuns in "02_Prescrição".

I can't change the name field. SO, how to fix it?

Short error

Note that
composer require shihjay2/fpdf

Will give an error; works with

composer require shihjay2/fpdm

fpdm unable to identify checkbox_yes and check_box_no

On my pdf forms, fpdm is unable to identify value for checkbox_yes and check_box_no.

Problem is in the line
} elseif (($ap_line==$Counter-4)&&($ap_d_line==$Counter-2)&&($ap_d_yes=='')&&$this->extract_pdf_definition_value("name", $CurLine, $match)) {

the offset of ap_d_line with counter is not 2 in my pdf file
If I remove this condition, it finds the two values but order is random with some pdf files I have inversion between checked and unchecked state.

I can send the pdf if needed.
The pdf was generated by Acrobat PDFMaker 10.1 pour Word with french locales.

Can someone helps me ?

Laravel: Class FPDM not found

I installed the package with this: composer require tmw/fpdm

This is the line that triggers the error: $pdf = new \FPDM($file);

The documentation doesn't say I need to do anything to my composer.json autoload section but I tried a few different things there with no luck.

checkbox fields

Hi,
i have a strange issue on checkbox filled with FPDM, on mac preview there is no problem in showing but on adobe acrobat reader the checkboxes aren't showed.
Sometimes on other Mac OS i can see that on checkboxes are present 2 marks...

Maybe the issue is that the font that is used for check mark is ZapfDingbats, but in pdf template created with adobe acrobat pro, the default font used for is AdobePi.

Here : http://webprogramming.ninja/2015/12/28/fpdf-and-the-check-mark/
there is a solution for fpdf.

is there a way for using a different font/char in fpdm for check marks?

thanks for your great work! i hope we can found a useful solution for community!

Carlo

Checkbox new array values

I don't know all the different layouts for the PDF arrays that can be checkboxes, but the pdf I'm using did not contain "checkbox_no" and "checkbox_yes", but rather just a "checkbox_state". When viewing this, it has the word "Off". I adjusted the the "set_field_checkbox($name, $value)" function to include another if check:

else if(isset($this->value_entries["$name"]["infos"]["checkbox_state_line"]) && isset($this->value_entries["$name"]["infos"]["checkbox_state"])) { $field_checkbox_line=$this->value_entries["$name"]["infos"]["checkbox_state_line"]; if ($field_checkbox_line) { $CurLine =$this->pdf_entries[$field_checkbox_line]; $OldLen=strlen($CurLine); $CurLine = '/AS /'; if($value) { $CurLine .= 'On'; } else { $CurLine .= 'Off'; } $NewLen=strlen($CurLine); $Shift=$NewLen-$OldLen; $this->shift=$this->shift+$Shift; //Saves $this->pdf_entries[$field_checkbox_line]=$CurLine; return $Shift; } else { if ($verbose_set) { echo "<br>Change checkbox value aborted, parsed checkbox definition incomplete."; } }

This does "fill in" my checkbox but not with a "x" or checkmark, but rather just a colored blob/square.

Field name not found

The script doesn't populate field names like this one
topmostSubform[0].Page4[0].DateTimeField1[0]

Checkboxes not checked correctly.

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.

Ajouter une nouvelle page / AddPage

Bonjour,

j'aimerais savoir s'il est possible avec FPDM d'ajouter des pages à son document ?

Je précise ma demande : je dois générer un récapitulatif de commande. Je ne sais pas à l'avance combien de lignes de produits va contenir ma commande mais le modèle de base est conçu pour 10 lignes. Comment faire pour que je puisse générer x pages à partir de mon document n'en contenant qu'une seule à la base ?

La commande AddPage de FPDF n'est pas reconnu avec FPDM.

ou à defaut d'une solution existe-t-il une librairie permettant de fusionner plusieurs pdf générés avec FPDM ? J'en ai essayé plusieurs mais aucune ne fonctionne avec des documents issus de FPDM.

Merci d'avance.
Bonne journée.

Hello,

I would like to know if it is possible with FPDM to add pages to its document?

I specify my request: I must generate an order summary. I do not know in advance how many product lines will contain my order but the basic model is designed for 10 lines. How can I generate x pages from my document containing only one at the base?

The FPDF AddPage command is not recognized with FPDM.

or in the absence of a solution is there a library allowing to merge several pdf generated with FPDM? I tried several but none of them work with documents from FPDM.

Thank you in advance.
Have a good day.

FPDF-Merge Error: Object streams are not supported

I took an existing pdf with various fields, converted it in Acrobat so the fields will allow input, and then I tested it out. But I'm getting this error now: FPDF-Merge Error: Object streams are not supported

The test worked fine with the template.pdf that was provided in the code. And when I look at the template.pdf in Acrobat, I can't see what the difference between the two .pdfs are.

Checkboxes Failing to Detect State for Valid PDFs

The code seems to assume that the checkbox "on" definition is aways first in the "/AP" Appearance Dictionary. This causes the checkbox code to set the wrong state for any PDF where the "off" definition is before the "on" definition.

For example a PDF with this checkbox Appearance Dictionary

/AP 
<<
/D 
<<
/Off 14 0 R
/Yes 15 0 R
>>
/N 
<<
/Off 16 0 R
/Yes 17 0 R

Will generate the following troubling data in the fpdm [infos] => Array:

[checkbox_yes] => Off
[checkbox_no] => Yes

I have checked the ISO 32000 and older PDF 1.4 reference and there seems to be no requirement for the "on" definition to appear before the "off" definition which would explain why a lot of PDFs have the reverse definition layout. The references do, on the other hand, seem to both state that the off-state definition must be named "Off", so this might be a better way to tell which definition is which.

Here is my horrible, rushed, hacked, redundancy filled solution.
In fpdm.php from line 1859 I replaced this

                                        } elseif (($ap_line==$Counter-4)&&($ap_d_line==$Counter-2)&&($ap_d_yes=='')&&$this->extract_pdf_definition_value("name", $CurLine, $match)) {
                                            $ap_d_yes=$match[1];
                                            if ($verbose_parsing) {
                                                echo("<br>Object's checkbox_yes is '<i>$ap_d_yes</i>'");
                                            }
                                            $object["infos"]["checkbox_yes"]=$ap_d_yes;
                                        } elseif (($ap_line==$Counter-5)&&($ap_d_line==$Counter-3)&&($ap_d_no=='')&&$this->extract_pdf_definition_value("name", $CurLine, $match)) {
                                            $ap_d_no=$match[1];
                                            if ($verbose_parsing) {
                                                echo("<br>Object's checkbox_no is '<i>$ap_d_no</i>'");
                                            }
                                            $object["infos"]["checkbox_no"]=$ap_d_no;

With this:

                                        } elseif (($ap_line==$Counter-4)&&($ap_d_line==$Counter-2)&&$this->extract_pdf_definition_value("name", $CurLine, $match)) {
                                            $ap_d_first=$match[1];
                                            if($ap_d_first!="Off") {
                                                if ($verbose_parsing) {
                                                    echo("<br>Object's checkbox_yes is '<i>$ap_d_first</i>'");
                                                }
                                                $ap_d_yes=$ap_d_first;
                                                $object["infos"]["checkbox_yes"]=$ap_d_first;
                                            }
                                            else {
                                                if ($verbose_parsing) {
                                                    echo("<br>Object's checkbox_no is '<i>$ap_d_first</i>'");
                                                }
                                                $ap_d_no=$ap_d_first;
                                                $object["infos"]["checkbox_no"]=$ap_d_first;
                                            }
                                        } elseif (($ap_line==$Counter-5)&&($ap_d_line==$Counter-3)&&$this->extract_pdf_definition_value("name", $CurLine, $match)) {
                                            $ap_d_second=$match[1];
                                            if($ap_d_second!="Off") {
                                                if ($verbose_parsing) {
                                                    echo("<br>Object's checkbox_yes is '<i>$ap_d_second</i>'");
                                                }
                                                $ap_d_yes=$ap_d_second;
                                                $object["infos"]["checkbox_yes"]=$ap_d_second;
                                            }
                                            else {
                                                if ($verbose_parsing) {
                                                    echo("<br>Object's checkbox_no is '<i>$ap_d_second</i>'");
                                                }
                                                $ap_d_no=$ap_d_second;
                                                $object["infos"]["checkbox_no"]=$ap_d_second;
                                            }
                                        } 

Also, just another possible minor issue. It seems that the code is looking for the definitions in the Appearance Dictionary's optional "down appearance" (/D) instead of the required "normal appearance" (/N). This seems like it might also cause issues for some PDFs if they include the "normal appearance" definitions but not the optional "down appearance".

Changing Checkbox Tick Font Size

Thank you very much for this script and keeping it opensource.

The checkbox parser tick is expected to match the original version of the editable pdf. How can i get my current output closest to expected output

Expected Output

image

Current Output

image

Checkbox not working?

Hi, I tried the new feature for checkbox, but it is not working in my local laptop, here is my code below, I didn't get error and other text boxes are working, could someone let me know possible issue for me?

require_once '../fpdm-2.9.2/fpdm.php';

$fields = array(
'name' => 'My name',
'address' => 'My address',
'city' => 'My city',
'phone' => 'My phone number',
'checkbox1' => 'Yes',
);

$fileName='template2';//test.pdf
$pdf = new FPDM('../forms/IR/'.$fileName.'.pdf');
$pdf->useCheckboxParser = true;
$pdf->Load($fields, false); // second parameter: false if field values are in ISO-8859-1, true if UTF-8
$pdf->Merge();

$output="corp_IR.pdf";
$pdf->Output('I',$output);

Sign PDF with FPDM ?

Hi,
I need to sign 2 fields in a PDF with PHP.
Is it possible with FPDM or other ?
Thanks !

Don't replace fields containing parentheses

Hi,

I am new to FPDM and have a problem the first time I use it.

When I want to replace a field whose value is:
/V (\(Saisir l'adresse sur 3 lignes minimum\)\rDESTINATAIRE\rADRESSE \rCP VILLE ))
He replaces with:
/V <20727565206465732063616E61726473>\rDESTINATAIRE\rADRESSE \rCP VILLE )
instead of
/V <20727565206465732063616E61726473>

So I corrected line 836 on /fpdm/fpdm.php :
if(preg_match('#/V\s?[<(]([^>)]*)[>)]#', $CurLine, $a, PREG_OFFSET_CAPTURE))
in
if(preg_match('#/V\s?[<(]([^>]*)[>)]#', $CurLine, $a, PREG_OFFSET_CAPTURE))

But is this the correct correction?

checkbox does not display in acrobat reader

When I use fpdm, checkbox appears correctly in okular but not in latest acrobat reader.

With the following change in src/fpdm.php, it works but I do not know what I am really doing...

@ -966,7 +958,7 @@
                         }
                         $CurLine =$this->pdf_entries[$field_checkbox_line];
                         $OldLen=strlen($CurLine);
-                        $CurLine = '/AS /'.$state;
+                       $CurLine = '/AS /'.$state."\n/DV /$state\n/V /$state";
                         $NewLen=strlen($CurLine);
                         $Shift=$NewLen-$OldLen;
                         $this->shift=$this->shift+$Shift;

FPDM Output Not Saving File

Using FPDM and instead of viewing the merge doc I am attempting to auto-save the doc on the server with variations of this syntax:

$pdf -> Output('filename.pdf', \folder\Destination::FILE);

No matter what I try I get an error and it will not save the results in a PDF file on the server.
(if i do not specify the DESTINATION:: i get incorrect output destination, if I include it then I get a class Destination not found error)

Can anyone help me with a variation of this command that will save the merged PDF doc? or perhaps a different method?

Thanks!

radiobuttons (checkbox-groups) added

I have recently modified the core-script src/fpdm.php in such a way that it now manages to cope with groups of checkboxes.
At least I think so;)

I'm not familiar with the github-habbits, yet: Shall I upload it here? Maybe after further testing and eliminiting some possible bugs left the modificatiosn might be worth another update.

The example-Form to integrate also contained some ugly umlauts and also a hyphen in the field-definitions. As for this I'd recommend to change the intial regex definition (Line 41) to

$FPDM_REGEXPS= array(
...
"name"=>"//([-#\w]+)/",
...
);
though I think this needs some more testing.

PHP 7.4 Warning: implode(): Invalid arguments passed in \fpdm\fpdm->get_buffer()

i got some warning php in fpdm.php line 550
$buffer=implode("\n",$this->pdf_entries);
sometime $this->pdf_entries is null it is not array
suggestion $buffer=implode("\n",!empty($this->pdf_entries) ? $this->pdf_entries : []);

another warning php in fpdm.php line 1627
Warning: count(): Parameter must be an array or an object that implements Countable in \fpdm\fpdm->parsePDFEntries()
$CountLines = count($entries);
i suggest $CountLines = !empty($entries) ? count($entries) : 0;

gzuncompress(): data error

I am getting gzuncompress(): data error when trying to merge a file, I am just running the following code

$pdf = new \FPDM($contractPath); $pdf->Load($fields, false); // second parameter: false if field values are in ISO-8859-1, true if UTF-8 $pdf->Merge(); $pdf->Output();

It works fine with template.pdf but fails on my pdf file. Any ideas what might be the issue or cause of this error?

Viewing a merged PDF on iOS, the filled-in fields are not visible

When using $support='native' and merging field values, the output pdf file will have fields that are not visible on iOS using the built-in pdf handlers. The fields are also not visible in mupdf viewer on Windows. If using a third party viewer on iOS (like Acrobat), then the filled-in field values look okay. But in a typical scenario, where the pdf is attached to an email message or viewed in Safari, the pdf will not preview correctly.

If using $support=’pdftk' on the same source pdf and same fill-in field values, the resulting pdf renders fine under iOS and mupdf viewer.

Viewed merged pdf file on iOS 13.3.1, iOS 9.3.5; Windows 10 version 1903 with MuPDF 1.14.0

Attached are the template pdf, merge output using native, and merged output using pdftk modes.
The templatePDF file was prepared with pdftk executable.


The calling PHP code looks like this [for $support='native']
$pdf = new FPDM($this->templatePDF);
$pdf->Load($flds, false);
// $pdf->Plays('pdftk');
$pdf->Fix();
$pdf->Merge();
$pdf->Output('I', $fName);

gc-native.pdf
gc-template.pdf
gc-pdftk.pdf

Link on textbox is not working

I try to set a URL on a textbox, but, show the HTML code.

` $fields = array(
'linea0' => 'My name 0',
'linea1' => 'My name1',
'linea2' => 'My name2',
'linea3' => 'My name3',
'linea4' => 'My name4',
'cvs' => 'My city5',
);

    $pdf = new FPDM('/path/template.pdf');
    $pdf->Load($fields, false);
    $pdf->Merge();
    $pdf->Output('F', '/path/to/output.php');`

Anyone?

Thanks

Radio boxes

I have a pdf form with some radio boxes in it, and when I try to fill the form I get an error message that says <b>FPDF-Merge Error:</b> field radio1 not found

Are radios not supported? If so that would be great to get support for

Field Name not found

Can't seem to get this working with my PDF.
PDF form created in Adobe Acrobat DC, then ran through pdftk, but FPDF still says the field names are not found.

Exact error is:
FPDF-Merge Error: field PremiseName not found

I can get the example working no problem, so I know this is an issue with my PDF.
If I run pdftk data_dump_fields the field name shows up correctly and I have copied and pasted that into my array.

I'm completely stuck where to turn for advice on what I'm missing here...

Submit PDF?

How would I submit a PDF, and have it be available to send as an email through SendGrid?

Need Readonly PDF

Hello Team,

Your code and this library is perfect and awesome - I really liked it.
But I have only one concern - once the data is merged into the PDF - I want the final PDF but not in Editable mode.
Is it possible? If Yes then please let me know how.
Really Appreciate your earliest reply.

Thank you.

Checkbox not working

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

Recommend changing error messaging

On line 637, I recommend you change the error messaging when trying to Output to a file from:

Unable to create output file: '.$name.' (currently opened under Acrobat Reader?)

to:

Unable to create output file: '.$name.' (check that your application has file/folder permissions on the local server (ie. if a web app, does www-group have group permissions/access to write; if a CMS based application, did you provide a public files path?), or is it currently opened under Acrobat Reader?)

Can not flatten the PDF

I generate a new PDF with the filled data but Firefox can not render it correctly so i tried to flatten the PDF so i used:

$pdf = new FPDM('pattern.pdf'); $pdf->Load($fields, true); // second parameter: false if field values are in ISO-8859-1, true if UTF-8 //$pdf->Flatten(); $pdf->Merge(); $pdf->Output();

command which make unreadable the pdf in every platform.

create_function: deprecated 7.2 - Use anonymous functions instead.

When looking at the code I came across this hack in src/fpdm.php

//My PHP4/5 static call hack, only to make the callback $this->replace_value($matches,"$value") possible!
$callback_code='$THIS=new FPDM("[_STATIC_]");return $THIS->replace_value($matches,"'.$value.'");';

$field_regexp='/^\/(\w+)\s?(\<|\()([^\)\>]*)(\)|\>)/';

if(preg_match($field_regexp,$CurLine)) {
    //modify it according to the new value $value
    $CurLine = preg_replace_callback(
        $field_regexp,
        create_function('$matches',$callback_code),
        $CurLine
    );
}else {
    if($verbose_set) echo("<br>WARNING:".htmlentities("Can not access to the value: $CurLine using regexp $field_regexp"));
}

PHPs create_function() seems to be deprecated as of 7.2. So this hack might fail in the future.

Method for QR code into merged pdf?

Is there a way to create a QR code using information from the field array into a merged pdf? Is it just a matter of creating a QR code type field in the pdf and then sending text to it like other text fields? Do you have any examples of how this might be done?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.