pdfProtect

Password-protect the first selected PDF or the first discovered PDF.

Function

pdfProtect(output_file="protected.pdf", password="12345", source=None)

Parameters

output_file

Type: str, default "protected.pdf"

Name of the protected PDF. The file is written inside `protected pdfs/`.

password

Type: str, default "12345"

Password used by pypdf to encrypt the PDF. For production code, provide a stronger password rather than relying on the default.

source

Type: path, iterable of paths, or None

Optional explicit PDF input. Only the first selected PDF is protected.

Returns

A `Path` pointing to the protected PDF, or `None` when no PDFs are found.

Examples

Protect the first discovered PDF

pdfProtect(password="StrongPassword123!")

Protect a merged result

pdfProtect(password="StrongPassword123!", source=pdfMerge())

Dynamic input behavior

When source is omitted, Toolvix discovers matching files in the current working folder. When source is supplied, only the supplied files are processed. This makes nested pipelines deterministic.

Back to function index · Nesting and chaining