def breakPassword(filename): """Breaks a single word password of a PDF Args: filename (str): Filename for encrypted pdf Returns: None """ encryptedFile = open(filename, 'rb') pdfReader = PyPDF2.PdfFileReader(encryptedFile) with open('dictionary.txt') as words: wordList = words.read().split('\n') for word in wordList: wordLower = word.lower() wordCap = word.capitalize() if crypt(word): return word elif crypt(wordCap): return wordCap elif crypt(wordLower): return wordLower return.ħ. Project: automate-the-boring-stuff-projects Author: kudeh File: passwordBreaker.py License: MIT License. def encryptPDFs(root, password): """Encrypts all pdfs folder walk Args: root (str): folder path to walk password (str): password to encrypt pdfs with Returns: None """ for folder, subfolder, fileList in os.walk(root): for file in fileList: if file.endswith('.pdf'): filepath = os.path.join(os.path.abspath(folder), file) pdfFileObj = open(filepath, 'rb') pdfReader = PyPDF2.PdfFileReader(pdfFileObj) if not pdfReader.isEncrypted: pdfWriter = PyPDF2.PdfFileWriter() for pageNum in range(pdfReader.numPages): pdfWriter.addPage(pdfReader.getPage(pageNum)) pdfWriter.encrypt(password) newPath = os.path.dirname(filepath) + '/untitled folder/' + \ ('_encrypted.'.Ħ. Project: automate-the-boring-stuff-projects Author: kudeh File: pdfParanoia.py License: MIT License. Project: insightconnect-plugins Author: rapid7 File: action.py License: MIT License. def pdf_date(path): """ Extract a date from PDF file metadata.ģ.
Project: open-syllabus-project Author: davidmcclure File: utils.py License: Apache License 2.0.
def pdf_meta(tmp_file_path, original_file_name, original_file_extension): doc_info = None if use_pdf_meta: doc_info = PdfFileReader(open(tmp_file_path, 'rb')).getDocumentInfo() if doc_info: author = doc_thor if doc_thor else u'Unknown' title = doc_info.title if doc_info.title else original_file_name subject = doc_info.subject else: author = u'Unknown' title = original_file_name subject = "" return BookMeta( file_path=tmp_file_path, extension=original_file_extension, title=title, author=author, cover=pdf_preview(tmp_file_path, original_file_name), description=subject, tags="", series="", series_id="", languages="")Ģ. Project: calibre-web Author: janeczku File: uploader.py License: GNU General Public License v3.0.