PDFUnlocker
Removing the password protection from a PDF file and adding a new file entry with the unlocked PDF.
python · Common Scripts
Source
import demistomock as demisto # noqa: F401 from CommonServerPython import * # noqa: F401 from pikepdf import PasswordError, Pdf def unlock_pdf(args: dict): res = demisto.getFilePath(args.get("entryID")) origin_path = res["path"] output_name = "UNLOCKED_" + res["name"] try: with Pdf.open(origin_path, password=str(args.get("password"))) as unlocked_pdf: unlocked_pdf.save(output_name) return_results(file_result_existing_file(output_name)) except PasswordError: return_error("Incorrect password. Please provide the correct password.") def main(): args = demisto.args() unlock_pdf(args) if __name__ in ("__main__", "__builtin__", "builtins"): main()
README
Removes the password protection from a PDF file and adds a new file entry with the unlocked PDF.
Script Data
| Name | Description |
|---|---|
| Script Type | python |
| Tags | - |
Inputs
| Argument Name | Description |
|---|---|
| entryID | The entry ID with the PDF file. |
| password | The password for the PDF file. |
Outputs
There are no outputs for this script.