[Python] Get bounding box of all the articles in a newspaper PDF file

Discussão em 'Python' iniciado por Stack, Agosto 3, 2025.

  1. Stack

    Stack Membro Participativo

    I am trying to get the bounding box of all the articles in a newspaper pdf page using pdfplumber. However it is not marking all the articles. I am using the code below.

    import pdfplumber
    pdf = pdfplumber.open("2.pdf")
    p0 = pdf.pages[0]
    im = p0.to_image(resolution=150)


    table_settings = {
    "snap_y_tolerance": 0,
    "intersection_x_tolerance": 50,
    }
    im.debug_tablefinder(table_settings)
    tables = p0.find_tables(table_settings)
    im.show()


    Link to processed Image

    However, the it is not marking all articles as shown in image attached. I think the tables approach was the quickest and shortest way, but it works for well organised tables. I think this strategy is not suitable for newspaper articles. Any other suggestions or improvements in code will be appreciated.

    Continue reading...

Compartilhe esta Página