We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 56b6289 commit 5041815Copy full SHA for 5041815
ch13-interact-with-pdf-files/5-encrypting-and-decrypting-pdfs.py
@@ -27,3 +27,19 @@
27
output_path = Path.home() / "top_secret_encrypted.pdf"
28
with output_path.open(mode="wb") as output_file:
29
pdf_writer.write(output_file)
30
+
31
32
+# ***********
33
+# Exercise 2
34
+#
35
+# Open the `top_secret_encrpyted.pdf` file you created in exercise 1,
36
+# decrypt it, and print the text on the first page of the PDF.
37
38
39
+pdf_path = Path.home() / "top_secret_encrypted.pdf"
40
+pdf_reader = PdfFileReader(str(pdf_path))
41
42
+pdf_reader.decrypt("Unguessable")
43
44
+first_page = pdf_reader.getPage(0)
45
+print(first_page.extractText())
0 commit comments