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(); echo "Document Open Password: "******"\n"; echo "Permissions Password: "******"\n"; echo "Permissions: " . "\n\tHas 'owner' permissions: " . $hdlr->GetPermission(SecurityHandler::e_owner) . "\n\tOpen and decrypt the document: " . $hdlr->GetPermission(SecurityHandler::e_doc_open) . "\n\tAllow content extraction: " . $hdlr->GetPermission(SecurityHandler::e_extract_content) . "\n\tAllow full document editing: " . $hdlr->GetPermission(SecurityHandler::e_doc_modify) . "\n\tAllow printing: " . $hdlr->GetPermission(SecurityHandler::e_print) . "\n\tAllow high resolution printing: " . $hdlr->GetPermission(SecurityHandler::e_print_high) . "\n\tAllow annotation editing: " . $hdlr->GetPermission(SecurityHandler::e_mod_annot) . "\n\tAllow form fill: " . $hdlr->GetPermission(SecurityHandler::e_fill_forms) . "\n\tAllow content extraction for accessibility: " . $hdlr->GetPermission(SecurityHandler::e_access_support) . "\n\tAllow document assembly: " . $hdlr->GetPermission(SecurityHandler::e_assemble_doc) . "\n"; } // remove all security on the document $doc->RemoveSecurity(); $doc->Save($output_path . "not_secured.pdf", 0); $doc->Close(); echo "Test Completed.\n";