Skip to content

Commit e0e0f84

Browse files
committed
Update README
1 parent 6f7bba5 commit e0e0f84

File tree

1 file changed

+20
-16
lines changed

1 file changed

+20
-16
lines changed

README.md

Lines changed: 20 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -10,12 +10,6 @@ php-pdftk
1010

1111
A PDF conversion and form utility based on pdftk.
1212

13-
**The `pdftk` command must be installed and working on your system.**
14-
15-
> Note: This library is written for pdftk 2.x versions. You should be able to
16-
> use it with pdftk 1.x but not all methods will work there. For details consult
17-
> the man page of pdftk on your system.
18-
1913
## Features
2014

2115
*php-pdftk* brings the full power of `pdftk` to PHP - and more.
@@ -29,6 +23,12 @@ A PDF conversion and form utility based on pdftk.
2923
* Read out meta data about PDF and form fields
3024
* Set passwords and permissions
3125

26+
## Requirements
27+
28+
* The `pdftk` command must be installed and working on your system
29+
* This library is written for pdftk 2.x versions. You should be able to use it with pdftk 1.x but not all methods will work there.
30+
For details consult the man page of pdftk on your system.
31+
3232
## Installation
3333

3434
You should use use [composer](https://getcomposer.org/) to install this library.
@@ -44,13 +44,13 @@ composer require mikehaertl/php-pdftk
4444
Please consult the `pdftk` man page for each operation to find out how each operation works
4545
in detail and which options are available.
4646

47-
> Note: You can always only perform **one** of the following operations on a single PDF instance.
48-
> Below you can find a workaround if you need multiple operations.
49-
5047
For all operations you can either save the PDF locally through `saveAs($name)` or send it to the
5148
browser with `send()`. If you pass a filename to `send($name)` the client browser will open a download
5249
dialogue whereas without a filename it will usually display the PDF inline.
5350

51+
**IMPORTANT:** You can always only perform **one** of the following operations on a single PDF instance.
52+
Below you can find a workaround if you need multiple operations.
53+
5454
#### Fill Form
5555

5656
Fill a PDF form with data from a PHP array or an XFDF/FDF file.
@@ -70,13 +70,14 @@ $pdf->fillForm('data.xfdf')
7070
->saveAs('filled.pdf');
7171
```
7272

73-
> Note: When filling in UTF-8 data, you should always add the needAppearances() option.
74-
> This will make sure, that the PDF reader takes care of using the right fonts for rendering,
75-
> something that pdftk can't do for you.
73+
**Note:** When filling in UTF-8 data, you should always add the `needAppearances()` option.
74+
This will make sure, that the PDF reader takes care of using the right fonts for rendering,
75+
something that pdftk can't do for you. Also note that `flatten()` doesn't really work well
76+
if you have special characters in your data.
7677

7778
#### Create a XFDF/FDF file from a PHP array
7879

79-
> Note: This is a bonus feature that is not available from `pdftk`.
80+
This is a bonus feature that is not available from `pdftk`.
8081

8182
```php
8283
use mikehaertl\pdftk\FdfFile;
@@ -123,11 +124,12 @@ stream at a time.
123124
```php
124125
use mikehaertl\pdftk\Pdf;
125126

126-
// new.pdf will have pages A1, B3, A2, B4, A3, B5, ...
127127
$pdf = new Pdf(array(
128128
'A' => 'file1.pdf', // Reference file as 'A'
129129
'B' => 'file2.pdf', // Reference file as 'B'
130130
));
131+
132+
// new.pdf will have pages A1, B3, A2, B4, A3, B5, ...
131133
$pdf->shuffle(1, 5, 'A') // pages 1-5 from A
132134
->shuffle(3, 8, 'B') // pages 3-8 from B
133135
->saveAs('new.pdf');
@@ -238,7 +240,7 @@ use mikehaertl\pdftk\Pdf;
238240
$pdf = new Pdf('my.pdf');
239241

240242
$pdf->allow('AllFeatures') // Change permissions
241-
->flatten() // Merge form data into document
243+
->flatten() // Merge form data into document (doesn't work well with UTF-8!)
242244
->compress($value) // Compress/Uncompress
243245
->keepId('first') // Keep first/last Id of combined files
244246
->dropXfa() // Drop newer XFA form from PDF
@@ -262,6 +264,8 @@ $pdf->addPage('my.pdf', null, 'some**password')
262264
->saveAs('new.pdf');
263265
```
264266

267+
### Execution
268+
265269
The class uses [php-shellcommand](https://github.com/mikehaertl/php-shellcommand) to execute
266270
`pdftk`. You can pass `$options` for its `Command` class as second argument to the constructor:
267271

@@ -270,7 +274,7 @@ use mikehaertl\pdftk\Pdf;
270274

271275
$pdf = new Pdf('my.pdf', [
272276
'command' => '/some/other/path/to/pdftk',
273-
'useExec' => true,
277+
'useExec' => true, // May help on Windows systems if execution fails
274278
]);
275279
```
276280

0 commit comments

Comments
 (0)