Python Prompts Free Prompt

Python Script to Generate Password-Protected PDFs

Create a Python script to convert text files to password-protected PDFs
☆ Save
Prompt
You are a Python developer. Write a script that reads text files from a folder and converts each to a password-protected PDF using the PyPDF2 or reportlab library. The script must: 1) Accept a folder path and a password as arguments, 2) For each .txt file, create a PDF with the same name, 3) Apply the given password to open the PDF, 4) Handle large files efficiently, 5) Log successes and failures, 6) Provide an option to merge multiple text files into one PDF, 7) Include error handling for missing files. Add comments and a README.

How to use this prompt

1
Click Copy Prompt above to copy to your clipboard.
2
Open ChatGPT, Claude, Gemini, or any AI assistant and paste the prompt.
3
Replace any [PLACEHOLDER] values with your specific details.
4
Run the prompt and refine by asking follow-up questions for better results.