Skip to content

Commit eb1a43d

Browse files
committed
upload v1.17.2
1 parent 363db51 commit eb1a43d

21 files changed

+1084
-1317
lines changed

PKG-INFO

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
Metadata-Version: 1.1
22
Name: PyMuPDF
3-
Version: 1.17.1
3+
Version: 1.17.2
44
Author: Ruikai Liu
55
Author-email: [email protected]
66
Maintainer: Jorj X. McKie
@@ -20,7 +20,7 @@ Description:
2020
Introduction
2121
============
2222

23-
This is **version 1.17.1 of PyMuPDF**, a Python binding for `MuPDF <http://mupdf.com/>`_ - "a lightweight PDF and XPS viewer".
23+
This is **version 1.17.2 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: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# PyMuPDF 1.17.1
1+
# PyMuPDF 1.17.2
22

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

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

1515
# Introduction
1616

17-
This is **version 1.17.1 of PyMuPDF**, a Python binding with support for [MuPDF 1.17.*](http://mupdf.com/) - "a lightweight PDF, XPS, and E-book viewer".
17+
This is **version 1.17.2 of PyMuPDF**, a Python binding with support for [MuPDF 1.17.*](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

21-
With PyMuPDF you can access files with extensions like ".pdf", ".xps", ".oxps", ".cbz", ".fb2" or ".epub". About 10 popular image formats are also supported via the document interface.
21+
With PyMuPDF you can access files with extensions like ".pdf", ".xps", ".oxps", ".cbz", ".fb2" or ".epub". In addition, about 10 popular image formats can also be opened and handled like documents.
2222

2323

2424
# Usage and Documentation
25-
For all supported document types (i.e. including images) you can
25+
For all supported document types (i.e. **_including images_**) you can
2626
* decrypt the document
2727
* access meta information, links and bookmarks
2828
* render pages in raster formats (PNG and some others), or the vector format SVG
@@ -32,14 +32,14 @@ For all supported document types (i.e. including images) you can
3232

3333
> To some degree, PyMuPDF can therefore be used as an [image converter](https://github.com/pymupdf/PyMuPDF/wiki/How-to-Convert-Images): it can read a range of input formats and can produce **Portable Network Graphics (PNG)**, **Portable Anymaps** (**PNM**, etc.), **Portable Arbitrary Maps (PAM)**, **Adobe Postscript** and **Adobe Photoshop** documents, making the use of other graphics packages obselete in these cases. But interfacing with e.g. PIL/Pillow for image input and output is easy as well.
3434
35-
**PDF files** can be created, joined or split up. Pages can be inserted, deleted, re-arranged or modified in many ways (including annotations and form fields).
35+
**PDF documents** can be created, joined or split up. Pages can be inserted, deleted, re-arranged or modified in many ways (including annotations and form fields).
3636

3737
* Images and fonts can be extracted or inserted.
3838
* Embedded files are fully supported.
3939
* PDFs can be reformatted to support double-sided printing, posterizing, applying logos or watermarks
4040
* Password protection is fully supported: decryption, encryption, encryption method selection, permmission level and user / owner password setting.
4141
* Low-level PDF structures can be accessed and modified.
42-
* PyMuPDF can also be used as a **module in the command line** using ``"python -m fitz ..."``. This is a versatile utility, which we will further develop over time. It currently supports PDF document
42+
* PyMuPDF can also be used as a **module in the command line** using ``"python -m fitz ..."``. This is a versatile utility, which we will further develop going forward. It currently supports PDF document
4343

4444
- **encryption / decryption / optimization**
4545
- creating **sub-documents**

docs/annot.rst

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -141,7 +141,7 @@ There is a parent-child relationship between an annotation and its page. If the
141141

142142
:arg rect_like rect: the new rectangle of the annotation (finite and not empty). E.g. using a value of *annot.rect + (5, 5, 5, 5)* will shift the annot position 5 pixels to the right and downwards.
143143

144-
.. note:: You need not invoke :meth:`Annot.update` for activation of the effect.
144+
.. note:: You **need not** invoke :meth:`Annot.update` for activation of the effect.
145145

146146

147147
.. method:: setRotation(angle)
@@ -196,9 +196,10 @@ There is a parent-child relationship between an annotation and its page. If the
196196
pair: text_color; update
197197
pair: border_color; update
198198
pair: fill_color; update
199+
pair: cross_out; update
199200
pair: rotate; update
200201

201-
.. method:: update(opacity=None, blend_mode=None, fontsize=0, text_color=None, border_color=None, fill_color=None, rotate=-1)
202+
.. method:: update(opacity=None, blend_mode=None, fontsize=0, text_color=None, border_color=None, fill_color=None, cross_out=True, rotate=-1)
202203

203204
Synchronize the appearance of an annotation with its properties after any changes.
204205

@@ -223,6 +224,7 @@ There is a parent-child relationship between an annotation and its page. If the
223224
* 'FreeText' annotations: If you set (or leave) this to *None*, then **no rectangle at all** will be drawn around the text, and the border color will be ignored. This will leave anything "under" the text visible.
224225
* 'Line', 'Polyline', 'Polygon' annotations: use it to give applicable line end symbols a fill color other than that of the annotation *(changed in v1.16.16)*.
225226

227+
:arg bool cross_out: *(new in v1.17.2)* add two diagonal lines to the annotation rectangle. 'Redact' annotations only. If not desired, *False* must be specified even if the annotation was created with *False*.
226228
:arg int rotate: new rotation value. Default (-1) means no change. Supports 'FreeText' and several other annotation types (see `Annot.setRotation`), [#f1]_. Only choose 0, 90, 180, or 270 degrees for 'FreeText'. Otherwise any integer is acceptable.
227229

228230
:rtype: bool

docs/changes.rst

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

4+
Changes in Version 1.17.2
5+
---------------------------
6+
* **Fixed** issue `#533 <https://github.com/pymupdf/PyMuPDF/issues/533>`_.
7+
* **Added** options to modify 'Redact' annotation appearance. Implements `#535 <https://github.com/pymupdf/PyMuPDF/issues/535>`_.
8+
9+
410
Changes in Version 1.17.1
511
---------------------------
612
* **Fixed** issue `#520 <https://github.com/pymupdf/PyMuPDF/issues/520>`_.

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.17.1"
49+
release = "1.17.2"
5050

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

docs/document.rst

Lines changed: 31 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ For addional details on **embedded files** refer to Appendix 3.
1717
======================================= ==========================================================
1818
:meth:`Document.authenticate` gain access to an encrypted document
1919
:meth:`Document.can_save_incrementally` check if incremental save is possible
20+
:meth:`Document.chapterPageCount` number of pages in chapter
2021
:meth:`Document.close` close the document
2122
:meth:`Document.convertToPDF` write a PDF version to memory
2223
:meth:`Document.copyPage` PDF only: copy a page reference
@@ -63,6 +64,7 @@ For addional details on **embedded files** refer to Appendix 3.
6364
:meth:`Document.xrefObject` PDF only: object source at the :data:`xref`
6465
:meth:`Document.xrefStream` PDF only: stream source at the :data:`xref`
6566
:meth:`Document.xrefStreamRaw` PDF only: raw stream source at the :data:`xref`
67+
:attr:`Document.chapterCount` number of chapters
6668
:attr:`Document.FormFonts` PDF only: list of global widget fonts
6769
:attr:`Document.isClosed` has document been closed?
6870
:attr:`Document.isEncrypted` document (still) encrypted?
@@ -151,13 +153,23 @@ For addional details on **embedded files** refer to Appendix 3.
151153
* bit 2 set => **owner** password authenticated
152154

153155

156+
.. method:: chapterPageCount(chapter)
157+
158+
*(New in v.1.17.0)* Return the number of pages of a chapter.
159+
160+
:arg int chapter: the 0-based chapter number.
161+
162+
:rtype: int
163+
:returns: number of pages in chapter. Relevant only for document types whith chapter support (EPUB currently).
164+
165+
154166
.. method:: nextLocation(page_id)
155167

156168
*(New in v.1.17.0)* Return the locator of the following page.
157169

158170
:arg tuple page_id: the current page id. This must be a tuple *(chapter, pno)* identifying an existing page.
159171

160-
:returns: The tuple of the following page, i.e. either *(chapter, pno + 1)* or *(chapter + 1, 0)*, **or** the empty tuple *()* if the argument was the last page.
172+
:returns: The tuple of the following page, i.e. either *(chapter, pno + 1)* or *(chapter + 1, 0)*, **or** the empty tuple *()* if the argument was the last page. Relevant only for document types whith chapter support (EPUB currently).
161173

162174

163175
.. method:: previousLocation(page_id)
@@ -166,7 +178,7 @@ For addional details on **embedded files** refer to Appendix 3.
166178

167179
:arg tuple page_id: the current page id. This must be a tuple *(chapter, pno)* identifying an existing page.
168180

169-
:returns: The tuple of the preceeding page, i.e. either *(chapter, pno - 1)* or the last page of the receeding chapter, **or** the empty tuple *()* if the argument was the first page.
181+
:returns: The tuple of the preceeding page, i.e. either *(chapter, pno - 1)* or the last page of the receeding chapter, **or** the empty tuple *()* if the argument was the first page. Relevant only for document types whith chapter support (EPUB currently).
170182

171183

172184
.. method:: loadPage(page_id=0)
@@ -179,7 +191,7 @@ For addional details on **embedded files** refer to Appendix 3.
179191

180192
Either a 0-based page number, or a tuple *(chapter, pno)*. For an integer, any *-inf < page_id < pageCount* is acceptable. While page_id is negative, :attr:`pageCount` will be added to it. For example: to load the last page, you can use *doc.loadPage(-1)*. After this you have page.number = doc.pageCount - 1.
181193

182-
For a tuple, *chapter* must be in range :attr:`Document.chapterCount`, and *pno* must be in range :meth:`Document.chapterPageCount` of that chapter. Both values are 0-based. With this notation, :attr:`Page.number` will equal the given tuple.
194+
For a tuple, *chapter* must be in range :attr:`Document.chapterCount`, and *pno* must be in range :meth:`Document.chapterPageCount` of that chapter. Both values are 0-based. With this notation, :attr:`Page.number` will equal the given tuple. Relevant only for document types whith chapter support (EPUB currently).
183195

184196
:rtype: :ref:`Page`
185197

@@ -684,11 +696,11 @@ For addional details on **embedded files** refer to Appendix 3.
684696

685697
.. method:: getSigFlags()
686698

687-
PDF only: Return whether the document contains signature fields.
699+
PDF only: Return whether the document contains signature fields. This is an optional PDF property: if not present, no conclusions can be drawn, because the PDF creator may just not have bothered to use it.
688700

689701
:rtype: int
690702
:returns:
691-
* -1: not a Form PDF or no signature fields exist.
703+
* -1: not a Form PDF / no signature fields recorded / no *SigFlags* found.
692704
* 1: at least one signature field exists.
693705
* 3: contains signatures that may be invalidated if the file is saved (written) in a way that alters its previous contents, as opposed to an incremental update.
694706

@@ -932,6 +944,20 @@ For addional details on **embedded files** refer to Appendix 3.
932944

933945
:type: int
934946

947+
.. Attribute:: chapterCount
948+
949+
*(New in version 1.17.0)*
950+
Contains the number of chapters in the document. Always at least 1. Relevant only for document types with chapter support (EPUB currently). Other documents will return 1.
951+
952+
:type: int
953+
954+
.. Attribute:: lastLocation
955+
956+
*(New in version 1.17.0)*
957+
Contains (chapter, pno) of the document's last page. Relevant only for document types with chapter support (EPUB currently). Other documents will return *(0, len(doc) - 1)* and *(0, -1)* if it has no pages.
958+
959+
:type: int
960+
935961
.. Attribute:: FormFonts
936962

937963
A list of form field font names defined in the */AcroForm* object. *None* if not a PDF.

docs/functions.rst

Lines changed: 19 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -42,14 +42,15 @@ Yet others are handy, general-purpose utilities.
4242
:meth:`getPDFnow` return the current timestamp in PDF format
4343
:meth:`getPDFstr` return PDF-compatible string
4444
:meth:`getTextlength` return string length for a given font & fontsize
45-
:meth:`Page._cleanContents` PDF only: clean the page's :data:`contents` objects
45+
:meth:`Page.cleanContents` PDF only: clean the page's :data:`contents` objects
4646
:meth:`Page._getContents` PDF only: return a list of content numbers
4747
:meth:`Page._setContents` PDF only: set page's :data:`contents` to some :data:`xref`
4848
:meth:`Page.getDisplayList` create the page's display list
4949
:meth:`Page.getTextBlocks` extract text blocks as a Python list
5050
:meth:`Page.getTextWords` extract text words as a Python list
5151
:meth:`Page.run` run a page through a device
52-
:meth:`Page._wrapContents` wrap contents with stacking commands
52+
:meth:`Page.readContents` PDF only: get complete, concatenated /Contents source
53+
:meth:`Page.wrapContents` wrap contents with stacking commands
5354
:attr:`Page._isWrapped` check whether contents wrapping is present
5455
:meth:`planishLine` matrix to map a line to the x-axis
5556
:meth:`PaperSize` return width, height for a known paper format
@@ -167,13 +168,13 @@ Yet others are handy, general-purpose utilities.
167168

168169
-----
169170

170-
.. method:: ImageProperties(image)
171+
.. method:: ImageProperties(stream)
171172

172173
*(New in version 1.14.14)*
173-
174+
174175
Return a number of basic properties for an image.
175176

176-
:arg bytes|bytearray|BytesIO|file image: an image either in memory or an **opened** file. A memory resident image maybe any of the formats *bytes*, *bytearray* or *io.BytesIO*.
177+
:arg bytes|bytearray|BytesIO|file stream: an image either in memory or an **opened** file. A memory resident image maybe any of the formats *bytes*, *bytearray* or *io.BytesIO*.
177178

178179
:returns: a dictionary with the following keys (an empty dictionary for any error):
179180

@@ -185,7 +186,7 @@ Yet others are handy, general-purpose utilities.
185186
colorspace (int) colorspace.n (e.g. 3 = RGB)
186187
bpc (int) bits per component (usually 8)
187188
format (int) image format in *range(15)*
188-
ext (str) suggested image file extension for the format
189+
ext (str) image file extension indicating the format
189190
size (int) length of the image in bytes
190191
========== ====================================================
191192

@@ -319,17 +320,17 @@ Yet others are handy, general-purpose utilities.
319320

320321
-----
321322

322-
.. method:: Page._wrapContents
323+
.. method:: Page.wrapContents
323324

324325
Put string pair "q" / "Q" before, resp. after a page's */Contents* object(s) to ensure that any "geometry" changes are **local** only.
325326

326-
Use this method as an alternative, minimalistic version of :meth:`Page._cleanContents`. Its advantage is a small footprint in terms of processing time and impact on incremental saves.
327+
Use this method as an alternative, minimalistic version of :meth:`Page.cleanContents`. Its advantage is a small footprint in terms of processing time and impact on incremental saves.
327328

328329
-----
329330

330331
.. attribute:: Page._isWrapped
331332

332-
Indicate whether :meth:`Page._wrapContents` may be required for object insertions in standard PDF geometry. Please note that this is a quick, basic check only: a value of *False* may still be a false alarm.
333+
Indicate whether :meth:`Page.wrapContents` may be required for object insertions in standard PDF geometry. Please note that this is a quick, basic check only: a value of *False* may still be a false alarm.
333334

334335
-----
335336

@@ -381,14 +382,22 @@ Yet others are handy, general-purpose utilities.
381382

382383
-----
383384

384-
.. method:: Page._cleanContents()
385+
.. method:: Page.cleanContents()
385386

386387
Clean and concatenate all :data:`contents` objects associated with this page. "Cleaning" includes syntactical corrections, standardizations and "pretty printing" of the contents stream. Discrepancies between :data:`contents` and :data:`resources` objects will also be corrected. See :meth:`Page._getContents` for more details.
387388

388389
Changed in version 1.16.0 Annotations are no longer implicitely cleaned by this method. Use :meth:`Annot._cleanContents` separately.
389390

390391
.. warning:: This is a complex function which may generate large amounts of new data and render other data unused. It is **not recommended** using it together with the **incremental save** option. Also note that the resulting singleton new */Contents* object is **uncompressed**. So you should save to a **new file** using options *"deflate=True, garbage=3"*.
391392

393+
-----
394+
395+
.. method:: Page.readContents()
396+
397+
*New in version 1.17.0.*
398+
Return the concatenation of all :data:`contents` objects associated with the page -- without cleaning or otherwise modifying them. Use this method whenever you need to parse this source in its entirety whithout having to bother how many separate contents objects exist.
399+
400+
392401
-----
393402

394403
.. method:: Annot._cleanContents()

docs/page.rst

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -216,7 +216,7 @@ In a nutshell, this is what you can do with PyMuPDF:
216216
:rtype: :ref:`Annot`
217217
:returns: the created annotation. It is drawn with line color red, no fill color and line width 1.
218218

219-
.. method:: addRedactAnnot(quad, text=None, fontname=None, fontsize=11, align=TEXT_ALIGN_LEFT, fill=(1, 1, 1), text_color=(0, 0, 0))
219+
.. method:: addRedactAnnot(quad, text=None, fontname=None, fontsize=11, align=TEXT_ALIGN_LEFT, fill=(1, 1, 1), text_color=(0, 0, 0), cross_out=True)
220220

221221
PDF only: *(new in version 1.16.11)* Add a redaction annotation. A redaction annotation identifies content to be removed from the document. Adding such an annotation is the first of two steps. It makes visible what will be removed in the subsequent step, :meth:`Page.apply_redactions`.
222222

@@ -230,12 +230,14 @@ In a nutshell, this is what you can do with PyMuPDF:
230230

231231
:arg int align: *(New in v1.16.12)* the horizontal alignment for the replacing text. See :meth:`insertTextbox` for available values. The vertical alignment is always (approximately) centered.
232232

233-
:arg sequence fill: *(New in v1.16.12)* the fill color of the rectangle after applying the redaction. The default is *white = (1, 1, 1)*, which is also taken if *None* is specified. *(Changed in v1.16.13)* To suppress any fill color, specify *False*. In this cases the rectangle remains transparent.
233+
:arg sequence fill: *(New in v1.16.12)* the fill color of the rectangle **after applying** the redaction. The default is *white = (1, 1, 1)*, which is also taken if *None* is specified. *(Changed in v1.16.13)* To suppress a fill color alltogether, specify *False*. In this cases the rectangle remains transparent.
234234

235235
:arg sequence text_color: *(New in v1.16.12)* the color of the replacing text. Default is *black = (0, 0, 0)*.
236236

237+
:arg bool cross_out: *(new in v1.17.2)* add two diagonal lines to the annotation rectangle.
238+
237239
:rtype: :ref:`Annot`
238-
:returns: the created annotation. The appearance of a redaction annotation cannot be changed (except for its rectangle). A redaction is displayed as a crossed-out transparent rectangle with red lines.
240+
:returns: the created annotation. *(Changed in v1.17.2)* Its standard appearance looks like a red rectangle (no fill color), optionally showing two diagonal lines. Colors, line width, dashing, opacity and blend mode can now be set and applied via :meth:`Annot.update` like with other annotations.
239241

240242
.. image:: images/img-redact.jpg
241243

0 commit comments

Comments
 (0)