[Python] Why do I get 'PdfReadError: EOF marker not found'?

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

  1. Stack

    Stack Membro Participativo

    I am downloading multiple PDFs. I have a list of urls and the code is written to download them and also create one big pdf with them all in. The code works for the first 144 pdfs then it throws this error:


    PdfReadError: EOF marker not found
    ​

    I've tried making all the pdfs end in %%EOF but that doesn't work - it still reaches the same point then I get the error again.

    Here's my code:

    my file and converting to list for python to read each separately


    with open('minutelinks.txt', 'r') as file:
    data = file.read()
    links = data.split()

    download pdfs


    from PyPDF2 import PdfFileMerger
    import requests
    urls = links

    merger = PdfFileMerger()
    for url in urls:
    response = requests.get(url)
    title = url.split("/")[-1]
    with open(title, 'wb') as f:
    f.write(response.content)
    merger.append(title)

    merger.write("allminues.pdf")
    merger.close()


    I want to be able to download all of them and create one big pdf - which it appears to do until it throws this error. I have about 750 pdfs and it only gets to 144.

    Continue reading...

Compartilhe esta Página