put a white rectangle in a pdf
by Pedroski from LinuxQuestions.org on (#50FYA)
The gf has a lot of old exams to scan in and put online for her boss.
The exams are printed of long funny size sheets, each page is 19.5cm by 27cm, but the sheet is 4 pages on one long sheet, printed front and back.
So, one long sheet is 27cm by 78cm, printed back and front.
We cut them up so each page is 19.5cm by 27cm.
Then I use my trusty Epson DS-510 batch scanner to scan the odd pages, the front of each page, into a pdf and the even pages, the back of each page, into a pdf.
I made a Python program to merge the odd and even pdfs, works great!
My little program first splits the odd and even pdfs, then merges them.
Now her boss asked if we could get rid of the exam identifier at the top of page 1.
The id is something like: C041-00531i1/4aai1/4in large letters at the top of page 1.
So I need to paste a white rectangle over it.
If the rectangle is 1cm high and 8cm wide, with its top and left side positioned respectively 2cm from the top of the page and 4.5cm from the left of the page, it will cover it nicely.
I use PyPDF2 to read and write the pdfs.
Before I merge the pdfs, I have to split the odd and even pdfs into 1 page pdfs. At that point I can access page 1 easily.
How can I automate placing a white rectangle on a page?
Thanks in advance for any tips or links!


The exams are printed of long funny size sheets, each page is 19.5cm by 27cm, but the sheet is 4 pages on one long sheet, printed front and back.
So, one long sheet is 27cm by 78cm, printed back and front.
We cut them up so each page is 19.5cm by 27cm.
Then I use my trusty Epson DS-510 batch scanner to scan the odd pages, the front of each page, into a pdf and the even pages, the back of each page, into a pdf.
I made a Python program to merge the odd and even pdfs, works great!
My little program first splits the odd and even pdfs, then merges them.
Now her boss asked if we could get rid of the exam identifier at the top of page 1.
The id is something like: C041-00531i1/4aai1/4in large letters at the top of page 1.
So I need to paste a white rectangle over it.
If the rectangle is 1cm high and 8cm wide, with its top and left side positioned respectively 2cm from the top of the page and 4.5cm from the left of the page, it will cover it nicely.
I use PyPDF2 to read and write the pdfs.
Before I merge the pdfs, I have to split the odd and even pdfs into 1 page pdfs. At that point I can access page 1 easily.
How can I automate placing a white rectangle on a page?
Thanks in advance for any tips or links!