https://github.com/gmitirol/toolkit-pdftk
Object-oriented PDFtk wrapper
https://github.com/gmitirol/toolkit-pdftk
pdf pdf-manipulation pdftk php php7
Last synced: 3 months ago
JSON representation
Object-oriented PDFtk wrapper
- Host: GitHub
- URL: https://github.com/gmitirol/toolkit-pdftk
- Owner: gmitirol
- License: lgpl-3.0
- Created: 2018-12-05T08:26:46.000Z (over 6 years ago)
- Default Branch: main
- Last Pushed: 2024-09-17T07:43:33.000Z (10 months ago)
- Last Synced: 2025-03-23T22:25:09.267Z (3 months ago)
- Topics: pdf, pdf-manipulation, pdftk, php, php7
- Language: PHP
- Size: 400 KB
- Stars: 4
- Watchers: 4
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
PHP Toolkit - PDFtk
===================This library provides an object-oriented, simple interface for the most important PDFtk features.
The current build status and code analysis can be found here:
* [Scrutinizer CI](https://scrutinizer-ci.com/g/gmitirol/toolkit-pdftk/)Requirements
------------
* PHP 7.1.0 or higher
* mbstring extension
* pdftkInstallation
------------
The recommended way to install toolkit-pdftk is via composer.
```json
"require": {
"gmi/toolkit-pdftk": "3.0.*"
}
```Usage examples
--------------
```php
use Gmi\Toolkit\Pdftk\Bookmark;
use Gmi\Toolkit\Pdftk\Pdftk;$source = '/path/to/source.pdf';
$target = '/path/to/target.pdf';$pdftk = new Pdftk();
// import a source PDF (metadata, page information, bookmarks)
$pdftk->import($source);// create an additional bookmark
$exampleBookmark = new Bookmark();
$exampleBookmark
->setPageNumber(1)
->setLevel(2)
->setTitle('Section 3')
;// add the bookmark to the PDF
$pdftk->bookmarks()->add($exampleBookmark);
// set metadata entry for the PDF
$pdftk->metadata()->set('Author', 'Jane Doe');// apply bookmarks and metadata to the source PDF using a specified target PDF
$pdftk->apply($source, $target);
```Tests
-----
The test suite can be run with `vendor/bin/phpunit tests`.