-
Notifications
You must be signed in to change notification settings - Fork 680
Description
Description of the bug
Hello,
I am currently using PyMuPDF to crop a small portion from a single-page PDF document and generate a new PDF file with only this selected area. However, I noticed that the file size of the new PDF is the same as the original, despite containing only a fraction of the content.
I was expecting the newly generated PDF to be significantly smaller than the original. Could you please advise on how to achieve this size reduction while retaining the PDF format? Any guidance on optimizing the output file size for cropped PDF documents would be greatly appreciated.
Thank you for your assistance.
How to reproduce the bug
doc = pymupdf.open(input_file_path) new_doc = pymupdf.open() page = doc[1] page_width, page_height = page.rect.width, page.rect.height rect = pymupdf.Rect(0, 0, page_width, 400) o_page = new_doc.new_page(-1, page_width, 400) o_page.show_pdf_page(o_page.rect, doc, 0, clip=rect) new_doc.save('./temp/small.pdf', garbage=4, use_objstms=1, clean=True, deflate=True) new_doc.close() doc.close()
PyMuPDF version
1.24.13
Operating system
MacOS
Python version
3.11