Skip to content

Commit 73bc764

Browse files
committed
upload v1.16.14
1 parent 8af219a commit 73bc764

21 files changed

+908
-239
lines changed

PKG-INFO

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
Metadata-Version: 1.1
22
Name: PyMuPDF
3-
Version: 1.16.13
3+
Version: 1.16.14
44
Author: Ruikai Liu
55
Author-email: [email protected]
66
Maintainer: Jorj X. 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: March 15, 2020
12+
Release date: March 25, 2020
1313

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

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

README.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
1-
# PyMuPDF 1.16.13
1+
# PyMuPDF 1.16.14
22

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

5-
Release date: March 15, 2020
5+
Release date: March 25, 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

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

1515
# Introduction
1616

17-
This is **version 1.16.13 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".
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".
1818

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

docs/annot.rst

Lines changed: 24 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,8 @@ There is a parent-child relationship between an annotation and its page. If the
1414
=============================== ==============================================================
1515
**Attribute** **Short Description**
1616
=============================== ==============================================================
17+
:meth:`Annot.blendMode` return the annotation's blend mode
18+
:meth:`Annot.setBlendMode` set the annotation's blend mode
1719
:meth:`Annot.delete_responses` delete all responding annotions
1820
:meth:`Annot.fileGet` return attached file content
1921
: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
8890

8991
.. method:: setOpacity(value)
9092

91-
Change an annotation's transparency.
93+
Set the annotation's transparency. Opacity can also be set in :meth:`Annot.update`.
9294

9395
: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%.
9496

9597
Three overlapping 'Circle' annotations with each opacity set to 0.5:
9698

9799
.. image:: images/img-opacity.jpg
98100

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+
99114
.. method:: setName(name)
100115

101116
*(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`.
102117

103-
104118
:arg str name: the new name.
105119

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+
106122
.. method:: setRect(rect)
107123

108124
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
144160

145161

146162
.. index::
163+
pair: blend_mode; update
147164
pair: fontsize; update
148165
pair: text_color; update
149166
pair: border_color; update
150167
pair: fill_color; update
151168
pair: rotate; update
152169

153-
.. method:: update(fontsize=0, text_color=None, border_color=None, fill_color=None, rotate=-1)
170+
.. method:: update(opacity=None, blend_mode=None, fontsize=0, text_color=None, border_color=None, fill_color=None, rotate=-1)
154171

155172
Synchronize the appearance of an annotation with its properties after any changes.
156173

157-
You can safely omit this method only for the following changes:
174+
You can safely omit this method **only** for the following changes:
158175

159176
* :meth:`setRect`
160177
* :meth:`setFlags`
161178
* :meth:`fileUpd`
162179
* :meth:`setInfo` (except changes to *"content"*)
163180

164-
All arguments are optional and **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.
165182

166183
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.
167184

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`.
168187
:arg float fontsize: change font size of the text.
169188
:arg sequence,float text_color: change the text color.
170189
:arg sequence,float border_color: change the border color.

docs/changes.rst

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,24 @@
11
Change Logs
22
===============
33

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>`_
16+
17+
* **Fixed** issue `#474 <https://github.com/pymupdf/PyMuPDF/issues/474>`_.
18+
* **Fixed** issue `#466 <https://github.com/pymupdf/PyMuPDF/issues/466>`_.
19+
20+
21+
422
Changes in Version 1.16.13
523
---------------------------
624

docs/conf.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@
4646
# built documents.
4747
#
4848
# The full version, including alpha/beta/rc tags.
49-
release = "1.16.13"
49+
release = "1.16.14"
5050

5151
# The short X.Y version
5252
version = release

docs/document.rst

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,7 @@ For addional details on **embedded files** refer to Appendix 3.
5050
:meth:`Document.reload_page` PDF only: provide a new copy of a page
5151
:meth:`Document.save` PDF only: save the document
5252
:meth:`Document.saveIncr` PDF only: save the document incrementally
53+
:meth:`Document.scrub` PDF only: remove sensitive data
5354
:meth:`Document.searchPageFor` search for a string on a page
5455
:meth:`Document.select` PDF only: select a subset of pages
5556
:meth:`Document.setMetadata` PDF only: set the metadata
@@ -425,6 +426,23 @@ For addional details on **embedded files** refer to Appendix 3.
425426

426427
Check whether the document can be saved incrementally. Use it to choose the right option without encountering exceptions.
427428

429+
.. method:: scrub(attached_files=True, clean_pages=True, embedded_files=True, hidden_text=True, javascript=True, metadata=True, redactions=True, remove_links=True, reset_fields=True, reset_responses=True, xml_metadata=True)
430+
431+
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.
437+
:arg bool javascript: Remove JavaScript sources.
438+
:arg bool metadata: Remove PDF standard metadata.
439+
:arg bool redactions: Apply redaction annotations.
440+
:arg bool remove_links: Remove all links.
441+
:arg bool reset_fields: Reset all form fields to their defaults.
442+
:arg bool reset_responses: Remove all responses from all annotations.
443+
:arg bool xml_metadata: Remove XML metadata.
444+
445+
428446
.. method:: save(outfile, garbage=0, clean=False, deflate=False, incremental=False, ascii=False, expand=0, linear=False, pretty=False, encryption=PDF_ENCRYPT_NONE, permissions=-1, owner_pw=None, user_pw=None)
429447

430448
PDF only: Saves the document in its **current state**.

docs/images/img-markers.jpg

0 Bytes
Loading

docs/page.rst

Lines changed: 20 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -244,32 +244,37 @@ This is available for PDF documents only. There are basically two groups of meth
244244
.. image:: images/img-polyline.png
245245
:scale: 70
246246

247-
.. method:: addUnderlineAnnot(quads)
247+
.. method:: addUnderlineAnnot(quads=None, start=None, stop=None, clip=None)
248248

249-
.. method:: addStrikeoutAnnot(quads)
249+
.. method:: addStrikeoutAnnot(quads=None, start=None, stop=None, clip=None)
250250

251-
.. method:: addSquigglyAnnot(quads)
251+
.. method:: addSquigglyAnnot(quads=None, start=None, stop=None, clip=None)
252252

253-
.. method:: addHighlightAnnot(quads)
253+
.. method:: addHighlightAnnot(quads=None, start=None, stop=None, clip=None)
254254

255-
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.
256256

257257
Standard colors are chosen per annotation type: **yellow** for highlighting, **red** for strike out, **green** for underlining, and **magenta** for wavy underlining.
258258

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

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

263263
>>> quads = page.searchFor("pymupdf", hit_max=100, quads=True)
264264
>>> page.addHighlightAnnot(quads)
265265

266-
: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.
267270

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

271276
.. image:: images/img-markers.jpg
272-
:scale: 80
277+
:scale: 100
273278

274279
.. method:: addStampAnnot(rect, stamp=0)
275280

@@ -281,9 +286,10 @@ This is available for PDF documents only. There are basically two groups of meth
281286

282287
.. note::
283288

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

288294

289295
.. image :: images/img-stampannot.jpg

docs/vars.rst

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -377,6 +377,27 @@ Widget flags (*field_flags*)
377377
PDF_CH_FIELD_IS_COMMIT_ON_SEL_CHANGE 1 << 26
378378

379379

380+
.. _BlendModes:
381+
382+
PDF Standard Blend Modes
383+
----------------------------
384+
385+
For an explanation see :ref:`AdobeManual`, page 520::
386+
387+
PDF_BM_ColorBurn "ColorBurn"
388+
PDF_BM_ColorDodge "ColorDodge"
389+
PDF_BM_Darken "Darken"
390+
PDF_BM_Difference "Difference"
391+
PDF_BM_Exclusion "Exclusion"
392+
PDF_BM_HardLight "HardLight
393+
PDF_BM_Lighten "Lighten"
394+
PDF_BM_Multiply "Multiply"
395+
PDF_BM_Normal "Normal"
396+
PDF_BM_Overlay "Overlay"
397+
PDF_BM_Screen "Screen"
398+
PDF_BM_SoftLight "Softlight"
399+
400+
380401
.. _StampIcons:
381402

382403
Stamp Annotation Icons

docs/version.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
Covered Version
22
--------------------
33

4-
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**.
55

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

Comments
 (0)