You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Summary: PyMuPDF is a Python binding for the PDF rendering library MuPDF
11
11
Description:
12
-
Release date: November 30, 2020
12
+
Release date: December 20, 2020
13
13
14
14
Authors
15
15
=======
@@ -20,13 +20,13 @@ Description:
20
20
Introduction
21
21
============
22
22
23
-
This is **version 1.18.4 of PyMuPDF**, a Python binding for `MuPDF <http://mupdf.com/>`_ - "a lightweight PDF and XPS viewer".
23
+
This is **version 1.18.5 of PyMuPDF**, a Python binding for `MuPDF <http://mupdf.com/>`_ - "a lightweight PDF and XPS viewer".
24
24
25
25
MuPDF can access files in PDF, XPS, OpenXPS, epub, comic and fiction book formats, and it is known for both, its top performance and high rendering quality.
26
26
27
27
With PyMuPDF you therefore can access files with extensions ``*.pdf``, ``*.xps``, ``*.oxps``, ``*.epub``, ``*.cbz`` or ``*.fb2`` from your Python scripts. A number of popular image formats is supported as well, including multi-page TIFF images.
28
28
29
-
PyMuPDF should run on all platforms that are supported by both, MuPDF and Python. These include, but are not limited to, Windows (XP/SP2 and up), Mac OSX and Linux, 32-bit or 64-bit. If you can generate MuPDF on a Python supported platform, then also PyMuPDF can be used there.
29
+
PyMuPDF should run on all platforms that are supported by both, MuPDF and Python 3.6+. These include, but are not limited to, Windows, Mac OSX and Linux, 32-bit or 64-bit. If you can generate MuPDF on a Python supported platform, then also PyMuPDF can be used there.
30
30
31
31
PyMuPDF is hosted on `GitHub <https://github.com/pymupdf/PyMuPDF>`_ where you find up-to-date information of its features, our `issue tracker <https://github.com/pymupdf/PyMuPDF/issues>`_, `Wikis <https://github.com/pymupdf/PyMuPDF/wiki>`_ and much more.
32
32
@@ -66,6 +66,5 @@ Classifier: Operating System :: MacOS
66
66
Classifier: Operating System :: Microsoft :: Windows
@@ -15,7 +15,7 @@ On **[PyPI](https://pypi.org/project/PyMuPDF)** since August 2016: [ - "a lightweight PDF, XPS, and E-book viewer".
18
+
This is **version 1.18.5 of PyMuPDF**, a Python binding with support for [MuPDF 1.18.*](http://mupdf.com/) - "a lightweight PDF, XPS, and E-book viewer".
19
19
20
20
MuPDF can access files in PDF, XPS, OpenXPS, CBZ, EPUB and FB2 (e-books) formats, and it is known for its top performance and high rendering quality.
21
21
@@ -61,10 +61,7 @@ Our **documentation**, written using Sphinx, is available in various formats fro
61
61
62
62
# Installation
63
63
64
-
For Windows, Linux and Mac OSX platforms, there are wheels in the [download](https://pypi.org/project/PyMuPDF/#files) section of PyPI. This includes Python 64bit versions 3.6 through 3.9. For Windows only, 32bit versions are available too.
65
-
66
-
> Wheels for **Python versions 2.7 and 3.5** will only be produced until the end of this year 2020. After that, you will need to build PyMuPDF from sources as explained below.
67
-
> Starting immediately, we **_defer uploading Python 2.7 / 3.5 wheels_** until explicitely requested. Please submit an issue.
64
+
For Windows, Linux and Mac OSX platforms, there are wheels in the [download](https://pypi.org/project/PyMuPDF/#files) section of PyPI. This includes Python 64bit versions **3.6 through 3.9**. For Windows only, 32bit versions are available too.
68
65
69
66
If your platform is not supported with one of our wheels, you need to generate PyMuPDF yourself as follows. This requires the development version of Python.
70
67
@@ -77,10 +74,10 @@ Before you can do that, you must first build MuPDF. For most platforms, the MuPD
77
74
78
75
- Now MuPDF can be generated.
79
76
80
-
*Since PyMuPDF v1.14.17, the sources provided in this repository **no longer contain**the interface files ``fitz.py`` and ``fitz.wrap.c`` - they are instead generated **"on the fly"** by ``setup.py`` using the interface generator [SWIG](http://www.swig.org/). So you need SWIG on your system. Please refer to issue #312 for some background.
77
+
*Please note that you will need the interface generator [SWIG](http://www.swig.org/) when building PyMuPDF from the sources of this repository (please refer to issue #312 for some background on this).
81
78
- PyMuPDF wheels are being generated using **SWIG v4.0.1**.
82
79
83
-
* If you do **not use SWIG**, please download the **sources from PyPI** - they continue to contain those generated files, so installation should work like any other Python extension generation on your system.
80
+
* If you do **not use SWIG**, please download the **sources from PyPI** - they contain sources pre-processed by SWIG, so installation should work like any other Python extension generation on your system.
84
81
85
82
Once this is done, adjust directories in ``setup.py`` and run ``python setup.py install``.
Changes the "stroke" and "fill" colors for supported annotation types.
274
+
Changes the "stroke" and "fill" colors for supported annotation types -- not all annotations accept both.
274
275
275
276
*Changed in version 1.16.9:* Allow colors to be directly set. These parameters are used if *colors* is not a dictionary.
276
277
277
278
:arg dict colors: a dictionary containing color specifications. For accepted dictionary keys and values see below. The most practical way should be to first make a copy of the *colors* property and then modify this dictionary as required.
278
279
:arg sequence stroke: see above.
279
280
:arg sequence fill: see above.
280
281
282
+
*Changed in v1.18.5:* To completely remove a color specification, use an empty sequence like ``[]``.
Copy file name to clipboardExpand all lines: docs/changes.rst
+17
Original file line number
Diff line number
Diff line change
@@ -1,6 +1,23 @@
1
1
Change Logs
2
2
===============
3
3
4
+
Changes in Version 1.18.5
5
+
-------------------------
6
+
Apart from several fixes, this version also focusses on several minor, but important feature improvements. Among the latter is a more precise computation of proper line heights and insertion points for writing / inserting text. As opposed to using font-agnostic constants, these values are now taken from the font's properties.
7
+
8
+
Also note that this is the first version which does no longer provide pregenerated wheels for Python versions older than 3.6. PIP also discontinues support for these by end of this year 2020.
9
+
10
+
* **Fixed** issue `#771 <https://github.com/pymupdf/PyMuPDF/issues/771>`_. By using "small glyph heights" option, the full page text can be extracted.
* **Fixed** issue `#739 <https://github.com/pymupdf/PyMuPDF/issues/739>`_. The "dict", "rawdict" and corresponding JSON output variants now have two new *span* keys: ``"ascender"`` and ``"descender"``. These floats represent special font properties which can be used to compute bboxes of spans or characters of **exactly fontsize height** (as opposed to the default line height). An example algorithm is shown in section "Span Dictionary" `here <https://pymupdf.readthedocs.io/en/latest/textpage.html#dictionary-structure-of-extractdict-and-extractrawdict>`_. Also improved the detection and correction of ill-specified ascender / descender values encountered in some fonts.
14
+
* **Added** a new, experimental :meth:`Tools.set_small_glyph_heights` -- also in response to issue `#739 <https://github.com/pymupdf/PyMuPDF/issues/739>`_. This method sets or unsets a global parameter to **always compute bboxes with fontsize height**. If "on", text searching and all text extractions will returned rectangles, bboxes and quads with a smaller height.
* **Changed** fill color logic of 'Polyline' annotations: this parameter now only pertains to line end symbols -- the annotation itself can no longer have a fill color. Also addresses issue `#727 <https://github.com/pymupdf/PyMuPDF/issues/727>`_.
17
+
* **Changed** :meth:`Page.getImageBbox` to also compute the bbox if the image is contained in an XObject.
18
+
* **Changed** :meth:`Shape.insertTextbox`, resp. :meth:`Page.insertTextbox`, resp. :meth:`TextWriter.fillTextbox` to respect font's properties "ascender" / "descender" when computing line height and insertion point. This should no longer lead to line overlaps for multi-line output. These methods used to ignore font specifics and used constant values instead.
19
+
20
+
4
21
Changes in Version 1.18.4
5
22
---------------------------
6
23
This version adds several features to support PDF Optional Content. Among other things, this includes OCMDs (Optional Content Membership Dictionaries) with the full scope of *"visibility expressions"* (PDF key ``/VE``), text insertions (including the :ref:`TextWriter` class) and drawings.
Copy file name to clipboardExpand all lines: docs/document.rst
+24-19
Original file line number
Diff line number
Diff line change
@@ -8,7 +8,7 @@ Document
8
8
9
9
This class represents a document. It can be constructed from a file or from memory.
10
10
11
-
Since version 1.9.0 there exists the alias *open* for this class, i.e. ``fitz.Document(...)`` and ``fitz.open(...)`` do exactly the same thing.
11
+
There exists the alias *open* for this class, i.e. ``fitz.Document(...)`` and ``fitz.open(...)`` do exactly the same thing.
12
12
13
13
For details on **embedded files** refer to Appendix 3.
14
14
@@ -262,39 +262,44 @@ For details on **embedded files** refer to Appendix 3.
262
262
263
263
Create or update an :data:`OCMD` (optional content membership dictionary).
264
264
265
+
:arg int xref::data:`xref` of the OCMD to be updated, or 0 for a new OCMD.
265
266
:arg list ocgs: a sequence of :data:`xref` numbers of existing :data:`OCG` PDF objects.
266
-
:arg str policy: one of "AnyOn", "AnyOff", "AllOn", "AllOff" (mixed or lower case).
267
-
:arg int xref::data:`xref` of an existing OCMD, which should be updated, or 0 for a new OCMD.
267
+
:arg str policy: one of "AnyOn" (default), "AnyOff", "AllOn", "AllOff" (mixed or lower case).
268
268
:arg list ve: a "visibility expression". This is a list of arbitrarily nested other lists -- see explanation below. Use as an alternative to the combination *ocgs* / *policy* if you need to formulate more complex conditions.
269
269
:rtype: int
270
-
:returns::data:`xref` of the OCMD. Use as entry for ``oc`` parameter in supporting objects.
270
+
:returns::data:`xref` of the OCMD. Use as ``oc=xref`` parameter in supporting objects, and respectively in :meth:`Document.set_oc` or :meth:`Annot.set_oc`.
271
271
272
272
.. note::
273
273
274
-
This object type can be used like an :data:`OCG` to determine the visibility of a PDF object. Its purpose is to **compute a boolean value** from the states of some OCGs. This value is then interpreted as ON (true) or OFF (false).
275
-
276
-
* Using the combination of *ocgs* and *policy*: The possible *policy* values are as follows:
274
+
The purpose of OCMDs is to more flexibly determine visibility. An OCMD actually is a boolean expression: it evaluates the current visibility of one or more optional content groups and then computes its own ON (true) or OFF (false) state.
275
+
276
+
There are two ways to formulate the OCMD's visibility:
277
+
278
+
1. Use the combination of *ocgs* and *policy*: The *policy* value is interpreted as follows:
277
279
278
280
- AnyOn -- (default) true if at least one OCG is ON.
279
281
- AnyOff -- true if at least one OCG is OFF.
280
282
- AllOn -- true if all OCGs are ON.
281
283
- AllOff -- true if all OCGs are OFF.
282
284
283
-
For example assume you want two PDF objects be displayed exactly one at a time (if one is ON, then the other one must be off): use an OCG for object 1 and an OCMD for object 2. Create the OCMD via ``set_ocmd(ocgs=[xref], policy="AllOff")``, where *xref* is the cross reference number of the OCG.
285
+
Suppose you want two PDF objects be displayed exactly one at a time (if one is ON, then the other one must be OFF):
286
+
287
+
Solution: use an **OCG** for object 1 and an **OCMD** for object 2. Create the OCMD via ``set_ocmd(ocgs=[xref], policy="AllOff")``, with the :data:`xref` of the OCG.
284
288
285
-
* Using the visibility expression *ve*: This is a list of arbitrarily nested other lists. It uses a combination of the logical expressions **"and"**, **"or"**, **"not"**, and the :data:`xref` numbers of one or more existing OCGs. The arguments *ocgs* and *policy* need not be used. The syntax of this parameter is a bit awkward, but quite powerful:
289
+
2. Use the **visibility expression** *ve*: This is a list of a logical expression keyword (string) followed by integers or other lists. The possible logical expressions are **"and"**, **"or"**, and **"not"**. The integers must be :data:`xref` numbers of OCGs. The syntax of this parameter is a bit awkward, but quite powerful:
286
290
287
-
- Each list, including the top one, must have two or more items. The fist item must be a logical expression.
288
-
- If the first item is a **"not"**, then the list must have exactly two items.
289
-
- If the first item is **"and"** or **"or"**, any number of other items may follow.
290
-
- Items following the logical expression may be either integers or other lists. An *integer* must be the xref of an OCG. A list must conform to the rules layed out so far.
291
+
- Each list, including the top one, must start with a logical expression.
292
+
- If the first item is a **"not"**, then the list must have exactly two items. If it is **"and"** or **"or"**, any number of other items may follow.
293
+
- Items following the logical expression may be either integers or other lists. An *integer* must be the xref of an OCG. A *list* must conform to the rules above.
291
294
292
295
**Examples:**
293
296
294
-
- ``ve=["or", 4, ["not", 5], ["and", 6, 7]]``. This delivers ON if 4 is ON, or 5 is OFF, or 6 and 7 are both ON.
295
-
- ``ve=["not", xref]`` has the same effect like previously using *ocgs* and *policy*.
297
+
- ``set_ocmd(ve=["or", 4, ["not", 5], ["and", 6, 7]])``. This delivers ON if the following is true: **"4 is ON, or 5 is OFF, or 6 and 7 are both ON"**.
298
+
- ``set_ocmd(ve=["not", xref])``. This has the same effect as the OCMD example created under 1.
299
+
300
+
For more details and examples see page 367 of :ref:`AdobeManual`. Also do have a look at example scripts `here <https://github.com/pymupdf/PyMuPDF-Utilities/tree/master/optional-content>`_.
296
301
297
-
For more details and examples see page 367 of :ref:`AdobeManual`.
302
+
Visibility expressions, ``/VE``, are part of the PDF version 1.6 specification. If you are using an older PDF consumer software, you hence may find it unsupported (i.e. ignored).
298
303
299
304
300
305
.. method:: get_ocmd(xref)
@@ -305,7 +310,7 @@ For details on **embedded files** refer to Appendix 3.
305
310
306
311
:arg int xref: the :data:`xref` of the OCMD.
307
312
:rtype: dict
308
-
:returns: a dictionary with the keys *ocgs*, *policy* and *ve*.
313
+
:returns: a dictionary with the keys *xref*, *ocgs*, *policy* and *ve*.
309
314
310
315
311
316
.. method:: get_oc_states(config=-1)
@@ -397,9 +402,9 @@ For details on **embedded files** refer to Appendix 3.
397
402
Modify OC visibility status of content groups. This is analog to what supporting PDF viewers would offer.
398
403
399
404
.. note::
400
-
Visibility is **not** a property of an OCG. Current visibility is not even an information that is necessarily present in the PDF document. Using this method, the user can **temporarily** modify visibility just as if doing so via a supporting PDF consumer software.
405
+
Visibility is **not** a property stored with the OCG. It is not even an information necessarily present in the PDF document at all. Instead, the current visibility is **temporarily** set using the user interface of some supporting PDF consumer software. The same type of functionality is offered by this method.
401
406
402
-
To make permanent changes, use :meth:`Document.set_oc_states`.
407
+
To make **permanent** changes, use :meth:`Document.set_oc_states`.
403
408
404
409
:arg in number: number as returned by :meth:`Document.layer_ui_configs`.
405
410
:arg int action: 0 = set on (default), 1 = toggle on/off, 2 = set off.
0 commit comments