@@ -59,7 +59,7 @@ Fill a PDF form with data from a PHP array or an XFDF/FDF file.
59
59
use mikehaertl\pdftk\Pdf;
60
60
61
61
// Fill form with data array
62
- $pdf = new Pdf('form.pdf');
62
+ $pdf = new Pdf('/full/path/to/ form.pdf');
63
63
$pdf->fillForm(array(
64
64
'name'=>'ÄÜÖ äüö мирано čárka',
65
65
'nested.name' => 'valX',
@@ -91,10 +91,10 @@ This is a bonus feature that is not available from `pdftk`.
91
91
use mikehaertl\pdftk\FdfFile;
92
92
93
93
$fdf = new XfdfFile(['name'=>'Jürgen мирано']);
94
- $fdf->saveAs('data.xfdf');
94
+ $fdf->saveAs('/path/to/ data.xfdf');
95
95
96
96
$fdf = new FdfFile(['name'=>'Jürgen мирано']);
97
- $fdf->saveAs('data.fdf');
97
+ $fdf->saveAs('/path/to/ data.fdf');
98
98
```
99
99
100
100
#### Cat
@@ -105,23 +105,23 @@ Assemble a PDF from pages of one or more PDF files.
105
105
use mikehaertl\pdftk\Pdf;
106
106
107
107
// Extract pages 1-5 and 7,4,9 into a new file
108
- $pdf = new Pdf('my.pdf');
108
+ $pdf = new Pdf('/path/to/ my.pdf');
109
109
$pdf->cat(1, 5)
110
110
->cat(array(7, 4, 9))
111
- ->saveAs('new.pdf');
111
+ ->saveAs('/path/to/ new.pdf');
112
112
113
113
// Combine pages from several files, demonstrating several ways how to add files
114
114
$pdf = new Pdf(array(
115
- 'A' => 'file1.pdf', // Reference file as 'A'
116
- 'B' => ['file2.pdf','pass**word'], // Reference file as 'B'
115
+ 'A' => '/path/ file1.pdf', // Reference file as 'A'
116
+ 'B' => ['/path/ file2.pdf','pass**word'], // Reference file as 'B'
117
117
));
118
- $pdf->addFile('file3.pdf','C','**secret**pw'); // Reference file as 'C'
118
+ $pdf->addFile('/path/ file3.pdf','C','**secret**pw'); // Reference file as 'C'
119
119
$pdf->cat(1, 5, 'A') // pages 1-5 from A
120
120
->cat(3, null, 'B') // page 3 from B
121
121
->cat(7, 'end', 'B', null, 'east') // pages 7-end from B, rotated East
122
122
->cat('end',3,'A','even') // even pages 3-end in reverse order from A
123
123
->cat([2,3,7], 'C') // pages 2,3 and 7 from C
124
- ->saveAs('new.pdf');
124
+ ->saveAs('/path/ new.pdf');
125
125
```
126
126
127
127
#### Shuffle
@@ -133,14 +133,14 @@ stream at a time.
133
133
use mikehaertl\pdftk\Pdf;
134
134
135
135
$pdf = new Pdf(array(
136
- 'A' => 'file1.pdf', // Reference file as 'A'
137
- 'B' => 'file2.pdf', // Reference file as 'B'
136
+ 'A' => '/path/ file1.pdf', // Reference file as 'A'
137
+ 'B' => '/path/ file2.pdf', // Reference file as 'B'
138
138
));
139
139
140
140
// new.pdf will have pages A1, B3, A2, B4, A3, B5, ...
141
141
$pdf->shuffle(1, 5, 'A') // pages 1-5 from A
142
142
->shuffle(3, 8, 'B') // pages 3-8 from B
143
- ->saveAs('new.pdf');
143
+ ->saveAs('/path/ new.pdf');
144
144
```
145
145
146
146
#### Burst
@@ -150,8 +150,8 @@ Split a PDF file into one file per page.
150
150
``` php
151
151
use mikehaertl\pdftk\Pdf;
152
152
153
- $pdf = new Pdf('my.pdf');
154
- $pdf->burst('page_%d.pdf'); // Supply a printf() pattern
153
+ $pdf = new Pdf('/path/ my.pdf');
154
+ $pdf->burst('/path/ page_%d.pdf'); // Supply a printf() pattern
155
155
```
156
156
157
157
#### Add background PDF
@@ -162,14 +162,14 @@ Add another PDF file as background.
162
162
use mikehaertl\pdftk\Pdf;
163
163
164
164
// Set background from another PDF (first page repeated)
165
- $pdf = new Pdf('my.pdf');
166
- $pdf->background('back.pdf')
167
- ->saveAs('watermarked.pdf');
165
+ $pdf = new Pdf('/path/ my.pdf');
166
+ $pdf->background('/path/ back.pdf')
167
+ ->saveAs('/path/ watermarked.pdf');
168
168
169
169
// Set background from another PDF (one page each)
170
- $pdf = new Pdf('my.pdf');
171
- $pdf->multiBackground('back_pages.pdf')
172
- ->saveAs('watermarked.pdf');
170
+ $pdf = new Pdf('/path/ my.pdf');
171
+ $pdf->multiBackground('/path/ back_pages.pdf')
172
+ ->saveAs('/path/ watermarked.pdf');
173
173
```
174
174
175
175
#### Add overlay PDF
@@ -180,14 +180,14 @@ Add another PDF file as overlay.
180
180
use mikehaertl\pdftk\Pdf;
181
181
182
182
// Stamp with another PDF (first page repeated)
183
- $pdf = new Pdf('my.pdf');
184
- $pdf->stamp('overlay.pdf')
185
- ->saveAs('stamped.pdf');
183
+ $pdf = new Pdf('/path/ my.pdf');
184
+ $pdf->stamp('/path/ overlay.pdf')
185
+ ->saveAs('/path/ stamped.pdf');
186
186
187
187
// Stamp with another PDF (one page each)
188
- $pdf = new Pdf('my.pdf');
189
- $pdf->multiStamp('overlay_pages.pdf')
190
- ->saveAs('stamped.pdf');
188
+ $pdf = new Pdf('/path/ my.pdf');
189
+ $pdf->multiStamp('/path/ overlay_pages.pdf')
190
+ ->saveAs('/path/ stamped.pdf');
191
191
```
192
192
193
193
#### Generate FDF
@@ -198,8 +198,8 @@ Create a FDF file from a given filled PDF form.
198
198
use mikehaertl\pdftk\Pdf;
199
199
200
200
// Create FDF from PDF
201
- $pdf = new Pdf('form.pdf');
202
- $pdf->generateFdfFile('data.fdf');
201
+ $pdf = new Pdf('/path/ form.pdf');
202
+ $pdf->generateFdfFile('/path/ data.fdf');
203
203
```
204
204
205
205
#### Get PDF data
@@ -210,11 +210,11 @@ Read out metadata or form field information from a PDF file.
210
210
use mikehaertl\pdftk\Pdf;
211
211
212
212
// Get data
213
- $pdf = new Pdf('my.pdf');
213
+ $pdf = new Pdf('/path/ my.pdf');
214
214
$data = $pdf->getData();
215
215
216
216
// Get form data fields
217
- $pdf = new Pdf('my.pdf');
217
+ $pdf = new Pdf('/path/ my.pdf');
218
218
$data = $pdf->getDataFields();
219
219
```
220
220
@@ -227,15 +227,15 @@ If you need more than one operation you can feed one `Pdf` instance into another
227
227
use mikehaertl\pdftk\Pdf;
228
228
229
229
// Extract pages 1-5 and 7,4,9 into a new file
230
- $pdf = new Pdf('my.pdf');
230
+ $pdf = new Pdf('/path/ my.pdf');
231
231
$pdf->cat(1, 5)
232
232
->cat(array(7, 4, 9));
233
233
234
234
// We now use the above PDF as source file for a new PDF
235
235
$pdf2 = new Pdf($pdf);
236
236
$pdf2->fillForm(array('name'=>'ÄÜÖ äüö мирано čárka'))
237
237
->needAppearances()
238
- ->saveAs('filled.pdf');
238
+ ->saveAs('/path/ filled.pdf');
239
239
```
240
240
241
241
### Options
@@ -245,7 +245,7 @@ You can combine the above operations with one or more of the following options.
245
245
``` php
246
246
use mikehaertl\pdftk\Pdf;
247
247
248
- $pdf = new Pdf('my.pdf');
248
+ $pdf = new Pdf('/path/ my.pdf');
249
249
250
250
$pdf->allow('AllFeatures') // Change permissions
251
251
->flatten() // Merge form data into document (doesn't work well with UTF-8!)
@@ -261,15 +261,15 @@ $pdf->allow('AllFeatures') // Change permissions
261
261
262
262
// Example: Fill PDF form and merge form data into PDF
263
263
// Fill form with data array
264
- $pdf = new Pdf('form.pdf');
264
+ $pdf = new Pdf('/path/ form.pdf');
265
265
$pdf->fillForm(array('name'=>'My Name'))
266
266
->flatten()
267
- ->saveAs('filled.pdf');
267
+ ->saveAs('/path/ filled.pdf');
268
268
269
269
// Example: Remove password from a PDF
270
270
$pdf = new Pdf;
271
- $pdf->addPage('my.pdf', null, 'some**password')
272
- ->saveAs('new.pdf');
271
+ $pdf->addPage('/path/ my.pdf', null, 'some**password')
272
+ ->saveAs('/path/ new.pdf');
273
273
```
274
274
275
275
### Execution
@@ -280,8 +280,10 @@ The class uses [php-shellcommand](https://github.com/mikehaertl/php-shellcommand
280
280
``` php
281
281
use mikehaertl\pdftk\Pdf;
282
282
283
- $pdf = new Pdf('my.pdf', [
283
+ $pdf = new Pdf('/path/ my.pdf', [
284
284
'command' => '/some/other/path/to/pdftk',
285
+ // or on most Windows systems:
286
+ // 'command' => 'C:\Program Files (x86)\PDFtk\bin\pdftk.exe',
285
287
'useExec' => true, // May help on Windows systems if execution fails
286
288
]);
287
289
```
0 commit comments