Python PyPDF2 — Encrypt a PDF file

Scriptopia
Jan 20, 2023

--

Python script that will encrypt a PDF file. To do this we use PyPDF2 which is a Python library that enables users to perform various operations on PDF documents.

In this example the password for the encrypted file will be set to ‘iamlegend’, if you do use this code as part of your own project be sure to change this something appropriate.

Also be sure to subscribe to our YouTube channel for daily coding content.

https://scriptopia.co.uk/2023/01/20/python-pypdf2-encrypt-a-pdf-file/

--

--

Scriptopia

Programming - Projects - Source Code available for everything - Scriptopia.co.uk