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: 2 additions & 2 deletions changes.txt
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ Other:
* Added support for radio button groups.
* Added support for widget aliases.
* Fixed builds with swig-4.5.
* Fixed `https://bugs.ghostscript.com/show_bug.cgi?id=709683`_ Path Traversal and Arbitrary File Write in PyMuPDF CLI Font Extraction (CVE-2026-82035)
* Fixed `<https://bugs.ghostscript.com/show_bug.cgi?id=709683>`_ Path Traversal and Arbitrary File Write in PyMuPDF CLI Font Extraction (CVE-2026-82035)
* Fixed ignoring aspect ratio for square images.
* Fixed potential SEGV in pymupdf.Page.get_cdrawings() if callback raises exception.
* Fixed use with python-3.15.
Expand Down Expand Up @@ -406,7 +406,7 @@ Other:
* Added miter_limit arg to insert_text*() to allow suppression of spikes caused by long miters.
* Add Widget Support to `Document.insert_pdf()`.
* Add `bibi` to span dicts.
* Add `synthetic' to char dict.
* Add `synthetic` to char dict.
* Fixed Pyodide builds.


Expand Down
8 changes: 8 additions & 0 deletions docs/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,14 @@
# If true, keep warnings as "system message" paragraphs in the built documents.
keep_warnings = False


# https://www.sphinx-doc.org/en/master/usage/configuration.html#confval-suppress_warnings
suppress_warnings = [
'ref.any',
'toc.not_included',
'ref.ref',
]

# Localization vars

gettext_uuid = True
Expand Down
191 changes: 97 additions & 94 deletions docs/document.rst

Large diffs are not rendered by default.

38 changes: 19 additions & 19 deletions docs/font.rst
Original file line number Diff line number Diff line change
Expand Up @@ -43,15 +43,15 @@ A ``Font`` object also contains useful general information, like the font bbox,
.. class:: Font

.. index::
pair: Font, fontfile
pair: Font, fontbuffer
pair: Font, script
pair: Font, ordering
pair: Font, is_bold
pair: Font, is_italic
pair: Font, is_serif
pair: Font, fontname
pair: Font, language
pair: Font; fontfile
pair: Font; fontbuffer
pair: Font; script
pair: Font; ordering
pair: Font; is_bold
pair: Font; is_italic
pair: Font; is_serif
pair: Font; fontname
pair: Font; language

.. method:: __init__(self, fontname=None, fontfile=None,
fontbuffer=None, script=0, language=None, ordering=-1, is_bold=0,
Expand Down Expand Up @@ -132,9 +132,9 @@ A ``Font`` object also contains useful general information, like the font bbox,
=========== =========================== ======= =============================

.. index::
pair: Font.has_glyph, language
pair: Font.has_glyph, script
pair: Font.has_glyph, fallback
pair: Font.has_glyph; language
pair: Font.has_glyph; script
pair: Font.has_glyph; fallback

.. method:: has_glyph(chr, language=None, script=0, fallback=False)

Expand Down Expand Up @@ -183,9 +183,9 @@ A ``Font`` object also contains useful general information, like the font bbox,
.. note:: This method only returns meaningful data for fonts having a CMAP (character map, charmap, the `/ToUnicode` PDF key). Otherwise, this array will have length 1 and contain zero only.

.. index::
pair: Font.glyph_advance, language
pair: Font.glyph_advance, script
pair: Font.glyph_advance, wmode
pair: Font.glyph_advance; language
pair: Font.glyph_advance; script
pair: Font.glyph_advance; wmode

.. method:: glyph_advance(chr, language=None, script=0, wmode=0)

Expand All @@ -211,8 +211,8 @@ A ``Font`` object also contains useful general information, like the font bbox,
True

.. index::
pair: Font.glyph_bbox, language
pair: Font.glyph_bbox, script
pair: Font.glyph_bbox; language
pair: Font.glyph_bbox; script

.. method:: glyph_bbox(chr, language=None, script=0)

Expand All @@ -234,7 +234,7 @@ A ``Font`` object also contains useful general information, like the font bbox,
.. note:: *(Changed in v1.18.0)* This method and :meth:`Font.glyph_name_to_unicode` no longer depend on a font and instead retrieve information from the **Adobe Glyph List**. Also available as `pymupdf.unicode_to_glyph_name()` and resp. `pymupdf.glyph_name_to_unicode()`.

.. index::
pair: text_length, fontsize
pair: text_length; fontsize

.. method:: text_length(text, fontsize=11)

Expand All @@ -258,7 +258,7 @@ A ``Font`` object also contains useful general information, like the font bbox,
For multi-character strings, the method offers a huge performance advantage compared to the previous implementation: instead of about 0.5 microseconds for each character, only 12.5 nanoseconds are required for the second and subsequent ones.

.. index::
pair: char_lengths, fontsize
pair: char_lengths; fontsize

.. method:: char_lengths(text, fontsize=11)

Expand Down
1 change: 1 addition & 0 deletions docs/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,7 @@ This documentation covers all versions up to |version|.
znames.rst

|

----


Expand Down
70 changes: 44 additions & 26 deletions docs/installation.rst
Original file line number Diff line number Diff line change
Expand Up @@ -226,8 +226,8 @@ Notes
Build and install from a local PyMuPDF source tree
---------------------------------------------------------

Initial setup:

Initial setup
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
* Install C/C++ development tools as described above.
* Enter a Python venv and update pip, as described above.

Expand All @@ -241,41 +241,59 @@ Initial setup:
Or download and extract a `.zip` or `.tar.gz` source release from
https://github.com/pymupdf/PyMuPDF/releases.

Then one can build PyMuPDF in two ways:

* Build and install PyMuPDF with default MuPDF version::
pymupdf vs pymupdf-lite
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
The default is to build/install pymupdf-lite. To build/install pymupdf instead:

cd PyMuPDF && pip install .
* Set PYMUPDF_SETUP_PATH_LAYOUT to the absolute path of a local checkout of pymupdf-layout.
* Set PYMUPDF_SETUP_PATH_4LLM to the absolute path of a local checkout of pymupdf4llm.

This will automatically download a specific hard-coded MuPDF source
release, and build it into PyMuPDF.
* For example::

* Or build and install PyMuPDF using a local MuPDF source tree:
git clone https://github.com/ArtifexSoftware/pymupdf_layout.git
git clone https://github.com/pymupdf/pymupdf4llm.git
export PYMUPDF_SETUP_PATH_LAYOUT=`pwd`/pymupdf_layout
export PYMUPDF_SETUP_PATH_4LLM=`pwd`/pymupdf4llm


* Clone the MuPDF git repository::
Build/install commands
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

git clone --recursive https://git.ghostscript.com/mupdf.git
To install::

*
Build PyMuPDF, specifying the location of the local MuPDF tree with the
environmental variables `PYMUPDF_SETUP_MUPDF_BUILD`::
pip install ./PyMuPDF

cd PyMuPDF && PYMUPDF_SETUP_MUPDF_BUILD=../mupdf pip install .
To build a wheel::

Also, one can build for different Python versions in the same PyMuPDF tree:
pip wheel ./PyMuPDF

*
PyMuPDF will build for the version of Python that is being used to run
`pip`. To run `pip` with a specific Python version, use `python -m pip`
instead of `pip`.
**Note that one needs to specify `./PyMuPDF` not `PyMuPDF` - the latter will download/install pre-built wheels from pypi.org.**


Variations
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

So for example on Windows one can build different versions with::
Using a specific MuPDF.

cd PyMuPDF && py -3.14 -m pip install .
* By default the build will automatically download a specific hard-coded MuPDF source release,
and build it into pymupdf/pymupdf-lite.

or::
* To instead use a local MuPDF checkout,
set PYMUPDF_SETUP_MUPDF_BUILD to the absolute path of the MuPDF checkout.

cd PyMuPDF && py -3.12-32 -m pip install .

Building for a non-default Python version.

* By default the build will be for `pip`'s Python version.
* To build for a specific Python version, use `python<version> -m pip`.
* For example on Windows::

py -3.14 -m pip install ./PyMuPDF

Or::

py -3.12-32 -m pip install ./PyMuPDF


Running tests
Expand All @@ -290,7 +308,7 @@ suite::


Notes about using a non-default MuPDF
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Using a non-default build of MuPDF by setting environmental variable
`PYMUPDF_SETUP_MUPDF_BUILD` can cause various things to go wrong and so is
Expand Down Expand Up @@ -355,13 +373,13 @@ Enabling Integrated OCR Support
Enabling integrated OCR support requires installing at least one OCR engine, such as RapidOCR or Tesseract. See also: :ref:`OCR Engine Comparison <ocr-engine-comparison>`.

RapidOCR
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

See the instructions on the `RapidOCR GitHub repository <https://github.com/RapidAI/RapidOCR>`_.


