PHP code example of fawno / qpdf
1. Go to this page and download the library: Download fawno/qpdf library. Choose the download type require. 2. Extract the ZIP file and open the index.php. 3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
fawno / qpdf example snippets
Fawno\QPDF\QPDF;
$lib_path = __DIR__ . '/qpdf28.dll';
$qpdf = new QPDF($lib_path);
$filename = __DIR__ . '/encrypted_document.pdf';
$password = 'secret_password';
$qpdf->readFile($filename, $password);
if ($qpdf->hasError()) {
$error = $qpdf->getError();
print_r($error);
die();
}
if ($qpdf->hasWarning()) {
$warning = $qpdf->getWarning();
print_r($warning);
}
$filename = __DIR__ . '/document_without_encrypt.pdf';
$qpdf->initWrite($filename);
if ($qpdf->hasError()) {
$error = $qpdf->getError();
print_r($error);
die();
}
$qpdf->preserveEncryption(false);
$qpdf->write();
if ($qpdf->hasError()) {
$error = $qpdf->getError();
print_r($error);
die();
}
sh
php composer.phar