4LLM

PyMuPDF4LLM
now ships with Layout.

TRY DEMO
Get Started with PyMuPDF

Get Started with PyMuPDF

Install with one simple command.

Quick Example

123456789
import pymupdf

doc = pymupdf.open("a.pdf") # open a document
out = open("output.txt", "wb") # create a text output
for page in doc: # iterate the document pages
    text = page.get_text().encode("utf8") # get plain text (is in UTF-8)
    out.write(text) # write text of page
    out.write(bytes((12,))) # write page delimiter (form feed 0x0C)
out.close()
PyMuPDF Logo

© 2026 Artifex Software Inc. All rights reserved.