Download the PHP package indzz/pdfprotect without Composer
On this page you can find all versions of the php package indzz/pdfprotect. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download indzz/pdfprotect
More information about indzz/pdfprotect
Files in indzz/pdfprotect
Package pdfprotect
Short Description A library to add password protection to an existing PDF file
License MIT
Informations about the package pdfprotect
PDF Protection
This is a PHP wrapper library to add password encryption to an existing PDF file.
Driver 1 - FPDI
The first solution requires PHP only.
It uses FPDI to import all pages of the source PDF and add each page to a new file. Then, it outputs the file binary as a response.
Advantage:
- PHP Only, no extra library needed
Disadvantage:
- PDF version 1.5 or above is not supported, due to the limitation of the free PDF parser
Please be reminded to add the following packages to composer.json before you use this driver:
Driver 2 - QPDF
The second solution uses QPDF, which is a command line program. The solution simply calls shell_exec
to execute QPDF and add the password.
Advantage:
- Simple
- Supports PDF version 1.5
Disadvantage:
- Requires extra library installed on the system
For macOS, you may install QPDF with Homebrew:
For Ubuntu, you may install with apt:
If you are using other Linux distribution, please refer to the corresponding package repository.
Example
The simplest usage is:
See example
folder for more details
- Directly output to web browser - 1-output.pdf
- Save to a path on the server-side - 2-save.pdf
- Return a Symfony HTTP Foundation Response object - 3-response.pdf
License
This library is open-sourced under the MIT license.
Please also refer to the license of the