Untitled
unknown
abc
2 years ago
340 B
7
Indexable
from pypdf import PdfReader, PdfWriter
reader = PdfReader("1.pdf")
writer = PdfWriter()
# Add all pages to the writer
for page in reader.pages:
writer.add_page(page)
# Add a password to the new PDF
writer.encrypt("123", algorithm="AES-256")
# Save the new PDF to a file
with open("encrypted-pdf.pdf", "wb") as f:
writer.write(f)Editor is loading...