Category "pypdf2"

error: Unable to find trailer dictionary while recovering damaged file

PyPDF2 fail sometimes with decryption of some PDF files, and I am trying do decrypt them with pikepdf but I am getting this error: Unable to find trailer dictio

Fill PDF form values using PyPDF2 multiple pages but getting same and duplicate data on all pages of pdf

I have used this below code. from PyPDF2 import PdfFileWriter, PdfFileReader from PyPDF2.generic import BooleanObject, NameObject, IndirectObject def set_need

Change metadata of pdf file with pypdf2

I want to add a metadata key-value pair to the metadata of a pdf file. I found a several years old answer, but I think this is way to complicated. I guess ther

Merging multiple PDFs at specified pages

I am trying to use Python to merge multiple PDFs at specific pages I want. So for instance, let's say we have 3 pdfs and I want to merge the second one at page

PyPDF2.PdfFileWriter addAttachment not working

Based on https://programtalk.com/python-examples/PyPDF2.PdfFileWriter/, example 2, I try to to add an attachment into a PDF file. Here is my code I am trying to

Reading a pdf from a zipfile

I'm trying to get PyPDF2 to read a small .pdf file that is within a simple zip file. Here's what I've got so far: import PyPDF2,zipfile with zipfile.ZipFile("T

PyPDF2 PdfFileWriter has no attribute stream

I am trying to split a pdf into its pages and save each page as a new pdf. I have tried this method from a previous question with no success and the pypdf2 spli

Detect and crop a box in .pdf or image as individual images

I have a multi-page .pdf (scanned images) containing handwriting I would like to crop and store as new separate images. For example, in the visual below I would

Duplicating PDF with PyPDF2 gives blank pages

I'm using PyPDF2 to alter a PDF document (adding bookmarks). So I need to read in the entire source PDF, and write it out, keeping as much of the data intact as

PyPDF2 extract empty Text

I am using PyPDF2 for extract text from pdf. All examples which I found in the google look like my code: import PyPDF2 reader = PyPDF2.PdfFileReader("test2.pd

convert from pdf to text: lines and words are broken

I want to convert a pdf file to text by PyPDF2 but converted text looks differents from PDF file. Specifically, one line in PDF is broken into multiple lines in

Add a bookmark to a PDF with PyPDF2

I'm trying to add a bookmark to a PDF using PyPDF2. I run the following with no problems. But a bookmark is never created. Any thoughts on what I'm doing wrong.

Read all bookmarks from a PDF document and create a dictionary with PageNumber and Title of the bookmark

I a trying to read a PDF document using Python with PyPDF2 package. The objective is to read all the bookmarks in the pdf and construct a dictionary with page n

Why does PyPDF2.PdfFileWriter forget changes I made to a document?

I am trying to modify text in a PDF file. The text can be in an object of type Tj or BDC. I find the correct objects and if I read them directly after changing

Edit text in PDF with python

I have a pdf file and I need to edit some text/values in the pdf. For example, in the pdfs that I have "BIRTHDAY DD/MM/YYYY" is always "N/A". I want to change i

only algorithm code 1 and 2 are supported

I would like to read the pdf file. This is a book.pdf with a password (256 bit AES encryption). I know a password. I am using Jupyter Notebook. I get an error:

Select only first page of PDF with PyPDF2

I am trying to strip out only the first page of multiple PDF files and combine into one file. (I receive 150 PDF files a day, the first page is the invoice whic

How to add watermark in all pages of PDF files with python?

I'm try to adding watermark to every pages of my PDF file.My PDF files have 58 pages but my output file has get only last page in my PDF file. This's my code:

How to extract text from a Specific Area in a PDF using Python?

I'm trying to extract Text from a PDF using Python, and I have successfully done so using PyPDF2 like this: from PyPDF2 import PdfFileReader reader = PdfFileRea

Concatenating PDF files in memory with PyPDF2

I wish to concatenate (append) a bunch of small pdfs together effectively in memory in pure python. Specifically, an usual case is 500 single page pdfs, each wi