is ther anyway i can find Coordinates in Python from Objects of the PDF. I want then to Cut the PDf exact above the highest Object and below the lowest Object:
from PyPDF2 import PdfFileWriter, PdfFileReader
with open("in.pdf", "rb") as in_f:
input1 = PdfFileReader(in_f)
output = PdfFileWriter()
numPages = input1.getNumPages()
print ("document has %s pages." % numPages)
for i in range(numPages):
page = input1.getPage(i)
print (page.cropBox.getLowerLeft())
print (page.cropBox.getUpperRight())
page.cropBox.setLowerLeft((0, 500))
page.cropBox.setUpperRight((595.275, 841.889))
output.addPage(page)
with open("out.pdf", "wb") as out_f:
output.write(out_f)
So the Code now vuts something but yeah how do i find out exactly where to Cut! is ther a Methode?
Edit:
@BhavyaParikh.
I want an alogorithem that finds the Y-Coordinates from the highest and the lowest point of any object given in the pdf page. and then cuts at these points instead of the hardcoded values "(0, 500) and (595.275, 841.889)". So for example: "(x1,y1) and (x2,y2). But i dont know how to finde these Coordinates.