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: March 15, 2020
12
+
Release date: March 25, 2020
13
13
14
14
Authors
15
15
=======
@@ -20,7 +20,7 @@ Description:
20
20
Introduction
21
21
============
22
22
23
-
This is **version 1.16.13 of PyMuPDF**, a Python binding for `MuPDF <http://mupdf.com/>`_ - "a lightweight PDF and XPS viewer".
23
+
This is **version 1.16.14 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.
@@ -14,7 +14,7 @@ On **[PyPI](https://pypi.org/project/PyMuPDF)** since August 2016: [**, a Python binding with support for [MuPDF 1.16.*](http://mupdf.com/) - "a lightweight PDF, XPS, and E-book viewer".
17
+
This is **version 1.16.14 of PyMuPDF (formerly python-fitz)**, a Python binding with support for [MuPDF 1.16.*](http://mupdf.com/) - "a lightweight PDF, XPS, and E-book viewer".
18
18
19
19
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.
:meth:`Annot.fileInfo` return attached file information
@@ -88,21 +90,35 @@ There is a parent-child relationship between an annotation and its page. If the
88
90
89
91
.. method:: setOpacity(value)
90
92
91
-
Change an annotation's transparency.
93
+
Set the annotation's transparency. Opacity can also be set in :meth:`Annot.update`.
92
94
93
95
:arg float value: a float in range *[0, 1]*. Any value outside is assumed to be 1. E.g. a value of 0.5 sets the transparency to 50%.
94
96
95
97
Three overlapping 'Circle' annotations with each opacity set to 0.5:
96
98
97
99
.. image:: images/img-opacity.jpg
98
100
101
+
.. method:: blendMode()
102
+
103
+
*(New in v1.16.14)* Return the annotation's blend mode. See :ref:`AdobeManual`, page 520 for explanations.
104
+
105
+
:rtype: str
106
+
:returns: the blend mode or *None*.
107
+
108
+
.. method:: setBlendMode(blend_mode)
109
+
110
+
*(New in v1.16.14)* Set the annotation's blend mode. See :ref:`AdobeManual`, page 520 for explanations. The blend mode can also be set in :meth:`Annot.update`.
111
+
112
+
:arg str blend_mode: set the blend mode. Use :meth:`Annot.update` to reflect this in the visual appearance. For predefined values see :ref:`BlendModes`.
113
+
99
114
.. method:: setName(name)
100
115
101
116
*(New in version 1.16.0)* Change the name field of any annotation type. For 'FileAttachment' and 'Text' annotations, this is the icon name, for 'Stamp' annotations the text in the stamp. The visual result (if any) depends on your PDF viewer. See also :ref:`mupdficons`.
102
117
103
-
104
118
:arg str name: the new name.
105
119
120
+
.. caution:: If you set the name of a 'Stamp' annotation, then this will **not change** the rectangle, nor will the text be layouted in any way. If you choose a standard text from :ref:`StampIcons` (the **exact** name piece after ``STAMP_``!), you should receive the original layout. An **arbitrary text** will not be changed to upper case, but be written as is, horizontally centered in **one line**. If its length exceeds the available width, it will be accordingly shortened. To ensure your own text will **not be shortened**, ensure that ``fitz.getTextLength(text, fontname="tiro", fontsize=20) / annot.rect.width <= 0.85``.
121
+
106
122
.. method:: setRect(rect)
107
123
108
124
Change the rectangle of an annotation. The annotation can be moved around and both sides of the rectangle can be independently scaled. However, the annotation appearance will never get rotated, flipped or sheared.
@@ -144,27 +160,30 @@ There is a parent-child relationship between an annotation and its page. If the
Synchronize the appearance of an annotation with its properties after any changes.
156
173
157
-
You can safely omit this method only for the following changes:
174
+
You can safely omit this method **only** for the following changes:
158
175
159
176
* :meth:`setRect`
160
177
* :meth:`setFlags`
161
178
* :meth:`fileUpd`
162
179
* :meth:`setInfo` (except changes to *"content"*)
163
180
164
-
All arguments are optionaland **are reserved for 'FreeText'** annotations -- because of implementation peculiarities of this annotation type. For other types they are ignored.
181
+
All arguments are optional. *(Changed in v1.16.14)* blend_mode and opacity are applicable to all annotation types. The other arguments **are reserved for 'FreeText'** annotations and ignored for other types.
165
182
166
183
Color specifications may be made in the usual format used in PuMuPDF as sequences of floats ranging from 0.0 to 1.0 (including both). The sequence length must be 1, 3 or 4 (supporting GRAY, RGB and CMYK colorspaces respectively). For mono-color, just a float is also acceptable.
167
184
185
+
:arg float opacity: *(new in v1.16.14)* **valid for all annotation types:** change or set the annotation's transparency. Valid values are *0 <= opacity < 1*.
186
+
:arg str blend_mode: *(new in v1.16.14)* **valid for all annotation types:** change or set the annotation's blend mode. For valid values see :ref:`BlendModes`.
168
187
:arg float fontsize: change font size of the text.
169
188
:arg sequence,float text_color: change the text color.
170
189
:arg sequence,float border_color: change the border color.
Copy file name to clipboardExpand all lines: docs/changes.rst
+18Lines changed: 18 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1,6 +1,24 @@
1
1
Change Logs
2
2
===============
3
3
4
+
Changes in Version 1.16.14
5
+
---------------------------
6
+
7
+
* **Changed** text marker annotations to accept parameters beyond just quadrilaterals such that now **text lines between two given points can be marked**.
8
+
9
+
* **Added** :meth:`Document.scrub` which **removes potentially sensitive data** from a PDF. Implements `#453 <https://github.com/pymupdf/PyMuPDF/issues/453>`_.
10
+
11
+
* **Added** :meth:`Annot.blendMode` which returns the **blend mode** of annotations.
12
+
13
+
* **Added** :meth:`Annot.setBlendMode` to set the annotation's blend mode. This resolves issue `#416 <https://github.com/pymupdf/PyMuPDF/issues/416>`_.
14
+
* **Changed** :meth:`Annot.update` to accept additional parameters for setting blend mode and opacity.
15
+
* **Added** advanced graphics features to **control the anti-aliasing values**, :meth:`Tools.set_aa_level`. Resolves `#467 <https://github.com/pymupdf/PyMuPDF/issues/467>`_
PDF only: *(New in v1.16.14)* Remove potentially sensitive data from the PDF. This function is inspired by the similar "Sanitize" function in Adobe Acrobat products. The process is configurable by a number of options, which are all *True* by default.
432
+
433
+
:arg bool attached_files: Search for 'FileAttachment' annotations and remove the file content.
434
+
:arg bool clean_pages: Remove any comments from page painting sources. If this option is set to *False*, then this is also done for *hidden_text* and *redactions*.
435
+
:arg bool embedded_files: Remove embedded files.
436
+
:arg bool hidden_text: Remove OCR-ed text and invisible text.
PDF only: These annotations are normally used for marking text which has previously been located (for example via :meth:`searchFor`). But the actual presence of text within the specified area(s) is neither checked nor required. So you are free to "mark" anything.
255
+
PDF only: These annotations are normally used for **marking text** which has previously been somehow located (for example via :meth:`searchFor`). But this is not required: you are free to "mark" just anything.
256
256
257
257
Standard colors are chosen per annotation type: **yellow** for highlighting, **red** for strike out, **green** for underlining, and **magenta** for wavy underlining.
258
258
259
-
The methods convert the argument into a list of :ref:`Quad` objects. The **annotation** rectangle is calculated to envelop these quadrilaterals.
259
+
The methods convert the arguments into a list of :ref:`Quad` objects. The **annotation** rectangle is then calculated to envelop all these quadrilaterals.
260
260
261
-
.. note:: :meth:`searchFor` supports :ref:`Quad` objects as an output option. Hence the following two statements are sufficient to locate and mark every occurrence of string "pymupdf" with **one common** annotation::
261
+
.. note:: :meth:`searchFor` delivers a list of either rectangles or quadrilaterals. Such a list can be directly used as parameter for these annotation types and will deliver **one common** annotation for all occurrences of the search string::
:arg rect_like,quad_like,list,tuple quads: Changed in version 1.14.20 the rectangles or quads containing the to-be-marked text (locations). A list or tuple must consist of :data:`rect_like` or :data:`quad_like` items (or even a mixture of either). You should prefer using quads, because this will automatically support non-horizontal text and avoid rectangle-to-quad conversion effort.
266
+
:arg rect_like,quad_like,list,tuple quads: *(Changed in v1.14.20)* the rectangles or quads containing the to-be-marked text (locations). A list or tuple must consist of :data:`rect_like` or :data:`quad_like` items (or even a mixture of either). You should prefer using quads, because this will automatically support non-horizontal text and avoid rectangle-to-quad conversion effort. *(Changed in v1.16.14)* **Set this parameter to** *None* if you want to use the following arguments.
267
+
:arg point_like start: *(New in v1.16.14)* start text marking at this point. Defaults to the top-left point of *clip*.
268
+
:arg point_like stop: *(New in v1.16.14)* stop text marking at this point. Defaults to the bottom-right point of *clip*.
269
+
:arg rect_like clip: *(New in v1.16.14)* only consider text lines intersecting this area. Defaults to the page rectangle.
267
270
268
-
:rtype::ref:`Annot`
269
-
:returns: the created annotation. To change colors, set the "stroke" color accordingly (:meth:`Annot.setColors`) and then perform an :meth:`Annot.update`.
271
+
:rtype::ref:`Annot` or *(changed in v1.16.14)* *None*
272
+
:returns: the created annotation. *(Changed in v1.16.14)* If *quads* is an empty list, **no annotation** is created. To change colors, set the "stroke" color accordingly (:meth:`Annot.setColors`) and then perform an :meth:`Annot.update`.
273
+
274
+
.. note:: Starting with v1.16.14 you can use parameters *start*, *stop* and *clip* to highlight consecutive lines between the points *start* and *stop*. Make use of *clip* to further reduce the selected line bboxes and thus deal with e.g. multi-column pages. The following multi-line highlight was created specifying the two red points and setting clip accordingly.
270
275
271
276
.. image:: images/img-markers.jpg
272
-
:scale:80
277
+
:scale:100
273
278
274
279
.. method:: addStampAnnot(rect, stamp=0)
275
280
@@ -281,9 +286,10 @@ This is available for PDF documents only. There are basically two groups of meth
281
286
282
287
.. note::
283
288
284
-
* The stamp's text (e.g. "APPROVED") and its border line will automatically be sized and put centered in the given rectangle. :attr:`Annot.rect` is automatically calculated to fit and will usually be smaller than this parameter. The appearance can be changed using :meth:`Annot.setOpacity` and by setting the "stroke" color (no "fill" color supported).
285
-
286
-
* This can conveniently be used to create watermark images: on a temporary PDF page create a stamp annotation with a low opacity value, make a pixmap from it with *alpha=True* (and potentially also rotate it), discard the temporary PDF page and use the pixmap with :meth:`insertImage` for your target PDF.
289
+
* The stamp's text and its border line will automatically be sized and be put horizontally and vertically centered in the given rectangle. :attr:`Annot.rect` is automatically calculated to fit the given **width** and will usually be smaller than this parameter.
290
+
* The font chosen is "Times Bold" and the text will be upper case.
291
+
* The appearance can be changed using :meth:`Annot.setOpacity` and by setting the "stroke" color (no "fill" color supported).
292
+
* This can be used to create watermark images: on a temporary PDF page create a stamp annotation with a low opacity value, make a pixmap from it with *alpha=True* (and potentially also rotate it), discard the temporary PDF page and use the pixmap with :meth:`insertImage` for your target PDF.
This documentation covers PyMuPDF v1.16.13 features as of **2020-03-15 05:29:04**.
4
+
This documentation covers PyMuPDF v1.16.14 features as of **2020-03-25 11:44:22**.
5
5
6
6
.. note:: The major and minor versions of **PyMuPDF** and **MuPDF** will always be the same. Only the third qualifier (patch level) may be different from that of MuPDF.
0 commit comments