I am using pdf2image to convert pdf to images and detecting tables with table-transformers. I need help with coordinates.
Issue is, I am getting perfect table borders but pixels in images are different from PDF coordinates. Any way to convert image coordinates to PDF coordinates? Here is my code for reference:
from pdf2image import convert_from_path
images = convert_from_path('/content/Sample Statement Format Bancslink.pdf')
for i in range(len(images)):
images[i].save('/content/pages_sbi/page'+str(i)+'.jpeg')
Here is how to use PyMuPDF to transform image coordinates back to PDF page coordinates.
This of course works page by page. So in the following, an image file is assumed to be made from the corresponding page.
Just as an aside, PyMuPDF is also able to render pages to images. So if your table detection mechanism can be invoke page, by page, you could make a loop like this: