Error: FloatObject (b'0.000000000000-14210855') invalid; use 0.0 instead while using PyPDF2

I am using function to count occurrences of given word in pdf using PyPDF2. While the function is running I get message in terminal: FloatObject (b’0.000000000000-14210855′) invalid; use 0.0 instead My code: def count_words(word): print() print(‘Counting words..’) files = os.listdir(‘./pdfs’) counted_words = [] for idx, file in enumerate(files, 1): with open(f’./pdfs/{file}’, ‘rb’) as pdf_file: ReadPDF… Read More Error: FloatObject (b'0.000000000000-14210855') invalid; use 0.0 instead while using PyPDF2

How to overwrite specific page of PDF with another page of another PDF with Python's PyPDF2

I want to overwrite the first page of a PDF with another page of another PDF using the PyPDF2 library in Python. For more detail, I have two separate PDFs (let’s call them overwritten.pdf and other.pdf) and I want to replace the first (it doesn’t have to be the first) page of overwritten.pdf with a… Read More How to overwrite specific page of PDF with another page of another PDF with Python's PyPDF2

Split pfd based off value and Merge dictionaries inside list in python

I want to split a pdf based off a value on every page. Every value should be in its own pdf file. I currently have the following list where all values with the pages are displayed: l = [ {‘abr’: ‘123 ‘, ‘page’: 1}, {‘abr’: ‘125 ‘, ‘page’: 2}, {‘abr’: ‘125 ‘, ‘page’: 3}, {‘abr’:… Read More Split pfd based off value and Merge dictionaries inside list in python

How do I change the save location of an altered PDF using PyPDF2

I need to change the location that the output file is saved. Currently the save location is wherever the application is located. I would like to change it to the user’s desktop. Any help would be appreciated. filename = askopenfilename() packet.seek(0) new_pdf = PdfFileReader(packet) existing_pdf = PdfFileReader(open(filename, "rb")) output = PdfFileWriter() page = existing_pdf.getPage(0) page.mergePage(new_pdf.getPage(0))… Read More How do I change the save location of an altered PDF using PyPDF2

Extract values by key from a nested dictionary based on specific values

I have a nested dictionary which has been extracted from a PDF userform using the PyPDF2 library. form_dict = {‘Apple’: {‘/FT’: ‘/Btn’, ‘/T’: ‘Apple’}, ‘Banana’: {‘/FT’: ‘/Btn’, ‘/T’: ‘Banana’, ‘/V’: ‘/Yes’}, ‘Grape’: {‘/FT’: ‘/Btn’, ‘/T’: ‘Grape’, ‘/V’: ‘/Yes’} } I want to create a list of the outer keys for which the value against the… Read More Extract values by key from a nested dictionary based on specific values

PyPDF2.PdfFileMerger only writes first pdf

I have several Pdfs that I want to merge together. To do this I referenced this https://pythonhosted.org/PyPDF2/PdfFileMerger.html#PyPDF2.PdfFileMerger.write Documentation as well as this Merge PDF files post as reference. My code reads from the the directory where my pdfs lie and tries to write the new pdf into another directory def concatenate_pdfs(path_to_pdf_dir, output_dir): """merge all the… Read More PyPDF2.PdfFileMerger only writes first pdf

How to print out a value in a dictionary then values is a list?

Area of coding: PDF Table of Contents in python3 using pyPDF2 Problem: I need a program that can iterate through a union variable that contains multiple dictionarys, then multiple lists which contains multiple dictionarys. {} [{},[{},{},{}],{},[{},{},{}],{},[{},{},{}]] This pattern repeats multiple times. Expected output: The output should look like this 1 Title Goes Here 1.1 Title… Read More How to print out a value in a dictionary then values is a list?