Weave Code
Weaver
Helps Laravel developers discover, compare, and choose open-source packages. See popularity, security, maintainers, and scores at a glance to make better decisions.
Feedback
Share your thoughts, report bugs, or suggest improvements.
Subject
Message

Php Pdftk Laravel Package

mikehaertl/php-pdftk

PHP wrapper for the pdftk command-line tool that lets you fill PDF forms, merge or split documents, extract pages, apply stamps, watermarks and backgrounds, and rotate or compress PDFs from your Laravel or PHP application.

Deep Wiki
Context7

mikehaertl/php-pdftk is a PHP wrapper around the pdftk command-line tool, offering a clean object-oriented API for common PDF operations without PHP extensions. It lets you configure the pdftk binary and build reusable workflows for form filling, page manipulation, and document assembly.

  • Fill and flatten PDF forms with field data
  • Merge, split, extract, and rotate pages
  • Add watermarks, stamps, backgrounds, and page numbers
  • Attach files or compress PDFs
  • Chain operations through a fluent API
Frequently asked questions about Php Pdftk
What is mikehaertl/php-pdftk used for?
It is a PHP wrapper around the pdftk command-line binary that lets you fill PDF forms, merge or split documents, extract and rotate pages, apply watermarks and backgrounds, and compress or repair PDFs. The API is chainable and has no external PHP dependencies. It is best treated as an infrastructure utility you call behind your own service class rather than as a framework feature.
Does mikehaertl/php-pdftk work with Laravel?
Yes, but it is not a Laravel-native package: there is no service provider, config file to publish, or facade. You install it with Composer and either instantiate it directly or bind your own PdfService interface to a thin adapter in a service provider. Keeping the package classes out of controllers and models makes it much easier to swap the PDF engine later.
How do I install mikehaertl/php-pdftk and what are the runtime requirements?
Install it with Composer, then make sure a pdftk executable is available in every environment: local machines, CI, containers, and queue workers. pdftk also requires a Java runtime, which means this is typically a platform or Docker image change rather than a code change. You also need a writable temp directory and a configurable path to the binary.
Which Laravel and PHP versions are supported?
The package is compatible with Laravel 9 through 11 and PHP 8.1 and above as a plain library. Because it has no framework coupling, version support mainly depends on your PHP version and the pdftk binary you run, not on Laravel internals. Always verify the binary version in your own test suite after framework upgrades.
How do I fill a PDF form with php-pdftk?
You point the wrapper at a PDF template and pass field values through its fillForm method, then save or stream the result. The chainable API lets you combine operations, such as filling a form and then stamping a watermark or flattening the output. For tenant or user-supplied PDFs, validate the input and set sensible timeouts before running the command.
Is it safe to process user-uploaded PDFs with this package?
Treat untrusted PDFs as an attack surface: malformed or malicious files are parsed by Java, so run operations with timeouts and, ideally, in a sandboxed worker that has no access to sensitive data. The wrapper escapes arguments, but path injection, temp-file exposure of PII, and resource exhaustion remain real concerns. Clean up temporary files and avoid writing to world-readable locations.
Should I run PDF operations in a queued job instead of a web request?
Because the package shells out to pdftk, calls are synchronous and blocking, so anything beyond a trivial PDF should run off-request in a queued job. Use a dedicated queue and worker pool for PDF work, since those workers need the binary and Java runtime installed. This keeps general-purpose workers lean and gives you retries, timeouts, and clearer failure handling.
What is the difference between pdftk and pdftk-java, and how do I keep it stable?
The original pdftk is effectively unmaintained, and pdftk-java is the maintained fork that most teams should run. Flag and behavior drift between versions is a real compatibility hazard, so pin the exact binary version in your Docker image and test upgrades against fixture PDFs. Also make sure someone owns patching and CVE response for the binary, not just the Composer package.
What are the alternatives to php-pdftk for Laravel applications?
Pure-PHP options such as FPDI with setasign, Dompdf, or mPDF remove the binary and Java dependency but typically lose fidelity on complex forms, encryption, or repairs. Managed services like Adobe PDF Services or PDF.co remove operational burden but add per-page cost, latency, and data-residency questions. Self-hosted tools such as Stirling PDF are another middle ground worth comparing on total cost.
What license does php-pdftk use, and can I ship pdftk in a container?
The wrapper itself is MIT-licensed, but the pdftk binary is GPL, so licensing needs attention if you redistribute a container or appliance. Invoking it as a separate process is generally acceptable, but have legal review any distribution scenario. You should also confirm whether pdftk-java, rather than original pdftk, is the binary you ship.
Weaver

How can I help you explore Laravel packages today?

Conversation history is not saved when not logged in.
Prompt
Add packages to context
No packages found.
middlewares/firewall
qubiqx/montapacking
nyoncode/laravel-package-console
pnscripts/filament-broadquill-lite
pnscripts/laravel-sentfold-lite
vleap/mx-sdk-laravel-internal
twidpay/utils
htetmyathlaing/scout-elasticsearch-driver
artisan-toolbox/front-awesome
ls/client-assistant
users-au/laravel-client
cgv/localized-resource
noith/settings
kda/laravel-package
kda/filament-dynamic-navigation
bypersoft/signbox
pairus/product-data
fayne/laravel-filament-cms-core
nodisrupt/laravel-agent
sierratecnologia/media-manager