setasign / fpdi-protection
A FPDI compatible version of the FPDF_Protection script.
Installs: 3 960 595
Dependents: 2
Suggesters: 0
Security: 0
Stars: 31
Watchers: 7
Forks: 13
Open Issues: 4
Requires
- php: ^5.6 || ^7.0 || ^8.0 || ^8.1 || ^8.2
- ext-openssl: *
- setasign/fpdf: ^1.8.5
- setasign/fpdi: ^2.3.6
Requires (Dev)
- phpunit/phpunit: ~5.7
This package is auto-updated.
Last update: 2024-12-08 15:18:18 UTC
README
A FPDI 2 compatible and enhanced version of the FPDF_Protection script.
This version requires and uses OpenSSL functions instead of Mcrypt or a user land implementation of RC4.
RC4-40bits and RC4-128bits encryption are supported.
Installation with Composer
{ "require": { "setasign/fpdi-protection": "^2.0" } }
Manual Installation
If you do not use composer, just require the autoload.php in the /src folder:
require_once('src/autoload.php');
If you have a PSR-4 autoloader implemented, just register the src path as follows:
$loader = new \Example\Psr4AutoloaderClass; $loader->register(); $loader->addNamespace('setasign\FpdiProtection', 'path/to/src/');
Don't forget to install FPDI and FPDF, too!
Example
This class offers one public method, which allows you to set the protection of the resulting PDF document. All other code is identically to FPDI or FPDF.
If you pass null or an empty string as the owner password the method will create a random owner password. The return value of this method is the owner password.
<?php use setasign\FpdiProtection\FpdiProtection; // setup the autoload function require_once('vendor/autoload.php'); $pdf = new FpdiProtection(); $ownerPassword = $pdf->setProtection( FpdiProtection::PERM_PRINT | FpdiProtection::PERM_COPY, 'the user password', 'the owner password' ); // ...