[Python] Can't read PDF Text

Discussão em 'Python' iniciado por Stack, Julho 12, 2025.

  1. Stack

    Stack Membro Participativo

    I'm trying to come up with a nice feature for my work colleagues, that every day in the morning, we would get in Slack the menu of the day... inspired by https://github.com/lemedege/LunchBot/blob/main/run.py

    But I'm struggling to read the text from this PDF

    https://torvekoekken.dk/Files/Files/Branding RAPIDO/01 KBH menu/29_Søborg_Favorit_ENG 2025 ny.pdf

    I saved it as favorite.pdf

    here is a simple test:

    from PyPDF2 import PdfReader

    name = "favorite"
    doc = PdfReader(name+'.pdf')
    print(f"PDF {name} opened, with {len(doc.pages)} pages")
    page = doc.pages[0]
    print(f" text ->{page.extract_text()}<-")
    """ prints:
    PDF favorite opened, with 5 pages
    text -><-
    """


    and it's not because of the first page, all pages outputs empty content

    for page in doc:
    print(f" PDF contains this text ->{page.extract_text()}<-")
    ### prints:
    PDF favorite opened, with 5 pages
    PDF contains this text -><-
    PDF contains this text -><-
    PDF contains this text -><-
    PDF contains this text -><-
    ###


    I even tried with pymupdf as well at no avail

    what am I missing? is it because of the text font they are using?

    Continue reading...

Compartilhe esta Página