pythonpdf-generationpisaxhtml2pdf

password protect pdf files created using pisa


I'm converting a html file into pdf using python pisa module. I need to password protect it. I searched everywhere in pisa module and couldn't find a solution for it. Is there anyway to password protect it using python?

The constraint is I want keep my file in html format. On demand basis, I want to convert it into pdf file and password protect it. I don't want to use reportlab module.


Solution

  • You can with pyPdf which is optional for pisa but has an encryption method:

    A Pure-Python library built as a PDF toolkit. It is capable of:

    extracting document information (title, author, ...), splitting documents page by page, merging documents page by page, cropping pages, merging multiple pages into a single page, encrypting and decrypting PDF files.