@@ -59,10 +59,10 @@ use mikehaertl\pdftk\Pdf;
59
59
60
60
// Fill form with data array
61
61
$pdf = new Pdf('/full/path/to/form.pdf');
62
- $pdf->fillForm(array(
62
+ $pdf->fillForm([
63
63
'name'=>'ÄÜÖ äüö мирано čárka',
64
64
'nested.name' => 'valX',
65
- ) )
65
+ ] )
66
66
->needAppearances()
67
67
->saveAs('filled.pdf');
68
68
@@ -87,6 +87,7 @@ if you have special characters in your data.
87
87
This is a bonus feature that is not available from ` pdftk ` .
88
88
89
89
``` php
90
+ use mikehaertl\pdftk\XfdfFile;
90
91
use mikehaertl\pdftk\FdfFile;
91
92
92
93
$xfdf = new XfdfFile(['name'=>'Jürgen мирано']);
@@ -98,23 +99,23 @@ $fdf->saveAs('/path/to/data.fdf');
98
99
99
100
#### Cat
100
101
101
- Assemble a PDF from pages of one or more PDF files.
102
+ Assemble a PDF from pages from one or more PDF files.
102
103
103
104
``` php
104
105
use mikehaertl\pdftk\Pdf;
105
106
106
107
// Extract pages 1-5 and 7,4,9 into a new file
107
108
$pdf = new Pdf('/path/to/my.pdf');
108
109
$pdf->cat(1, 5)
109
- ->cat(array( 7, 4, 9) )
110
+ ->cat([ 7, 4, 9] )
110
111
->saveAs('/path/to/new.pdf');
111
112
112
113
// Combine pages from several files, demonstrating several ways how to add files
113
- $pdf = new Pdf(array(
114
- 'A' => '/path/file1.pdf', // Reference file as 'A'
115
- 'B' => ['/path/file2.pdf','pass**word'], // Reference file as 'B'
116
- ) );
117
- $pdf->addFile('/path/file3.pdf','C','**secret**pw'); // Reference file as 'C'
114
+ $pdf = new Pdf([
115
+ 'A' => '/path/file1.pdf', // A is alias for file1.pdf
116
+ 'B' => ['/path/file2.pdf','pass**word'], // B is alias for file2.pdf
117
+ ] );
118
+ $pdf->addFile('/path/file3.pdf','C','**secret**pw'); // C is alias file3.pdf
118
119
$pdf->cat(1, 5, 'A') // pages 1-5 from A
119
120
->cat(3, null, 'B') // page 3 from B
120
121
->cat(7, 'end', 'B', null, 'east') // pages 7-end from B, rotated East
@@ -131,10 +132,10 @@ stream at a time.
131
132
``` php
132
133
use mikehaertl\pdftk\Pdf;
133
134
134
- $pdf = new Pdf(array(
135
- 'A' => '/path/file1.pdf', // Reference file as 'A'
136
- 'B' => '/path/file2.pdf', // Reference file as 'B'
137
- ) );
135
+ $pdf = new Pdf([
136
+ 'A' => '/path/file1.pdf', // A is alias for file1.pdf
137
+ 'B' => '/path/file2.pdf', // B is alias for file2.pdf
138
+ ] );
138
139
139
140
// new.pdf will have pages A1, B3, A2, B4, A3, B5, ...
140
141
$pdf->shuffle(1, 5, 'A') // pages 1-5 from A
@@ -215,9 +216,16 @@ $data = $pdf->getData();
215
216
// Get form data fields
216
217
$pdf = new Pdf('/path/my.pdf');
217
218
$data = $pdf->getDataFields();
218
- echo $data; // raw string; also can directly call $data->__toString();
219
- print_r($data); // metadata as array; also can directly call $data->__toArray();
220
- $field1Value = $data[0]['FieldValue']; // array access to a field's value
219
+
220
+ // Get data as string
221
+ echo $data;
222
+ $txt = (string) $data;
223
+ $txt = $data->__toString();
224
+
225
+ // Get data as array
226
+ $arr = (array) $data;
227
+ $arr = $data->__toArray();
228
+ $field1 = $data[0]['Field1'];
221
229
```
222
230
223
231
#### How to perform more than one operation on a PDF
@@ -231,11 +239,11 @@ use mikehaertl\pdftk\Pdf;
231
239
// Extract pages 1-5 and 7,4,9 into a new file
232
240
$pdf = new Pdf('/path/my.pdf');
233
241
$pdf->cat(1, 5)
234
- ->cat(array( 7, 4, 9) );
242
+ ->cat([ 7, 4, 9] );
235
243
236
244
// We now use the above PDF as source file for a new PDF
237
245
$pdf2 = new Pdf($pdf);
238
- $pdf2->fillForm(array( 'name'=>'ÄÜÖ äüö мирано čárka') )
246
+ $pdf2->fillForm([ 'name'=>'ÄÜÖ äüö мирано čárka'] )
239
247
->needAppearances()
240
248
->saveAs('/path/filled.pdf');
241
249
```
@@ -264,7 +272,7 @@ $pdf->allow('AllFeatures') // Change permissions
264
272
// Example: Fill PDF form and merge form data into PDF
265
273
// Fill form with data array
266
274
$pdf = new Pdf('/path/form.pdf');
267
- $pdf->fillForm(array( 'name'=>'My Name') )
275
+ $pdf->fillForm([ 'name'=>'My Name'] )
268
276
->flatten()
269
277
->saveAs('/path/filled.pdf');
270
278
0 commit comments