https://github.com/setasign/fpdi-protection
A FPDI compatible and enhanced version of the FPDF_Protection script.
https://github.com/setasign/fpdi-protection
Last synced: 11 months ago
JSON representation
A FPDI compatible and enhanced version of the FPDF_Protection script.
- Host: GitHub
- URL: https://github.com/setasign/fpdi-protection
- Owner: Setasign
- License: mit
- Created: 2017-09-06T15:26:20.000Z (over 8 years ago)
- Default Branch: master
- Last Pushed: 2024-07-08T14:23:52.000Z (almost 2 years ago)
- Last Synced: 2025-04-03T00:39:03.729Z (about 1 year ago)
- Language: PHP
- Homepage:
- Size: 694 KB
- Stars: 31
- Watchers: 6
- Forks: 13
- Open Issues: 4
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
FpdiProtection
=================================
[](https://packagist.org/packages/setasign/fpdi-protection) [](https://packagist.org/packages/setasign/fpdi-protection) [](https://packagist.org/packages/setasign/fpdi-protection) [](https://packagist.org/packages/setasign/fpdi-protection)
A [FPDI](https://www.setasign.com/fpdi) 2 compatible and enhanced version of the [FPDF_Protection](http://www.fpdf.org/en/script/script37.php) 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](https://packagist.org/packages/setasign/fpdi-protection)
```json
{
"require": {
"setasign/fpdi-protection": "^2.0"
}
}
```
## Manual Installation
If you do not use composer, just require the autoload.php in the /src folder:
```php
require_once('src/autoload.php');
```
If you have a PSR-4 autoloader implemented, just register the src path as follows:
```php
$loader = new \Example\Psr4AutoloaderClass;
$loader->register();
$loader->addNamespace('setasign\FpdiProtection', 'path/to/src/');
```
Don't forget to install [FPDI](https://www.setasign.com/fpdi) and [FPDF](http://www.fpdf.org/), 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](https://www.setasign.com/fpdi) or [FPDF](http://www.fpdf.org/).
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
setProtection(
FpdiProtection::PERM_PRINT | FpdiProtection::PERM_COPY,
'the user password',
'the owner password'
);
// ...
```