Tesseract
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

PyMuPDF already contains the Tesseract engine to support OCR functions. All it is missing is the `Language Support Data <https://github.com/tesseract-ocr/tessdata>`_ that will be taken from the system installation of Tesseract.

Expand Down
2 changes: 0 additions & 2 deletions docs/page.rst
Original file line number Diff line number Diff line change
Expand Up @@ -296,7 +296,6 @@ In a nutshell, this is what you can do with PyMuPDF:
:rtype: :ref:`Annot`
:returns: the created annotation. It is drawn with line (stroke) color red = (1, 0, 0), line width 1, fill color is supported.

---------

Redactions
~~~~~~~~~~~
Expand Down Expand Up @@ -376,7 +375,6 @@ In a nutshell, this is what you can do with PyMuPDF:

|history_end|

---------

.. method:: add_polyline_annot(points)

Expand Down
2 changes: 1 addition & 1 deletion docs/pymupdf-office/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
</script>

PyMuPDF Office
=============
==============

Enhance |PyMuPDF| capability with **Office** document support.

Expand Down
4 changes: 3 additions & 1 deletion docs/resources.rst
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ For **Office** file support `try PyMuPDF Office <pymupdf-office>`.


|

----


Expand All @@ -22,6 +23,7 @@ Find out about **PyMuPDF Utilities**
The :title:`GitHub` repository `PyMuPDF-Utilities <https://github.com/pymupdf/PyMuPDF-Utilities>`_ contains a full range of examples, demonstrations and use cases.

