Skip to content

Commit bfb30b4

Browse files
committed
upload v1.18.5
1 parent 99a4e2c commit bfb30b4

28 files changed

+1008
-746
lines changed

PKG-INFO

+4-5
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
Metadata-Version: 1.1
22
Name: PyMuPDF
3-
Version: 1.18.4
3+
Version: 1.18.5
44
Author: Jorj McKie
55
Author-email: [email protected]
66
Maintainer: Jorj McKie
@@ -9,7 +9,7 @@ Home-page: https://github.com/pymupdf/PyMuPDF
99
Download-url: https://github.com/pymupdf/PyMuPDF
1010
Summary: PyMuPDF is a Python binding for the PDF rendering library MuPDF
1111
Description:
12-
Release date: November 30, 2020
12+
Release date: December 20, 2020
1313

1414
Authors
1515
=======
@@ -20,13 +20,13 @@ Description:
2020
Introduction
2121
============
2222

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".
2424

2525
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.
2626

2727
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.
2828

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.
3030

3131
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.
3232

@@ -66,6 +66,5 @@ Classifier: Operating System :: MacOS
6666
Classifier: Operating System :: Microsoft :: Windows
6767
Classifier: Operating System :: POSIX :: Linux
6868
Classifier: Programming Language :: C
69-
Classifier: Programming Language :: Python :: 2.7
7069
Classifier: Programming Language :: Python :: 3
7170
Classifier: Topic :: Utilities

README.md

+6-9
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
1-
# PyMuPDF 1.18.4
1+
# PyMuPDF 1.18.5
22

33
![logo](https://github.com/pymupdf/PyMuPDF/blob/master/demo/pymupdf.jpg)
44

5-
Release date: November 30, 2020
5+
Release date: December 20, 2020
66

77
**Travis-CI:** [![Build Status](https://travis-ci.org/JorjMcKie/py-mupdf.svg?branch=master)](https://travis-ci.org/JorjMcKie/py-mupdf)
88

@@ -15,7 +15,7 @@ On **[PyPI](https://pypi.org/project/PyMuPDF)** since August 2016: [![](https://
1515

1616
# Introduction
1717

18-
This is **version 1.18.4 of PyMuPDF**, a Python binding with support for [MuPDF 1.18.*](http://mupdf.com/) - "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".
1919

2020
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.
2121

@@ -61,10 +61,7 @@ Our **documentation**, written using Sphinx, is available in various formats fro
6161

6262
# Installation
6363

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.
6865

6966
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.
7067

@@ -77,10 +74,10 @@ Before you can do that, you must first build MuPDF. For most platforms, the MuPD
7774

7875
- Now MuPDF can be generated.
7976

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).
8178
- PyMuPDF wheels are being generated using **SWIG v4.0.1**.
8279

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.
8481

8582
Once this is done, adjust directories in ``setup.py`` and run ``python setup.py install``.
8683

docs/annot.rst

+5-2
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ There is a parent-child relationship between an annotation and its page. If the
3131
:meth:`Annot.set_border` set annotation's border properties
3232
:meth:`Annot.set_blendmode` set annotation's blend mode
3333
:meth:`Annot.set_colors` set annotation's colors
34+
:meth:`Annot.set_flags` set annotation's flags field
3435
:meth:`Annot.set_name` set annotation's name field
3536
:meth:`Annot.set_oc` set :data:`xref` to an :data:`OCG` / :data:`OCMD`
3637
:meth:`Annot.set_opacity` change transparency
@@ -264,20 +265,22 @@ There is a parent-child relationship between an annotation and its page. If the
264265

265266
.. method:: set_flags(flags)
266267

267-
Changes the annotation flags. Use the *|* operator to combine several.
268+
Changes the annotation flags. Use the ``|`` operator to combine several.
268269

269270
:arg int flags: an integer specifying the required flags.
270271

271272
.. method:: set_colors(colors=None, stroke=None, fill=None)
272273

273-
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.
274275

275276
*Changed in version 1.16.9:* Allow colors to be directly set. These parameters are used if *colors* is not a dictionary.
276277

277278
: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.
278279
:arg sequence stroke: see above.
279280
:arg sequence fill: see above.
280281

282+
*Changed in v1.18.5:* To completely remove a color specification, use an empty sequence like ``[]``.
283+
281284

282285
.. method:: delete_responses()
283286

docs/changes.rst

+17
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,23 @@
11
Change Logs
22
===============
33

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.
11+
* **Fixed** issue `#768 <https://github.com/pymupdf/PyMuPDF/issues/768>`_.
12+
* **Fixed** issue `#750 <https://github.com/pymupdf/PyMuPDF/issues/750>`_.
13+
* **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.
15+
* **Fixed** issue `#728 <https://github.com/pymupdf/PyMuPDF/issues/728>`_.
16+
* **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+
421
Changes in Version 1.18.4
522
---------------------------
623
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.

docs/conf.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@
4040
# built documents.
4141
#
4242
# The full version, including alpha/beta/rc tags.
43-
release = "1.18.4"
43+
release = "1.18.5"
4444

4545
# The short X.Y version
4646
version = release

docs/document.rst

+24-19
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ Document
88

99
This class represents a document. It can be constructed from a file or from memory.
1010

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.
1212

1313
For details on **embedded files** refer to Appendix 3.
1414

@@ -262,39 +262,44 @@ For details on **embedded files** refer to Appendix 3.
262262

263263
Create or update an :data:`OCMD` (optional content membership dictionary).
264264

265+
:arg int xref: :data:`xref` of the OCMD to be updated, or 0 for a new OCMD.
265266
: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).
268268
: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.
269269
: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`.
271271

272272
.. note::
273273

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:
277279

278280
- AnyOn -- (default) true if at least one OCG is ON.
279281
- AnyOff -- true if at least one OCG is OFF.
280282
- AllOn -- true if all OCGs are ON.
281283
- AllOff -- true if all OCGs are OFF.
282284

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.
284288

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:
286290

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.
291294

292295
**Examples:**
293296

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>`_.
296301

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).
298303

299304

300305
.. method:: get_ocmd(xref)
@@ -305,7 +310,7 @@ For details on **embedded files** refer to Appendix 3.
305310

306311
:arg int xref: the :data:`xref` of the OCMD.
307312
: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*.
309314

310315

311316
.. method:: get_oc_states(config=-1)
@@ -397,9 +402,9 @@ For details on **embedded files** refer to Appendix 3.
397402
Modify OC visibility status of content groups. This is analog to what supporting PDF viewers would offer.
398403

399404
.. 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.
401406

402-
To make permanent changes, use :meth:`Document.set_oc_states`.
407+
To make **permanent** changes, use :meth:`Document.set_oc_states`.
403408

404409
:arg in number: number as returned by :meth:`Document.layer_ui_configs`.
405410
:arg int action: 0 = set on (default), 1 = toggle on/off, 2 = set off.

0 commit comments

Comments
 (0)