Skip to content

Commit 389e947

Browse files
committed
upload v1.19.5
1 parent c033e10 commit 389e947

13 files changed

+212
-84
lines changed

README.md

+5-7
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
1-
# PyMuPDF 1.19.4
1+
# PyMuPDF 1.19.5
22

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

5-
Release date: January 01, 2022
5+
Release date: February 01, 2022
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

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

1212
# Introduction
1313

14-
PyMuPDF (current version 1.19.4) is a Python binding with support for [MuPDF](https://mupdf.com/) (current version 1.19.*), a lightweight PDF, XPS, and E-book viewer, renderer, and toolkit, which is maintained and developed by Artifex Software, Inc.
14+
PyMuPDF (current version 1.19.5) is a Python binding with support for [MuPDF](https://mupdf.com/) (current version 1.19.*), a lightweight PDF, XPS, and E-book viewer, renderer, and toolkit, which is maintained and developed by Artifex Software, Inc.
1515

1616
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.
1717

@@ -70,7 +70,7 @@ The latest changelog can be viewed [here](https://pymupdf.readthedocs.io/en/late
7070

7171
PyMuPDF **requires Python 3.6 or later**.
7272

73-
Python wheels exist for **Windows** (32bit and 64bit), **Linux** (64bit, Intel and ARM) and **Mac OSX** (64bit, Intel only), so it can be installed from [PyPI](https://pypi.org/search/?q=pymupdf) in the usual way:
73+
For versions 3.7 and up, Python wheels exist for **Windows** (32bit and 64bit), **Linux** (64bit, Intel and ARM) and **Mac OSX** (64bit, Intel only), so it can be installed from [PyPI](https://pypi.org/search/?q=pymupdf) in the usual way:
7474

7575
```
7676
python -m pip install --upgrade pip
@@ -87,11 +87,9 @@ There are **no mandatory** external dependencies. However, some **optional featu
8787

8888
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.
8989

90-
> Starting with v1.18.15, to minimize network traffic we no longer redundantly store wheels in this repository's `releases` folder. You can find older versions back to v1.9.2 on [PyPI](https://pypi.org/project/PyMuPDF/#history). Sources for every release continue to be stored in [here](https://github.com/pymupdf/PyMuPDF/releases).
91-
9290
Other platforms **require installation from sources**, follow [these](https://pymupdf.readthedocs.io/en/latest/installation.html) instructions in the documentation.
9391

94-
> **Note:** If `pip` cannot find a wheel that is compatible with your platform, it will automatically start an installation from sources - **_which will fail_** if MuPDF is not installed on your system.
92+
> **Note:** If `pip` cannot find a wheel that is compatible with your platform, it will automatically try an installation from sources - **_which will fail_** if MuPDF (including its sources) is not installed on your system.
9593
9694
This repo's folder [installation](https://github.com/pymupdf/PyMuPDF/tree/master/installation) contains several platform-specific source installation scripts contributed by users. You may also find the following Wiki pages useful:
9795

changes.txt

+25
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,31 @@
11
Change Log
22
===========
33

4+
------
5+
6+
**Changes in Version 1.19.5**
7+
8+
* **Fixed** `#1518 <https://github.com/pymupdf/PyMuPDF/issues/1518>`_. A limited "fix": in some cases, rectangles and quadrupels were not correctly encoded to support re-drawing by :ref:`Shape`.
9+
10+
* **Fixed** `#1521 <https://github.com/pymupdf/PyMuPDF/issues/1521>`_. This had the same ultimate reason behind issue #1510.
11+
12+
* **Fixed** `#1513 <https://github.com/pymupdf/PyMuPDF/issues/1513>`_. Some Optional Content functions did not support non-ASCII characters.
13+
14+
* **Fixed** `#1510 <https://github.com/pymupdf/PyMuPDF/issues/1510>`_. Support more soft-mask image subtypes.
15+
16+
* **Fixed** `#1507 <https://github.com/pymupdf/PyMuPDF/issues/1507>`_. Immunize against items in the outlines chain, that are ``"null"`` objects.
17+
18+
* **Fixed** re-opened `#1417 <https://github.com/pymupdf/PyMuPDF/issues/1417>`_. ("too many open files"). This was due to insufficient calls to MuPDF's ``fz_drop_document()``. This also fixes `#1550 <https://github.com/pymupdf/PyMuPDF/issues/1550>`_.
19+
20+
* **Fixed** several undocumented issues in relation to incorrectly setting the text span origin :data:`point_like`.
21+
22+
* **Fixed** undocumented error computing the character bbox in method :meth:`Page.get_texttrace` when text is **flipped** (as opposed to just rotated).
23+
24+
* **Added** items to the dictionary returned by :meth:`image_properties`: ``orientation`` and ``transform`` report the natural image orientation (EXIF data).
25+
26+
* **Added** method :meth:`Document.xref_copy`. It will make a given target PDF object an exact copy of a source object.
27+
28+
429
------
530

631
**Changes in Version 1.19.4**

fitz/__init__.py

+4-2
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,7 @@
7777
fitz.Document.subset_fonts = fitz.utils.subset_fonts
7878
fitz.Document.get_oc = fitz.utils.get_oc
7979
fitz.Document.set_oc = fitz.utils.set_oc
80+
fitz.Document.xref_copy = fitz.utils.xref_copy
8081

8182

8283
# ------------------------------------------------------------------------------
@@ -429,7 +430,7 @@ def deprecated_function(*args, **kw):
429430
_alias(fitz, "PaperSize", "paper_size")
430431
_alias(fitz, "PaperRect", "paper_rect")
431432
_alias(fitz, "paperSizes", "paper_sizes")
432-
_alias(fitz, "ImageProperties", "image_properties")
433+
_alias(fitz, "ImageProperties", "image_profile")
433434
_alias(fitz, "planishLine", "planish_line")
434435
_alias(fitz, "getTextLength", "get_text_length")
435436
_alias(fitz, "getTextlength", "get_text_length")
@@ -449,4 +450,5 @@ def deprecated_function(*args, **kw):
449450
64 if sys.maxsize > 2 ** 32 else 32,
450451
)
451452

452-
restore_aliases()
453+
if VersionBind.startswith("1.19"): # don't generate aliases after this
454+
restore_aliases()

fitz/fitz.i

+70-28
Original file line numberDiff line numberDiff line change
@@ -282,6 +282,9 @@ struct Document
282282
{
283283
DEBUGMSG1("Document");
284284
fz_document *this_doc = (fz_document *) $self;
285+
while (this_doc->refs > 1) {
286+
fz_drop_document(gctx, this_doc);
287+
}
285288
fz_drop_document(gctx, this_doc);
286289
DEBUGMSG2;
287290
}
@@ -764,8 +767,11 @@ struct Document
764767
if (!first) goto finished;
765768
xrefs = PyList_New(0); // pre-allocate an empty list
766769
xrefs = JM_outline_xrefs(gctx, first, xrefs);
767-
Py_ssize_t i, n = PySequence_Size(xrefs);
770+
Py_ssize_t i, n = PySequence_Size(xrefs), m = PySequence_Size(items);
768771
if (!n) goto finished;
772+
if (n != m) {
773+
THROWMSG(gctx, "internal error finding outline xrefs");
774+
}
769775
int xref;
770776
771777
// update all TOC item dictionaries
@@ -3832,9 +3838,9 @@ if basestate:
38323838
case (2): type = "radiobox"; break;
38333839
default: type = "label"; break;
38343840
}
3835-
PyObject *item = Py_BuildValue("{s:i,s:s,s:i,s:s,s:O,s:O}",
3841+
PyObject *item = Py_BuildValue("{s:i,s:N,s:i,s:s,s:N,s:N}",
38363842
"number", i,
3837-
"text", info.text,
3843+
"text", JM_EscapeStrFromStr(info.text),
38383844
"depth", info.depth,
38393845
"type", type,
38403846
"on", JM_BOOL(info.selected),
@@ -6221,7 +6227,7 @@ def get_oc_items(self) -> list:
62216227
if rect == None:
62226228
return self.cropbox
62236229
mb = self.mediabox
6224-
return Rect(rect[0], mb.y1 - rect[1], rect[2], mb.y1 - rect[3])
6230+
return Rect(rect[0], mb.y1 - rect[3], rect[2], mb.y1 - rect[1])
62256231
62266232
@property
62276233
def trimbox(self):
@@ -6230,7 +6236,7 @@ def get_oc_items(self) -> list:
62306236
if rect == None:
62316237
return self.cropbox
62326238
mb = self.mediabox
6233-
return Rect(rect[0], mb.y1 - rect[1], rect[2], mb.y1 - rect[3])
6239+
return Rect(rect[0], mb.y1 - rect[3], rect[2], mb.y1 - rect[1])
62346240
62356241
@property
62366242
def bleedbox(self):
@@ -6239,7 +6245,7 @@ def get_oc_items(self) -> list:
62396245
if rect == None:
62406246
return self.cropbox
62416247
mb = self.mediabox
6242-
return Rect(rect[0], mb.y1 - rect[1], rect[2], mb.y1 - rect[3])
6248+
return Rect(rect[0], mb.y1 - rect[3], rect[2], mb.y1 - rect[1])
62436249
62446250
def _set_pagebox(self, boxtype, rect):
62456251
doc = self.parent
@@ -6713,7 +6719,18 @@ def insert_font(self, fontname="helv", fontfile=None, fontbuffer=None,
67136719
del pymupdf_fonts
67146720
67156721
# install the font for the page
6716-
val = self._insertFont(fontname, bfname, fontfile, fontbuffer, set_simple, idx,
6722+
if fontfile != None:
6723+
if type(fontfile) is str:
6724+
fontfile_str = fontfile
6725+
elif hasattr(fontfile, "absolute"):
6726+
fontfile_str = str(fontfile)
6727+
elif hasattr(fontfile, "name"):
6728+
fontfile_str = fontfile.name
6729+
else:
6730+
raise ValueError("bad fontfile")
6731+
else:
6732+
fontfile_str = None
6733+
val = self._insertFont(fontname, bfname, fontfile_str, fontbuffer, set_simple, idx,
67176734
wmode, serif, encoding, CJK_number)
67186735
67196736
if not val: # did not work, error return
@@ -7111,6 +7128,9 @@ Pixmap(PDFdoc, xref) - from an image xref in a PDF document.
71117128
fz_pixmap *src_pix = (fz_pixmap *) spix;
71127129
fz_try(gctx) {
71137130
fz_irect bbox = JM_irect_from_py(clip);
7131+
if (clip != Py_None && (fz_is_infinite_irect(bbox) || fz_is_empty_irect(bbox))) {
7132+
THROWMSG(gctx, "bad clip parameter");
7133+
}
71147134
if (!fz_is_infinite_irect(bbox)) {
71157135
pm = fz_scale_pixmap(gctx, src_pix, src_pix->x, src_pix->y, w, h, &bbox);
71167136
} else {
@@ -7266,7 +7286,9 @@ Pixmap(PDFdoc, xref) - from an image xref in a PDF document.
72667286
THROWMSG(gctx, "bad xref");
72677287
ref = pdf_new_indirect(gctx, pdf, xref, 0);
72687288
type = pdf_dict_get(gctx, ref, PDF_NAME(Subtype));
7269-
if (!pdf_name_eq(gctx, type, PDF_NAME(Image)))
7289+
if (!pdf_name_eq(gctx, type, PDF_NAME(Image)) &&
7290+
!pdf_name_eq(gctx, type, PDF_NAME(Alpha)) &&
7291+
!pdf_name_eq(gctx, type, PDF_NAME(Luminosity)))
72707292
THROWMSG(gctx, "not an image");
72717293
img = pdf_load_image(gctx, pdf, ref);
72727294
pix = fz_get_pixmap_from_image(gctx, img, NULL, NULL, NULL, NULL);
@@ -8159,12 +8181,14 @@ Includes alpha byte if applicable.""")
81598181
return self
81608182
81618183
def __exit__(self, *args):
8162-
self.__swig_destroy__(self)
8184+
if getattr(self, "thisown", False):
8185+
self.__swig_destroy__(self)
81638186
81648187
def __del__(self):
81658188
if not type(self) is Pixmap:
81668189
return
8167-
self.__swig_destroy__(self)
8190+
if getattr(self, "thisown", False):
8191+
self.__swig_destroy__(self)
81688192
81698193
%}
81708194
}
@@ -8440,7 +8464,8 @@ struct Annot
84408464
~Annot()
84418465
{
84428466
DEBUGMSG1("Annot");
8443-
pdf_drop_annot(gctx, (pdf_annot *) $self);
8467+
pdf_annot *this_annot = (pdf_annot *) $self;
8468+
pdf_drop_annot(gctx, this_annot);
84448469
DEBUGMSG2;
84458470
}
84468471
//----------------------------------------------------------------
@@ -10313,7 +10338,8 @@ struct Link
1031310338
%extend {
1031410339
~Link() {
1031510340
DEBUGMSG1("Link");
10316-
fz_drop_link(gctx, (fz_link *) $self);
10341+
fz_link *this_link = (fz_link *) $self;
10342+
fz_drop_link(gctx, this_link);
1031710343
DEBUGMSG2;
1031810344
}
1031910345
@@ -10530,7 +10556,8 @@ struct DisplayList {
1053010556
{
1053110557
~DisplayList() {
1053210558
DEBUGMSG1("DisplayList");
10533-
fz_drop_display_list(gctx, (fz_display_list *) $self);
10559+
fz_display_list *this_dl = (fz_display_list *) $self;
10560+
fz_drop_display_list(gctx, this_dl);
1053410561
DEBUGMSG2;
1053510562
}
1053610563
FITZEXCEPTION(DisplayList, !result)
@@ -10618,7 +10645,8 @@ struct DisplayList {
1061810645
def __del__(self):
1061910646
if not type(self) is DisplayList:
1062010647
return
10621-
self.__swig_destroy__(self)
10648+
if getattr(self, "thisown", False):
10649+
self.__swig_destroy__(self)
1062210650
%}
1062310651
}
1062410652
};
@@ -10631,7 +10659,8 @@ struct TextPage {
1063110659
~TextPage()
1063210660
{
1063310661
DEBUGMSG1("TextPage");
10634-
fz_drop_stext_page(gctx, (fz_stext_page *) $self);
10662+
fz_stext_page *this_tp = (fz_stext_page *) $self;
10663+
fz_drop_stext_page(gctx, this_tp);
1063510664
DEBUGMSG2;
1063610665
}
1063710666
@@ -11146,8 +11175,10 @@ struct TextPage {
1114611175
return val
1114711176
1114811177
def __del__(self):
11149-
if not type(self) is TextPage: return
11150-
self.__swig_destroy__(self)
11178+
if not type(self) is TextPage:
11179+
return
11180+
if getattr(self, "thisown", False):
11181+
self.__swig_destroy__(self)
1115111182
%}
1115211183
}
1115311184
};
@@ -11162,7 +11193,8 @@ struct Graftmap
1116211193
~Graftmap()
1116311194
{
1116411195
DEBUGMSG1("Graftmap");
11165-
pdf_drop_graft_map(gctx, (pdf_graft_map *) $self);
11196+
pdf_graft_map *this_gm = (pdf_graft_map *) $self;
11197+
pdf_drop_graft_map(gctx, this_gm);
1116611198
DEBUGMSG2;
1116711199
}
1116811200
@@ -11183,8 +11215,10 @@ struct Graftmap
1118311215
1118411216
%pythoncode %{
1118511217
def __del__(self):
11186-
if not type(self) is Graftmap: return
11187-
self.__swig_destroy__(self)
11218+
if not type(self) is Graftmap:
11219+
return
11220+
if getattr(self, "thisown", False):
11221+
self.__swig_destroy__(self)
1118811222
%}
1118911223
}
1119011224
};
@@ -11199,7 +11233,8 @@ struct TextWriter
1119911233
~TextWriter()
1120011234
{
1120111235
DEBUGMSG1("TextWriter");
11202-
fz_drop_text(gctx, (fz_text *) $self);
11236+
fz_text *this_tw = (fz_text *) $self;
11237+
fz_drop_text(gctx, this_tw);
1120311238
DEBUGMSG2;
1120411239
}
1120511240
@@ -11488,8 +11523,10 @@ struct TextWriter
1148811523
}
1148911524
%pythoncode %{
1149011525
def __del__(self):
11491-
if not type(self) is TextWriter: return
11492-
self.__swig_destroy__(self)
11526+
if not type(self) is TextWriter:
11527+
return
11528+
if getattr(self, "thisown", False):
11529+
self.__swig_destroy__(self)
1149311530
%}
1149411531
}
1149511532
};
@@ -11505,7 +11542,8 @@ struct Font
1150511542
~Font()
1150611543
{
1150711544
DEBUGMSG1("Font");
11508-
fz_drop_font(gctx, (fz_font *) $self);
11545+
fz_font *this_font = (fz_font *) $self;
11546+
fz_drop_font(gctx, this_font);
1150911547
DEBUGMSG2;
1151011548
}
1151111549
@@ -11833,8 +11871,10 @@ struct Font
1183311871
return "Font('%s')" % self.name
1183411872
1183511873
def __del__(self):
11836-
if not type(self) is Font: return
11837-
self.__swig_destroy__(self)
11874+
if not type(self) is Font:
11875+
return
11876+
if getattr(self, "thisown", False):
11877+
self.__swig_destroy__(self)
1183811878
%}
1183911879
}
1184011880
};
@@ -12846,8 +12886,10 @@ def _le_rclosedarrow(self, annot, p1, p2, lr, fill_color):
1284612886
return ap
1284712887
1284812888
def __del__(self):
12849-
if not type(self) is Tools: return
12850-
self.__swig_destroy__(self)
12889+
if not type(self) is Tools:
12890+
return
12891+
if getattr(self, "thisown", False):
12892+
self.__swig_destroy__(self)
1285112893
%}
1285212894
}
1285312895
};

0 commit comments

Comments
 (0)