From 74c3d4ce785cc0f0678177ae1b295a9863cbc717 Mon Sep 17 00:00:00 2001 From: Julian Smith Date: Fri, 26 Jun 2026 04:52:14 +0100 Subject: [PATCH 1/3] docs/document.rst: document that save() now also works for non-pdf documents. --- docs/document.rst | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/docs/document.rst b/docs/document.rst index 0ea00e760..8435ff11a 100644 --- a/docs/document.rst +++ b/docs/document.rst @@ -1285,12 +1285,10 @@ For details on **embedded files** refer to Appendix 3. .. method:: save(outfile, garbage=0, clean=False, deflate=False, deflate_images=False, deflate_fonts=False, incremental=False, ascii=False, expand=0, linear=False, pretty=False, no_new_id=False, encryption=PDF_ENCRYPT_NONE, permissions=-1, owner_pw=None, user_pw=None, use_objstms=0, compression_effort=0, raise_on_repair=False) - * Changed in v1.18.7 - * Changed in v1.19.0 - * Changed in v1.24.1 - - PDF only: Saves the document in its **current state**. - + PDF documents are saved in their **current state**. + + Non-PDF documents are saved in PDF format. *(new in v1.28.0)* + :arg str,Path,fp outfile: The file path, `pathlib.Path` or file object to save to. A file object must have been created before via `open(...)` or `io.BytesIO()`. Choosing `io.BytesIO()` is similar to :meth:`Document.tobytes` below, which equals the `getvalue()` output of an internally created `io.BytesIO()`. :arg int garbage: Do garbage collection. Positive values exclude "incremental". @@ -1356,6 +1354,7 @@ For details on **embedded files** refer to Appendix 3. 2. "Lossy" file size reduction in essence must give up something with respect to images, like (a) remove all images (b) replace images by their grayscale versions (c) reduce image resolutions. Find examples in the `PyMuPDF Utilities "replace-image" folder `_. + .. method:: ez_save(*args, **kwargs) * New in v1.18.11 From 819f38bff9dc8c4cf86ee3fcdefa310ce515df28 Mon Sep 17 00:00:00 2001 From: Julian Smith Date: Fri, 26 Jun 2026 04:54:44 +0100 Subject: [PATCH 2/3] README.md: updated example conversion from md to pdf. --- README.md | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/README.md b/README.md index 64c669406..ecd7abab4 100644 --- a/README.md +++ b/README.md @@ -177,9 +177,7 @@ print(text) import pymupdf md_doc = pymupdf.open("example.md") -pdfdata = md_doc.convert_to_pdf() -pdf_doc = pymupdf.open(stream=pdfdata) -pdf_doc.save("example.pdf") +md_doc.save("example.pdf") ``` ### Convert to Markdown for LLMs From 3fa20631eb9b399230d5dd513b5c6d04eb272ea0 Mon Sep 17 00:00:00 2001 From: Julian Smith Date: Fri, 26 Jun 2026 05:05:24 +0100 Subject: [PATCH 3/3] docs/document.rst: add new in 1.28.0 to __init__'s archive. --- docs/document.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/document.rst b/docs/document.rst index 8435ff11a..7130345e2 100644 --- a/docs/document.rst +++ b/docs/document.rst @@ -184,7 +184,7 @@ For details on **embedded files** refer to Appendix 3. :arg str filetype: A string specifying the type of document. This is only ever needed when file content inspection fails. Text types like "txt", "html", "xml" etc. cannot be disambiguated by their content. When such files are provided in memory or being provided with the wrong file extension, this parameter **must** be used. - :arg Archive archive: An optional :ref:`Archive` object to use as a source for resources like fonts and images. + :arg Archive archive: An optional :ref:`Archive` object to use as a source for resources like fonts and images. *(new in v1.28.0)* :arg rect_like rect: A rectangle specifying the desired page size. This parameter is only meaningful for documents with a variable page layout ("reflowable" documents), like e-books, MD or HTML, and ignored otherwise. If specified, it must be a non-empty, finite rectangle with top-left coordinates (0, 0). Together with parameter :data:`fontsize`, each page will be accordingly laid out and hence also determine the number of pages.