GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — pdf with password · ackercode/tutorials@caddaa7

File tree

Expand file treeCollapse file tree
Open diff view settings
Filter options
  • python-tutorials
    • pdfpassword.py
Expand file treeCollapse file tree
Open diff view settings
Collapse file

‎python-tutorials/pdfpassword.py‎

Copy file name to clipboard
+25Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
# Antes de mais nada -> pip install pypdf2
2+
3+
from PyPDF2 import PdfFileWriter, PdfFileReader
4+
import sys
5+
6+
def password_pdf(file, password):
7+
parser = PdfFileWriter()
8+
pdf = PdfFileReader(file)
9+
10+
for page in range(pdf.numPages):
11+
parser.addPage(pdf.getPage(page))
12+
13+
parser.encrypt(password)
14+
with open(f"pdf_senha_{file}", "wb") as f:
15+
parser.write(f)
16+
f.close()
17+
print(f"pdf_senha_{file} Criado")
18+
19+
if __name__ == "__main__":
20+
file = sys.argv[1]
21+
password = sys.argv[2]
22+
password_pdf(file, password)
23+
24+
# Primeiro chamamos a funcao que voce criou depois o nome do pdf depois a senha que voce quer colocar
25+
# Chamando no terminal python3 pdfpassword.py teste.pdf 123456

0 commit comments

Comments
0 (0)
You are visitor 01402520 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.