|

----


Expand All @@ -36,4 +38,4 @@ We recommend the pdf2docx_ library which uses |PyMuPDF| and the **python-docx**



.. include:: footer.rst
.. include:: footer.rst
10 changes: 6 additions & 4 deletions docs/story-class.rst
Original file line number Diff line number Diff line change
Expand Up @@ -167,8 +167,9 @@ Story

* position:
An `ElementPosition` with an extra `.page_num` member.
Typically called multiple times as we generate elements that
are headings or have an id.

Typically called multiple times as we generate elements that
are headings or have an id.
:arg pagefn:
None, or a callable taking `(page_num, mediabox, dev, after)`;
called at start (`after=0`) and end (`after=1`) of each page.
Expand Down Expand Up @@ -213,8 +214,9 @@ Story
If true, we add unique ids to all header tags that
don't already have an id. This can help automatic
generation of tables of contents.
Returns:
None.

Returns:
None.

.. method:: write_with_links(rectfn, positionfn=None, pagefn=None)

Expand Down
28 changes: 14 additions & 14 deletions docs/tools.rst
Original file line number Diff line number Diff line change
Expand Up @@ -135,31 +135,31 @@ This class is a collection of utility methods and attributes, mainly around memo
Control whether MuPDF errors should be displayed as |PyMuPDF| messages.

:arg value:
* If `None`, the current setting is left unchanged.
* Otherwise changes the current setting to `bool(value)`;
if ``True``, future MuPDF errors will be shown as :ref:`Messages`.
* Regardless of this setting, MuPDF errors will always be stored in the warnings store.
* Upon import of |PyMuPDF| this value is ``True``.
* If `None`, the current setting is left unchanged.
* Otherwise changes the current setting to `bool(value)`;
if ``True``, future MuPDF errors will be shown as :ref:`Messages`.
* Regardless of this setting, MuPDF errors will always be stored in the warnings store.
* Upon import of |PyMuPDF| this value is ``True``.

:returns: The current setting as ``True`` or ``False``.
:returns: The current setting as ``True`` or ``False``.

* New in version 1.16.8
* New in version 1.16.8


.. method:: mupdf_display_warnings(value=None)

Control whether MuPDF warnings should be displayed as |PyMuPDF| messages.

:arg value:
* If `None`, the current setting is left unchanged.
* Otherwise changes the current setting to `bool(value)`;
if ``True``, future MuPDF warnings will be shown as :ref:`Messages`.
* Regardless of this setting, MuPDF warnings will always be stored in the warnings store.
* Upon import of |PyMuPDF| this value is ``True``.
* If `None`, the current setting is left unchanged.
* Otherwise changes the current setting to `bool(value)`;
if ``True``, future MuPDF warnings will be shown as :ref:`Messages`.
* Regardless of this setting, MuPDF warnings will always be stored in the warnings store.
* Upon import of |PyMuPDF| this value is ``True``.

:returns: The current setting as ``True`` or ``False``.
:returns: The current setting as ``True`` or ``False``.

* New in version 1.16.8
* New in version 1.16.8


.. method:: mupdf_warnings(reset=True)
Expand Down
6 changes: 3 additions & 3 deletions docs/widget.rst
Original file line number Diff line number Diff line change
Expand Up @@ -204,11 +204,11 @@ Like annotations, widgets also lose connection to their page when the page becom
.. note::

1. For **adding** or **changing** one of the above scripts,
just put the appropriate JavaScript source code in the widget attribute.
To **remove** a script, set the respective attribute to ``None``.
just put the appropriate JavaScript source code in the widget attribute.
To **remove** a script, set the respective attribute to ``None``.

2. Button fields only support :attr:`script`.
Other script entries will automatically be set to ``None``.
Other script entries will automatically be set to ``None``.

3. It is worthwhile to look at
`this <https://experienceleague.adobe.com/docs/experience-manager-learn/assets/FormsAPIReference.pdf?lang=en>`_
Expand Down
3 changes: 3 additions & 0 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -944,6 +944,8 @@ def int_or_0(text):
# Add single README file.
ret.append( (f'{g_root}/README.md', '$dist-info/README.md') )

ret.append( (f'{g_root}/COPYING', '$dist-info/licenses/GNU_AFFERO_GPL_3.0.txt') )

return ret


Expand Down Expand Up @@ -1489,6 +1491,7 @@ def platform_release_tuple():
requires_dist = g_requires_dist,
requires_python = '>=3.11',
license = 'Dual Licensed - GNU AFFERO GPL 3.0 or Artifex Commercial License',
#license_expression = 'AGPL-3.0-only OR LicenseRef-Artifex-Commercial-License',
project_url = [
('Documentation, https://pymupdf.readthedocs.io/'),
('Source, https://github.com/pymupdf/pymupdf'),
Expand Down
Loading