Skip to content

Commit 521640a

Browse files
committed
upload v1.19.3
1 parent 52b80b5 commit 521640a

11 files changed

+118
-32
lines changed

README.md

+5-9
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

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

5-
Release date: December 15, 2021
5+
Release date: December 12, 2021
66

77
On **[PyPI](https://pypi.org/project/PyMuPDF)** since August 2016: [![Downloads](https://static.pepy.tech/personalized-badge/pymupdf?period=total&units=international_system&left_color=black&right_color=orange&left_text=Downloads)](https://pepy.tech/project/pymupdf)
88

@@ -60,11 +60,7 @@ Have a look at the basic [demos](https://github.com/pymupdf/PyMuPDF-Utilities/tr
6060
Documentation is written using Sphinx and is available in various formats from the following sources. It currently is a combination of reference guide and user manual. For a **quick start** look at the [tutorial](https://pymupdf.readthedocs.io/en/latest/tutorial.html) and the [recipes](https://pymupdf.readthedocs.io/en/latest/faq.html) chapters.
6161

6262
* You can view it online at [Read the Docs](https://readthedocs.org/projects/pymupdf/). This site also provides download options for PDF.
63-
<<<<<<< Updated upstream
64-
* The search function on Read the Docs does not work for me currently. If you want a working searchable local version, please download a zipped HTML for [here](https://github.com/pymupdf/PyMuPDF-optional-material/tree/master/doc/pymupdf.zip).
65-
=======
6663
* The search function on Read the Docs does not work for me currently. If you want a working searchable local version, please download a zipped HTML from [here](https://github.com/pymupdf/PyMuPDF-optional-material/tree/master/doc/pymupdf.zip).
67-
>>>>>>> Stashed changes
6864
* Find a Windows help file [here](https://github.com/pymupdf/PyMuPDF-optional-material/tree/master/doc/PyMuPDF.chm).
6965

7066
The latest changelog can be viewed [here](https://pymupdf.readthedocs.io/en/latest/changes.html).
@@ -81,12 +77,12 @@ python -m pip install --upgrade pip
8177
python -m pip install --upgrade pymupdf
8278
```
8379

84-
There are **no mandatory** external dependencies. However, some **optional features** become available if additional packages are installed:
80+
There are **no mandatory** external dependencies. However, some **optional features** become available only if additional packages are installed:
8581

8682
* [Pillow](https://pypi.org/project/Pillow/) for using pillow image output directly from PyMuPDF
87-
* [fontTools](https://pypi.org/project/fonttools/) for creating font subsets
88-
* [pymupdf-fonts](https://pypi.org/project/pymupdf-fonts/) contains some nice fonts for your text output
89-
* [Tesseract-OCR](https://github.com/tesseract-ocr/tesseract) for optical character recognition in images and document pages. Tesseract is separate software, not a Python package. To enable OCR functions in PyMuPDF, the system environment variable `"TESSDATA_PREFIX"` must be defined and contain the `tessdata` folder name of the Tesseract installation location
83+
* [fontTools](https://pypi.org/project/fonttools/) for creating font subsets.
84+
* [pymupdf-fonts](https://pypi.org/project/pymupdf-fonts/) contains some nice fonts for your text output.
85+
* [Tesseract-OCR](https://github.com/tesseract-ocr/tesseract) for optical character recognition in images and document pages. Tesseract is separate software, not a Python package. To enable OCR functions in PyMuPDF, the system environment variable `"TESSDATA_PREFIX"` must be defined and contain the `tessdata` folder name of the Tesseract installation location.
9086

9187

9288
Older wheels - also with support for older Python versions - can be found [here](https://github.com/pymupdf/PyMuPDF-Optional-Material/tree/master/wheels-upto-Py3.5>) and on PyPI.

changes.rst

+10
Original file line numberDiff line numberDiff line change
@@ -8,13 +8,23 @@ Change Log
88
This patch version implements minor improvements for :ref:`Pixmap` and also some important fixes.
99

1010
* **Fixed** `#1351 <https://github.com/pymupdf/PyMuPDF/discussions/1351>`_. Reverted code that introduced the memory growth in v1.18.15.
11+
1112
* **Fixed** `#1417 <https://github.com/pymupdf/PyMuPDF/discussions/1417>`_. Developped circumvention for growth of open file handles using :meth:`Document.insert_pdf`.
13+
1214
* **Fixed** `#1418 <https://github.com/pymupdf/PyMuPDF/discussions/1418>`_. Developped circumvention for memory growth using :meth:`Document.insert_pdf`.
15+
1316
* **Fixed** `#1430 <https://github.com/pymupdf/PyMuPDF/discussions/1430>`_. Developped circumvention for mass pixmap generations of document pages.
17+
1418
* **Fixed** `#1433 <https://github.com/pymupdf/PyMuPDF/discussions/1433>`_. Solves a bbox error for some Type 3 font in PyMuPDF text processing.
19+
1520
* **Added** :meth:`Pixmap.color_topusage` to determine the share of the most frequently used color. Solves `#1397 <https://github.com/pymupdf/PyMuPDF/discussions/1397>`_.
21+
1622
* **Added** :meth:`Pixmap.warp` which makes a new pixmap from a given arbitrary convex quad inside the pixmap.
23+
24+
* **Added** :attr:`Annot.irt_xref` and :meth:`Annot.set_irt_xref` to inquire or set the `/IRT` ("In Responde To") property of an annotation. Implements `#1450 <https://github.com/pymupdf/PyMuPDF/discussions/1450>`_.
25+
1726
* **Added** :meth:`Rect.torect` and :meth:`IRect.torect` which compute a matrix that transforms to a given other rectangle.
27+
1828
* **Changed** :meth:`Pixmap.color_count` to also return the count of each color.
1929
* **Changed** :meth:`Page.get_texttrace` to also return correct span and character bboxes if ``span["dir"] != (1, 0)``.
2030

docs/annot.rst

+19
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ There is a parent-child relationship between an annotation and its page. If the
3232
:meth:`Annot.set_blendmode` set annotation's blend mode
3333
:meth:`Annot.set_colors` set annotation's colors
3434
:meth:`Annot.set_flags` set annotation's flags field
35+
:meth:`Annot.set_irt_xref` define the annotation to being "In Response To"
3536
:meth:`Annot.set_name` set annotation's name field
3637
:meth:`Annot.set_oc` set :data:`xref` to an :data:`OCG` / :data:`OCMD`
3738
:meth:`Annot.set_opacity` change transparency
@@ -46,6 +47,7 @@ There is a parent-child relationship between an annotation and its page. If the
4647
:attr:`Annot.colors` border / background and fill colors
4748
:attr:`Annot.flags` annotation flags
4849
:attr:`Annot.has_popup` whether annotation has a Popup
50+
:attr:`Annot.irt_xref` annotation to which this one responds
4951
:attr:`Annot.info` various information
5052
:attr:`Annot.is_open` whether annotation or its Popup is open
5153
:attr:`Annot.line_ends` start / end appearance of line-type annotations
@@ -173,6 +175,17 @@ There is a parent-child relationship between an annotation and its page. If the
173175
:returns: zero or the xref of an OCG (or OCMD).
174176

175177

178+
.. method:: set_irt_xref(xref)
179+
180+
* New in v1.19.3
181+
182+
Set annotation to be "In Response To" another one.
183+
184+
:arg int xref: The :data:`xref` of another annotation.
185+
186+
.. note:: Must refer to an existing annotation on this page. Setting this property requires no subsequent ``update()``.
187+
188+
176189
.. method:: set_open(value)
177190

178191
*(New in v1.18.4)*
@@ -477,6 +490,12 @@ There is a parent-child relationship between an annotation and its page. If the
477490

478491
:rtype: int
479492

493+
.. attribute:: irt_xref
494+
495+
The PDF :data:`xref` of an annotation to which this one responds. Return zero if this is no response annotation.
496+
497+
:rtype: int
498+
480499
.. attribute:: popup_xref
481500

482501
The PDF :data:`xref` of the associated Popup annotation. Zero if non-existent.

docs/changes.rst

+10
Original file line numberDiff line numberDiff line change
@@ -8,13 +8,23 @@ Change Log
88
This patch version implements minor improvements for :ref:`Pixmap` and also some important fixes.
99

1010
* **Fixed** `#1351 <https://github.com/pymupdf/PyMuPDF/discussions/1351>`_. Reverted code that introduced the memory growth in v1.18.15.
11+
1112
* **Fixed** `#1417 <https://github.com/pymupdf/PyMuPDF/discussions/1417>`_. Developped circumvention for growth of open file handles using :meth:`Document.insert_pdf`.
13+
1214
* **Fixed** `#1418 <https://github.com/pymupdf/PyMuPDF/discussions/1418>`_. Developped circumvention for memory growth using :meth:`Document.insert_pdf`.
15+
1316
* **Fixed** `#1430 <https://github.com/pymupdf/PyMuPDF/discussions/1430>`_. Developped circumvention for mass pixmap generations of document pages.
17+
1418
* **Fixed** `#1433 <https://github.com/pymupdf/PyMuPDF/discussions/1433>`_. Solves a bbox error for some Type 3 font in PyMuPDF text processing.
19+
1520
* **Added** :meth:`Pixmap.color_topusage` to determine the share of the most frequently used color. Solves `#1397 <https://github.com/pymupdf/PyMuPDF/discussions/1397>`_.
21+
1622
* **Added** :meth:`Pixmap.warp` which makes a new pixmap from a given arbitrary convex quad inside the pixmap.
23+
24+
* **Added** :attr:`Annot.irt_xref` and :meth:`Annot.set_irt_xref` to inquire or set the `/IRT` ("In Responde To") property of an annotation. Implements `#1450 <https://github.com/pymupdf/PyMuPDF/discussions/1450>`_.
25+
1726
* **Added** :meth:`Rect.torect` and :meth:`IRect.torect` which compute a matrix that transforms to a given other rectangle.
27+
1828
* **Changed** :meth:`Pixmap.color_count` to also return the count of each color.
1929
* **Changed** :meth:`Page.get_texttrace` to also return correct span and character bboxes if ``span["dir"] != (1, 0)``.
2030

docs/document.rst

+3-1
Original file line numberDiff line numberDiff line change
@@ -1169,6 +1169,8 @@ For details on **embedded files** refer to Appendix 3.
11691169

11701170
.. method:: insert_pdf(docsrc, from_page=-1, to_page=-1, start_at=-1, rotate=-1, links=True, annots=True, show_progress=0, final=1)
11711171

1172+
* Changed in v1.19.3 - as a fix to issue `#537 <https://github.com/pymupdf/PyMuPDF/issues/537>`_, form fields are always excluded.
1173+
11721174
PDF only: Copy the page range **[from_page, to_page]** (including both) of PDF document *docsrc* into the current one. Inserts will start with page number *start_at*. Value -1 indicates default values. All pages thus copied will be rotated as specified. Links and annotations can be excluded in the target, see below. All page numbers are 0-based.
11731175

11741176
:arg docsrc: An opened PDF *Document* which must not be the current document. However, it may refer to the same underlying file.
@@ -1183,7 +1185,7 @@ For details on **embedded files** refer to Appendix 3.
11831185
:arg int rotate: All copied pages will be rotated by the provided value (degrees, integer multiple of 90).
11841186

11851187
:arg bool links: Choose whether (internal and external) links should be included in the copy. Default is *True*. Internal links to outside the copied page range are **always excluded**.
1186-
:arg bool annots: *(new in version 1.16.1)* choose whether annotations should be included in the copy.
1188+
:arg bool annots: *(new in version 1.16.1)* choose whether annotations should be included in the copy. *(Fixed in v1.19.3)* Form fields can never be copied.
11871189
:arg int show_progress: *(new in version 1.17.7)* specify an interval size greater zero to see progress messages on ``sys.stdout``. After each interval, a message like ``Inserted 30 of 47 pages.`` will be printed.
11881190
:arg int final: *(new in v1.18.0)* controls whether the list of already copied objects should be **dropped** after this method, default *True*. Set it to 0 except for the last one of multiple insertions from the same source PDF. This saves target file size and speeds up execution considerably.
11891191

docs/irect.rst

+3-3
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ IRect is a rectangular bounding box, very similar to :ref:`Rect`, except that al
1414
:meth:`IRect.intersect` common part with another rectangle
1515
:meth:`IRect.intersects` checks for non-empty intersection
1616
:meth:`IRect.morph` transform with a point and a matrix
17-
:meth:`IRect.torect` the matrix that converts to another rectangle
17+
:meth:`IRect.torect` matrix that transforms to another rectangle
1818
:meth:`IRect.norm` the Euclidean norm
1919
:meth:`IRect.normalize` makes a rectangle finite
2020
:attr:`IRect.bottom_left` bottom left point, synonym *bl*
@@ -89,11 +89,11 @@ IRect is a rectangular bounding box, very similar to :ref:`Rect`, except that al
8989

9090
*(New in version 1.19.3)*
9191

92-
Compute the matrix which transform this rectangle to a given one. See same-naed method of :ref:`Rect`.
92+
Compute the matrix which transforms this rectangle to a given one. See :meth:`Rect.torect`.
9393

9494
:arg rect_like rect: the target rectangle. Must not be empty or infinite.
9595
:rtype: :ref:`Matrix`
96-
:returns: a matrix ``mat`` such ``self * mat = rect``. Can for example be used to switch between page coordinates and corresponding positions of its pixmap.
96+
:returns: a matrix ``mat`` such that ``self * mat = rect``. Can for example be used to transform between the page and the pixmap coordinates.
9797

9898

9999
.. method:: morph(fixpoint, matrix)

docs/rect.rst

+11-9
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ The following remarks are also valid for :ref:`IRect` objects:
5757
:meth:`Rect.intersect` common part with another rectangle
5858
:meth:`Rect.intersects` checks for non-empty intersections
5959
:meth:`Rect.morph` transform with a point and a matrix
60-
:meth:`Rect.torect` the matrix that converts to another rectangle
60+
:meth:`Rect.torect` the matrix that transforms to another rectangle
6161
:meth:`Rect.norm` the Euclidean norm
6262
:meth:`Rect.normalize` makes a rectangle valid
6363
:meth:`Rect.round` create smallest :ref:`Irect` containing rectangle
@@ -183,26 +183,28 @@ The following remarks are also valid for :ref:`IRect` objects:
183183

184184
*(New in version 1.19.3)*
185185

186-
Compute the matrix which transform this rectangle to a given one.
186+
Compute the matrix which transforms this rectangle to a given one.
187187

188188
:arg rect_like rect: the target rectangle. Must not be empty or infinite.
189189
:rtype: :ref:`Matrix`
190-
:returns: a matrix ``mat`` such ``self * mat = rect``. Can for example be used to switch between page coordinates and corresponding positions of its pixmap.
190+
:returns: a matrix ``mat`` such that ``self * mat = rect``. Can for example be used to transform between the page and the pixmap coordinates.
191191

192-
.. note:: Suppose you want to check whether any of the words "pixmap" is located in an area with the same color as the text (e.g. white on white). We can find out whether the text's area mostly consists of pixels of identical color:
192+
.. note:: Suppose you want to check whether any of the words "pixmap" is invisible, because the text color equals the ambient color -- e.g. white on white. We make a pixmap and check the "color environment" of each word:
193193

194+
>>> # make a pixmap of the page
194195
>>> pix = page.get_pixmap(dpi=150)
196+
>>> # make a matrix that transforms to pixmap coordinates
195197
>>> mat = page.rect.torect(pix.irect)
196-
>>> # "mat" converts page coordinates to pixmap coordinates
198+
>>> # search for text locations
197199
>>> rlist = page.search_for("pixmap")
198-
>>> # then the following makes rectangles on the page's pixmap,
199-
>>> # wich each encircle one "pixmap" occurrence:
200+
>>> # check color environment of each occurrence
201+
>>> # we will check for "almost unicolor"
200202
>>> for r in rlist:
201203
if pix.color_topusage(clip=r * mat) > 0.95:
202-
print("Word 'pixmap' is invisible!")
204+
print("'pixmap' invisible here:", r)
203205
>>>
204206

205-
Method :meth:`Pixmap.color_topusage` computes the percentage of pixels showing the same color.
207+
Method :meth:`Pixmap.color_topusage` computes the percentage of pixels showing the same color.
206208

207209

208210
.. method:: morph(fixpoint, matrix)

docs/version.rst

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
Covered Version
22
--------------------
33

4-
This documentation covers PyMuPDF v1.19.2 features as of **2021-11-20 00:00:01**.
4+
This documentation covers PyMuPDF v1.19.3 features as of **2021-12-12 06:51:56**.
55

66
.. note:: The major and minor versions of **PyMuPDF** and **MuPDF** will always be the same. Only the third qualifier (patch level) may deviate from that of MuPDF.

fitz/fitz.i

+42
Original file line numberDiff line numberDiff line change
@@ -8370,6 +8370,48 @@ struct Annot
83708370
return Py_BuildValue("i", pdf_to_num(gctx, annot_obj));
83718371
}
83728372
8373+
//----------------------------------------------------------------
8374+
// annotation get IRT xref number
8375+
//----------------------------------------------------------------
8376+
PARENTCHECK(irt_xref, """annotation IRT xref""")
8377+
%pythoncode %{@property%}
8378+
PyObject *irt_xref()
8379+
{
8380+
pdf_annot *annot = (pdf_annot *) $self;
8381+
pdf_obj *annot_obj = pdf_annot_obj(gctx, annot);
8382+
pdf_obj *irt = pdf_dict_get(gctx, annot_obj, PDF_NAME(IRT));
8383+
if (!irt) return PyLong_FromLong(0);
8384+
return PyLong_FromLong((long) pdf_to_num(gctx, irt));
8385+
}
8386+
8387+
//----------------------------------------------------------------
8388+
// annotation set IRT xref number
8389+
//----------------------------------------------------------------
8390+
FITZEXCEPTION(set_irt_xref, !result)
8391+
PARENTCHECK(set_irt_xref, """Set annotation IRT xref""")
8392+
PyObject *set_irt_xref(int xref)
8393+
{
8394+
fz_try(gctx) {
8395+
pdf_annot *annot = (pdf_annot *) $self;
8396+
pdf_obj *annot_obj = pdf_annot_obj(gctx, annot);
8397+
pdf_page *page = pdf_annot_page(gctx, annot);
8398+
if (!INRANGE(xref, 1, pdf_xref_len(gctx, page->doc) - 1))
8399+
THROWMSG(gctx, "bad xref");
8400+
pdf_obj *irt = pdf_new_indirect(gctx, page->doc, xref, 0);
8401+
pdf_obj *subt = pdf_dict_get(gctx, irt, PDF_NAME(Subtype));
8402+
int irt_subt = pdf_annot_type_from_string(gctx, pdf_to_name(gctx, subt));
8403+
if (irt_subt < 0) {
8404+
pdf_drop_obj(gctx, irt);
8405+
THROWMSG(gctx, "xref not an annot");
8406+
}
8407+
pdf_dict_put_drop(gctx, annot_obj, PDF_NAME(IRT), irt);
8408+
}
8409+
fz_catch(gctx) {
8410+
return NULL;
8411+
}
8412+
Py_RETURN_NONE;
8413+
}
8414+
83738415
//----------------------------------------------------------------
83748416
// annotation get AP/N Matrix
83758417
//----------------------------------------------------------------

0 commit comments

Comments
 (0)