Example #1
0
$doc->SetSecurityHandler($new_handler);
// Save the changes.
echo "Saving modified file...\n";
$doc->Save($output_path . "secured.pdf", 0);
$doc->Close();
// Example 2:
// Opens an encrypted PDF document and removes its security.
$doc = new PDFDoc($output_path . "secured.pdf");
//If the document is encrypted prompt for the password
if (!$doc->InitSecurityHandler()) {
    $success = false;
    echo "The password is: test\n";
    for ($count = 0; $count < 3; $count++) {
        echo "A password required to open the document.\n" . "Please enter the password:"******"The password is correct.\n";
            break;
        } else {
            if ($count < 3) {
                echo "The password is incorrect, please try again\n";
            }
        }
    }
    if (!$success) {
        echo "Document authentication error....\n";
        PDFNet::Terminate();
        return;
    }
    $hdlr = $doc->GetSecurityHandler();