Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 1 addition & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
13 changes: 6 additions & 7 deletions docs/document.rst
Original file line number Diff line number Diff line change
Expand Up @@ -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.

Expand Down Expand Up @@ -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".
Expand Down Expand Up @@ -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 <https://github.com/pymupdf/PyMuPDF-Utilities/tree/master/examples/replace-image>`_.


.. method:: ez_save(*args, **kwargs)

* New in v1.18.11
Expand Down
Loading