I want to merge two pdf pages to generate a new page. But it works on some pdf files, it will not show text and rectangle (that I want to add to original pdf page) when I passing specific file.
When I am merging pages with test11_issued2.pdf, it works.
But when I am merging pages with test22_issued2.pdf, it failed and don't print any error log.
These two pdf are basically same.
PDF files can be found at this link: https://github.com/fangwangme/pdf-exchanger/tree/main/pdfs
from PyPDF2 import PdfFileWriter, PdfFileReader
output = PdfFileWriter()
input1 = PdfFileReader(open("test11.pdf", "rb"))
page = input1.getPage(0)
#watermark = PdfFileReader(open("test11_issued2.pdf", "rb"))
watermark = PdfFileReader(open("test22_issued2.pdf", "rb"))
watermark_page = watermark.getPage(0)
page.mergePage(watermark_page)
output.addPage(page)
outputStream = open("output.pdf", "wb")
output.write(outputStream)
The text and rectangle are not showing on PDF reader app, but I can read it from below code.
print(page.extractText())
Excepted result should look like as shown in the below picture.
