You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+51-14Lines changed: 51 additions & 14 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1,45 +1,81 @@
1
-
# Form filling
1
+
# PDF Form Filling with FPDM
2
+
3
+
## Package
4
+
2
5
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](http://www.fpdf.org/), and has been released as [Skript 93](http://www.fpdf.org/en/script/script93.php).
3
6
4
7
I created this repository for the following reasons:
8
+
5
9
- make the current FPDM source available via [composer](https://packagist.org/packages/tmw/fpdm)
6
10
- fix compatibility issues with PHP 7.x
7
-
- bugfixing
11
+
- bugfixing (changes to the original codebase are prefixed with `//FIX: change description` and ended with `//ENDFIX`)
12
+
- add support for checkboxes (disabled by default, see customization to activate)
8
13
9
14
This repository only contains the separate php class written for form filling. If you are looking for a repository containing the main FPDF Library, please head over to [github.com/Setasign/FPDF](https://github.com/Setasign/FPDF).
10
15
11
16
Once again, all credits to Olivier Plathey for providing an easy to use extension to his FPDF library!
12
17
13
-
# Version
18
+
## Version
19
+
14
20
Based on version 2.9 (2017-05-11) available from [fpdf.org/en/script/script93.php](http://www.fpdf.org/en/script/script93.php).
15
21
16
22
Note: If you find that a new version has been hosted on fpdf.org, please do not hesitate to drop me [a short note](https://github.com/codeshell/fpdm/issues) to make sure I do not miss it out.
17
23
18
-
# Usage
19
-
## Composer (autoload)
20
-
As this package specifies autoloading information, you can [autoload](https://getcomposer.org/doc/01-basic-usage.md#autoloading) all the dependencies by adding this to your code:
24
+
## Usage
25
+
26
+
### Composer (autoload)
27
+
28
+
The preferred way of making FPDM available in your app is to install it via composer with
29
+
30
+
`composer require tmw/fpdm`
31
+
32
+
and then to [autoload](https://getcomposer.org/doc/01-basic-usage.md#autoloading) it by adding this to your code:
21
33
22
34
`require 'vendor/autoload.php';`
23
35
24
-
## Standalone Script
25
-
Load the class file by calling
36
+
### Standalone Script (legacy)
37
+
38
+
Load the top level entry point by calling
26
39
27
40
`require_once '/abolute/path/to/fpdm.php';`
28
41
29
42
or
30
43
31
44
`require_once './relative/path/to/fpdm.php';`
32
45
46
+
## Customization
47
+
48
+
Added support for checkboxes. The feature is not heavily tested but works for me. Can be enabled with
49
+
50
+
```php
51
+
<?php
52
+
$fields = array(
53
+
'my_checkbox' => 'anything that evaluates to true.', // checkbox will be checked; Careful, that includes ANY non-empty string (even "no" or "unchecked")
54
+
'another_checkbox' => false, // checkbox will be UNchecked; empty string or 0 work as well
55
+
);
56
+
57
+
$pdf = new FPDM('template.pdf');
58
+
$pdf->useCheckboxParser = true;
59
+
$pdf->Load($fields, false); // second parameter: false if field values are in ISO-8859-1, true if UTF-8
60
+
$pdf->Merge();
61
+
$pdf->Output();
62
+
```
63
+
64
+
You don't have to figure out the technical names of checkbox states. They are retrieved during the parsing process.
65
+
66
+
## Original Info Page
67
+
68
+
### Information
33
69
34
-
# Original Info Page
35
-
## Information
36
70
Author: Olivier
37
71
38
72
License: FPDF
39
73
40
-
## Description
74
+
### Description
75
+
41
76
This script allows to merge data into a PDF form. Given a template PDF with text fields, it's
42
77
possible to inject values in two different ways:
78
+
43
79
- from a PHP array
44
80
- from an <abbrtitle="Forms Data Format">FDF</abbr> file
45
81
@@ -49,10 +85,11 @@ Note: if your template PDF is not compatible with this script, you can process i
49
85
[PDFtk](https://www.pdflabs.com/tools/pdftk-server/) this way:
50
86
51
87
`pdftk modele.pdf output modele2.pdf`
52
-
88
+
53
89
Then try again with modele2.pdf.
54
90
55
-
## Example
91
+
### Example
92
+
56
93
This example shows how to merge data from an array:
57
94
58
95
```php
@@ -76,4 +113,4 @@ $pdf->Output();
76
113
?>
77
114
```
78
115
79
-
View the result [here](http://www.fpdf.org/en/script/ex93.pdf).
116
+
View the result [here](http://www.fpdf.org/en/script/ex93.pdf).
0 commit comments