Skip to content

Commit 6f9a8fb

Browse files
committed
upload v1.16.7
1 parent e095b04 commit 6f9a8fb

11 files changed

+48
-65
lines changed

PKG-INFO

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
Metadata-Version: 1.1
22
Name: PyMuPDF
3-
Version: 1.16.6
3+
Version: 1.16.7
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: November 5, 2019
12+
Release date: November 10, 2019
1313

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

23-
This is **version 1.16.6 of PyMuPDF**, a Python binding for `MuPDF <http://mupdf.com/>`_ - "a lightweight PDF and XPS viewer".
23+
This is **version 1.16.7 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

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
1-
# PyMuPDF 1.16.6
1+
# PyMuPDF 1.16.7
22

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

5-
Release date: November 5, 2019
5+
Release date: November 10, 2019
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.6 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.7 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

doc/PyMuPDF.pdf

33.7 KB
Binary file not shown.

doc/html.zip

57 KB
Binary file not shown.

fitz/fitz.i

+14-32
Original file line numberDiff line numberDiff line change
@@ -1585,15 +1585,11 @@ if len(pyliste) == 0 or min(pyliste) not in range(len(self)) or max(pyliste) not
15851585
15861586
fz_buffer *buffer = NULL, *freebuf = NULL;
15871587
fz_var(freebuf);
1588-
fz_pixmap *pix = NULL;
1589-
fz_var(pix);
15901588
pdf_obj *obj = NULL;
15911589
PyObject *rc = NULL;
15921590
const char *ext = NULL;
15931591
fz_image *image = NULL;
15941592
fz_var(image);
1595-
fz_output *out = NULL;
1596-
fz_var(out);
15971593
fz_compressed_buffer *cbuf = NULL;
15981594
int type = FZ_IMAGE_UNKNOWN, n = 0, xres = 0, yres = 0, is_jpx = 0;
15991595
int smask = 0, width = 0, height = 0, bpc = 0;
@@ -1652,27 +1648,9 @@ if len(pyliste) == 0 or min(pyliste) not in range(len(self)) or max(pyliste) not
16521648
{
16531649
ext = JM_image_extension(type);
16541650
}
1655-
else // need a pixmap to make a PNG buffer
1651+
else // need to make a PNG buffer
16561652
{
1657-
pix = fz_get_pixmap_from_image(gctx, image,
1658-
NULL, NULL, NULL, NULL);
1659-
n = pix->n;
1660-
// only gray & rgb pixmaps support PNG!
1661-
if (pix->colorspace &&
1662-
pix->colorspace != fz_device_gray(gctx) &&
1663-
pix->colorspace != fz_device_rgb(gctx))
1664-
{
1665-
fz_color_params color_params = {0};
1666-
fz_pixmap *pix2 = fz_convert_pixmap(gctx, pix,
1667-
fz_device_rgb(gctx), NULL, NULL, color_params, 1);
1668-
fz_drop_pixmap(gctx, pix);
1669-
pix = pix2;
1670-
}
1671-
1672-
freebuf = fz_new_buffer(gctx, 2048);
1673-
out = fz_new_output_with_buffer(gctx, freebuf);
1674-
fz_write_pixmap_as_png(gctx, out, pix);
1675-
buffer = freebuf;
1653+
buffer = freebuf = fz_new_buffer_from_image_as_png(gctx, image, fz_default_color_params);
16761654
ext = "png";
16771655
}
16781656
@@ -1705,8 +1683,6 @@ if len(pyliste) == 0 or min(pyliste) not in range(len(self)) or max(pyliste) not
17051683
{
17061684
fz_drop_image(gctx, image);
17071685
fz_drop_buffer(gctx, freebuf);
1708-
fz_drop_output(gctx, out);
1709-
fz_drop_pixmap(gctx, pix);
17101686
pdf_drop_obj(gctx, obj);
17111687
}
17121688
@@ -3349,15 +3325,15 @@ if val:
33493325
val.parent._annot_refs[id(val)] = val
33503326
annot._erase()
33513327
%}
3352-
%feature("autodoc","Delete annot if PDF and return next one.") deleteAnnot;
3328+
%feature("autodoc","Delete annot and return next one.") deleteAnnot;
33533329
struct pdf_annot_s *deleteAnnot(struct pdf_annot_s *annot)
33543330
{
33553331
pdf_page *page = pdf_page_from_fz_page(gctx, $self);
33563332
pdf_annot *irt_annot = NULL;
3357-
while (1)
3333+
while (1) // first loop through all /IRT annots and remove them
33583334
{
33593335
irt_annot = JM_find_annot_irt(gctx, annot);
3360-
if (!irt_annot)
3336+
if (!irt_annot) // no more there
33613337
break;
33623338
JM_delete_annot(gctx, page, irt_annot);
33633339
}
@@ -6803,10 +6779,16 @@ struct Tools
68036779
return PyUnicode_FromString(FZ_VERSION);
68046780
}
68056781
6806-
%pythoncode %{property%}
6807-
%pythonappend mupdf_warnings %{val = "\n".join(val)%}
6808-
PyObject *mupdf_warnings()
6782+
%feature("autodoc","Return the MuPDF warnings store.") mupdf_warnings;
6783+
%pythonappend mupdf_warnings
6784+
%{
6785+
val = "\n".join(val)
6786+
if reset:
6787+
self.reset_mupdf_warnings()
6788+
%}
6789+
PyObject *mupdf_warnings(int reset=1)
68096790
{
6791+
Py_INCREF(JM_mupdf_warnings_store);
68106792
return JM_mupdf_warnings_store;
68116793
}
68126794

fitz/helper-annot.i

+12-4
Original file line numberDiff line numberDiff line change
@@ -244,6 +244,11 @@ PyObject *JM_annot_colors(fz_context *ctx, pdf_obj *annot_obj)
244244
return res;
245245
}
246246

247+
//----------------------------------------------------------------------------
248+
// delete an annotation using mupdf functions, but first delete the /AP and
249+
// /Popup dict keys in the annot->obj. Also remove the 'Popup' annotation
250+
// from the page's /Annots array which may exist.
251+
//----------------------------------------------------------------------------
247252
void JM_delete_annot(fz_context *ctx, pdf_page *page, pdf_annot *annot)
248253
{
249254
if (!annot) return;
@@ -252,7 +257,7 @@ void JM_delete_annot(fz_context *ctx, pdf_page *page, pdf_annot *annot)
252257
pdf_obj *popup = pdf_dict_get(ctx, annot->obj, PDF_NAME(Popup));
253258
pdf_dict_del(ctx, annot->obj, PDF_NAME(Popup));
254259
pdf_dict_del(ctx, annot->obj, PDF_NAME(AP));
255-
if (popup)
260+
if (popup) // now look for the popup entry
256261
{
257262
pdf_obj *annots = pdf_dict_get(ctx, page->obj, PDF_NAME(Annots));
258263
int i, n = pdf_array_len(ctx, annots);
@@ -277,18 +282,21 @@ void JM_delete_annot(fz_context *ctx, pdf_page *page, pdf_annot *annot)
277282
return;
278283
}
279284

285+
//----------------------------------------------------------------------------
286+
// locate and return the first annotation whose /IRT key points to annot.
287+
//----------------------------------------------------------------------------
280288
pdf_annot *JM_find_annot_irt(fz_context *ctx, pdf_annot *annot)
281289
{
282-
pdf_annot *irt_annot = NULL;
290+
pdf_annot *irt_annot = NULL; // returning this
283291
pdf_obj *o = NULL;
284292
pdf_annot **annotptr;
285293
int found = 0;
286294
fz_try(ctx)
287-
{
295+
{ // loop thru MuPDF's internal annots array
288296
pdf_page *page = annot->page;
289297
for (annotptr = &page->annots; *annotptr; annotptr = &(*annotptr)->next)
290298
{
291-
irt_annot = *annotptr;
299+
irt_annot = *annotptr; // check if this is what we are looking for
292300
o = pdf_dict_gets(ctx, irt_annot->obj, "IRT");
293301
if (o)
294302
{

fitz/helper-other.i

+1
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,7 @@ void JM_mupdf_warning(void *user, const char *message)
5959
// redirect MuPDF errors
6060
void JM_mupdf_error(void *user, const char *message)
6161
{
62+
LIST_APPEND_DROP(JM_mupdf_warnings_store, JM_EscapeStrFromStr(message));
6263
PySys_WriteStderr("mupdf: %s\n", message);
6364
}
6465

fitz/helper-stext.i

+10-17
Original file line numberDiff line numberDiff line change
@@ -272,7 +272,6 @@ static PyObject *JM_make_spanlist(fz_context *ctx, fz_stext_line *line, int raw,
272272

273273
static void JM_make_image_block(fz_context *ctx, fz_stext_block *block, PyObject *block_dict)
274274
{
275-
fz_color_params color_params = {0};
276275
fz_image *image = block->u.i.image;
277276
fz_buffer *buf = NULL, *freebuf = NULL;
278277
fz_compressed_buffer *buffer = fz_compressed_image_buffer(ctx, image);
@@ -281,31 +280,24 @@ static void JM_make_image_block(fz_context *ctx, fz_stext_block *block, PyObject
281280
int n = fz_colorspace_n(ctx, image->colorspace);
282281
int w = image->w;
283282
int h = image->h;
284-
int type = FZ_IMAGE_UNKNOWN;
285-
if (buffer) type = buffer->params.type;
286283
const char *ext = NULL;
287-
PyObject *bytes = JM_BinFromChar("");
284+
int type = FZ_IMAGE_UNKNOWN;
285+
if (buffer)
286+
type = buffer->params.type;
287+
if (type < FZ_IMAGE_BMP || type == FZ_IMAGE_JBIG2)
288+
type = FZ_IMAGE_UNKNOWN;
289+
PyObject *bytes = NULL;
288290
fz_var(bytes);
289291
fz_try(ctx)
290292
{
291-
if (type == FZ_IMAGE_JPX && !(image->mask))
292-
{;}
293-
else if (image->use_colorkey ||
294-
image->use_decode ||
295-
image->mask ||
296-
type < FZ_IMAGE_BMP ||
297-
type == FZ_IMAGE_JBIG2 ||
298-
(n != 1 && n != 3 && type == FZ_IMAGE_JPEG))
299-
type = FZ_IMAGE_UNKNOWN;
300-
301-
if (type != FZ_IMAGE_UNKNOWN)
293+
if (buffer && type != FZ_IMAGE_UNKNOWN)
302294
{
303295
buf = buffer->buffer;
304296
ext = JM_image_extension(type);
305297
}
306298
else
307299
{
308-
buf = freebuf = fz_new_buffer_from_image_as_png(ctx, image, color_params);
300+
buf = freebuf = fz_new_buffer_from_image_as_png(ctx, image, fz_default_color_params);
309301
ext = "png";
310302
}
311303
if (PY_MAJOR_VERSION > 2)
@@ -319,6 +311,8 @@ static void JM_make_image_block(fz_context *ctx, fz_stext_block *block, PyObject
319311
}
320312
fz_always(ctx)
321313
{
314+
if (!bytes)
315+
bytes = JM_BinFromChar("");
322316
DICT_SETITEM_DROP(block_dict, dictkey_width,
323317
Py_BuildValue("i", w));
324318
DICT_SETITEM_DROP(block_dict, dictkey_height,
@@ -339,7 +333,6 @@ static void JM_make_image_block(fz_context *ctx, fz_stext_block *block, PyObject
339333
}
340334
fz_catch(ctx) {;}
341335
return;
342-
343336
}
344337

345338
static void JM_make_text_block(fz_context *ctx, fz_stext_block *block, PyObject *block_dict, int raw, fz_buffer *buff)

fitz/utils.py

+1-2
Original file line numberDiff line numberDiff line change
@@ -382,8 +382,7 @@ def lookup_matrix(page, item):
382382

383383
mat = lookup_matrix(page, item)
384384
if not bool(mat):
385-
msg = "image '%s' not found" % item[7]
386-
raise ValueError(msg)
385+
return fitz.Rect(1, 1, -1, -1) # return infinite rect if not found
387386

388387
ctm = page._getTransformation() # page transformation matrix
389388
mat.preScale(1, -1) # fiddle the matrix

fitz/version.i

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
%pythoncode %{
22
VersionFitz = "1.16.0"
3-
VersionBind = "1.16.6"
4-
VersionDate = "2019-11-01 18:55:25"
5-
version = (VersionBind, VersionFitz, "20191101185525")
3+
VersionBind = "1.16.7"
4+
VersionDate = "2019-11-07 10:22:00"
5+
version = (VersionBind, VersionFitz, "20191107102200")
66
%}

setup.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ def run(self):
8181

8282
setup(
8383
name="PyMuPDF",
84-
version="1.16.6",
84+
version="1.16.7",
8585
description="Python bindings for the PDF rendering library MuPDF",
8686
long_description=long_desc,
8787
classifiers=classifier,

0 commit comments

Comments
 (0)