Is there a method to convert Page to byte array? #4759
Answered
by
JorjMcKie
erotavlas
asked this question in
Looking for help
-
I see there is a method in Document level to convert the entire PDF document to bytes, however I require to convert to bytes, page by page. Is there a way to do this? |
Beta Was this translation helpful? Give feedback.
Answered by
JorjMcKie
Oct 21, 2025
Replies: 1 comment 1 reply
-
You can split a PDF into single pages, each page becoming a 1-page PDF. import pymupdf
src = pymupdf.open("input.pdf")
for page in src:
doc = pymupdf.open()
doc.insert_pdf(src, from_page=page.number, to_page=page.number)
page_data = doc.to_bytes(<save options>)
doc.close()
# do something here with this 1-page PDF in memory |
Beta Was this translation helpful? Give feedback.
1 reply
Answer selected by
erotavlas
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
You can split a PDF into single pages, each page becoming a 1-page PDF.
You can write those single-page PDFs to memory - as
bytes
objects - as well. In principle like this: