Skip to content

Commit e095b04

Browse files
committed
upload v1.16.6
1 parent 5c7c36e commit e095b04

15 files changed

+635
-621
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.5
3+
Version: 1.16.6
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: October 15, 2019
12+
Release date: November 5, 2019
1313

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

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

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

5-
Release date: October 15, 2019
5+
Release date: November 5, 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.5 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.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".
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

12.2 KB
Binary file not shown.

doc/html.zip

7.73 KB
Binary file not shown.

fitz/fitz.i

Lines changed: 233 additions & 210 deletions
Large diffs are not rendered by default.

fitz/helper-annot.i

Lines changed: 74 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -105,8 +105,7 @@ PyObject *JM_annot_border(fz_context *ctx, pdf_obj *annot_obj)
105105
for (i = 0; i < pdf_array_len(ctx, dash); i++)
106106
{
107107
val = Py_BuildValue("i", pdf_to_int(ctx, pdf_array_get(ctx, dash, i)));
108-
PyList_Append(dash_py, val);
109-
Py_DECREF(val);
108+
LIST_APPEND_DROP(dash_py, val);
110109
}
111110
}
112111
}
@@ -124,8 +123,7 @@ PyObject *JM_annot_border(fz_context *ctx, pdf_obj *annot_obj)
124123
for (i = 0; i < pdf_array_len(ctx, o); i++)
125124
{
126125
val = Py_BuildValue("i", pdf_to_int(ctx, pdf_array_get(ctx, o, i)));
127-
PyList_Append(dash_py, val);
128-
Py_DECREF(val);
126+
LIST_APPEND_DROP(dash_py, val);
129127
}
130128
}
131129
}
@@ -139,22 +137,13 @@ PyObject *JM_annot_border(fz_context *ctx, pdf_obj *annot_obj)
139137
if (o) effect1 = pdf_to_int(ctx, o);
140138
}
141139

142-
val = Py_BuildValue("i", effect1);
143-
PyList_Append(effect_py, val);
144-
Py_DECREF(val);
145-
val = Py_BuildValue("s", effect2);
146-
PyList_Append(effect_py, val);
147-
Py_DECREF(val);
148-
val = Py_BuildValue("f", width);
149-
PyDict_SetItem(res, dictkey_width, val);
150-
Py_DECREF(val);
151-
PyDict_SetItem(res, dictkey_dashes, dash_py);
152-
val = Py_BuildValue("s", style);
153-
PyDict_SetItem(res, dictkey_style, val);
154-
Py_DECREF(val);
140+
LIST_APPEND_DROP(effect_py, Py_BuildValue("i", effect1));
141+
LIST_APPEND_DROP(effect_py, JM_UNICODE(effect2));
142+
DICT_SETITEM_DROP(res, dictkey_width, Py_BuildValue("f", width));
143+
DICT_SETITEM_DROP(res, dictkey_dashes, dash_py);
144+
DICT_SETITEM_DROP(res, dictkey_style, JM_UNICODE(style));
155145
if (effect1 > -1) PyDict_SetItem(res, dictkey_effect, effect_py);
156146
Py_CLEAR(effect_py);
157-
Py_CLEAR(dash_py);
158147
return res;
159148
}
160149

@@ -206,7 +195,7 @@ PyObject *JM_annot_set_border(fz_context *ctx, PyObject *border, pdf_document *d
206195
pdf_array_push_int(ctx, darr, (int64_t) d);
207196
}
208197
pdf_dict_putl_drop(ctx, annot_obj, darr, PDF_NAME(BS), PDF_NAME(D), NULL);
209-
nstyle = Py_BuildValue("s", "D");
198+
nstyle = PyUnicode_FromString("D");
210199
}
211200

212201
pdf_dict_putl_drop(ctx, annot_obj, pdf_new_real(ctx, nwidth),
@@ -226,7 +215,6 @@ PyObject *JM_annot_colors(fz_context *ctx, pdf_obj *annot_obj)
226215
PyObject *res = PyDict_New();
227216
PyObject *bc = PyList_New(0); // stroke colors
228217
PyObject *fc = PyList_New(0); // fill colors
229-
PyObject *val;
230218
int i;
231219
float col;
232220
pdf_obj *o = pdf_dict_get(ctx, annot_obj, PDF_NAME(C));
@@ -236,12 +224,10 @@ PyObject *JM_annot_colors(fz_context *ctx, pdf_obj *annot_obj)
236224
for (i = 0; i < n; i++)
237225
{
238226
col = pdf_to_real(ctx, pdf_array_get(ctx, o, i));
239-
val = Py_BuildValue("f", col);
240-
PyList_Append(bc, val);
241-
Py_DECREF(val);
227+
LIST_APPEND_DROP(bc, Py_BuildValue("f", col));
242228
}
243229
}
244-
PyDict_SetItem(res, dictkey_stroke, bc);
230+
DICT_SETITEM_DROP(res, dictkey_stroke, bc);
245231

246232
o = pdf_dict_gets(ctx, annot_obj, "IC");
247233
if (pdf_is_array(ctx, o))
@@ -250,15 +236,73 @@ PyObject *JM_annot_colors(fz_context *ctx, pdf_obj *annot_obj)
250236
for (i = 0; i < n; i++)
251237
{
252238
col = pdf_to_real(ctx, pdf_array_get(ctx, o, i));
253-
val = Py_BuildValue("f", col);
254-
PyList_Append(fc, val);
255-
Py_DECREF(val);
239+
LIST_APPEND_DROP(fc, Py_BuildValue("f", col));
256240
}
257241
}
258-
PyDict_SetItem(res, dictkey_fill, fc);
242+
DICT_SETITEM_DROP(res, dictkey_fill, fc);
259243

260-
Py_CLEAR(bc);
261-
Py_CLEAR(fc);
262244
return res;
263245
}
246+
247+
void JM_delete_annot(fz_context *ctx, pdf_page *page, pdf_annot *annot)
248+
{
249+
if (!annot) return;
250+
fz_try(ctx)
251+
{
252+
pdf_obj *popup = pdf_dict_get(ctx, annot->obj, PDF_NAME(Popup));
253+
pdf_dict_del(ctx, annot->obj, PDF_NAME(Popup));
254+
pdf_dict_del(ctx, annot->obj, PDF_NAME(AP));
255+
if (popup)
256+
{
257+
pdf_obj *annots = pdf_dict_get(ctx, page->obj, PDF_NAME(Annots));
258+
int i, n = pdf_array_len(ctx, annots);
259+
for (i = 0; i < n; i++)
260+
{
261+
pdf_obj *o = pdf_array_get(ctx, annots, i);
262+
pdf_obj *p = pdf_dict_get(ctx, o, PDF_NAME(Parent));
263+
if (!p) continue;
264+
if (!pdf_objcmp(ctx, p, annot->obj))
265+
{
266+
pdf_array_delete(ctx, annots, i);
267+
break;
268+
}
269+
}
270+
}
271+
pdf_delete_annot(ctx, page, annot);
272+
}
273+
fz_catch(ctx)
274+
{
275+
fz_warn(ctx, "could not delete annotation");
276+
}
277+
return;
278+
}
279+
280+
pdf_annot *JM_find_annot_irt(fz_context *ctx, pdf_annot *annot)
281+
{
282+
pdf_annot *irt_annot = NULL;
283+
pdf_obj *o = NULL;
284+
pdf_annot **annotptr;
285+
int found = 0;
286+
fz_try(ctx)
287+
{
288+
pdf_page *page = annot->page;
289+
for (annotptr = &page->annots; *annotptr; annotptr = &(*annotptr)->next)
290+
{
291+
irt_annot = *annotptr;
292+
o = pdf_dict_gets(ctx, irt_annot->obj, "IRT");
293+
if (o)
294+
{
295+
if (!pdf_objcmp(ctx, o, annot->obj))
296+
{
297+
found = 1;
298+
break;
299+
}
300+
}
301+
}
302+
}
303+
fz_catch(ctx) {;}
304+
if (found)
305+
return irt_annot;
306+
return NULL;
307+
}
264308
%}

fitz/helper-defines.i

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -239,17 +239,27 @@
239239
#define PDF_PERM_ASSEMBLE 1 << 10
240240
#define PDF_PERM_PRINT_HQ 1 << 11
241241

242+
// General text flags
243+
#define TEXT_FONT_SUPERSCRIPT 1
244+
#define TEXT_FONT_ITALIC 2
245+
#define TEXT_FONT_SERIFED 4
246+
#define TEXT_FONT_MONOSPACED 8
247+
#define TEXT_FONT_BOLD 16
248+
242249
%}
243250

244251
%{
245-
// Global Constants
252+
// Global Constants - Python dictionary keys
253+
PyObject *dictkey_bpc;
246254
PyObject *dictkey_bbox;
247255
PyObject *dictkey_blocks;
248256
PyObject *dictkey_c;
249257
PyObject *dictkey_chars;
258+
PyObject *dictkey_colorspace;
250259
PyObject *dictkey_color;
251260
PyObject *dictkey_content;
252261
PyObject *dictkey_creationDate;
262+
PyObject *dictkey_cs_name;
253263
PyObject *dictkey_dashes;
254264
PyObject *dictkey_desc;
255265
PyObject *dictkey_dir;
@@ -267,6 +277,7 @@ PyObject *dictkey_modDate;
267277
PyObject *dictkey_name;
268278
PyObject *dictkey_origin;
269279
PyObject *dictkey_size;
280+
PyObject *dictkey_smask;
270281
PyObject *dictkey_spans;
271282
PyObject *dictkey_stroke;
272283
PyObject *dictkey_style;
@@ -278,5 +289,7 @@ PyObject *dictkey_ufilename;
278289
PyObject *dictkey_width;
279290
PyObject *dictkey_wmode;
280291
PyObject *dictkey_xref;
292+
PyObject *dictkey_xres;
293+
PyObject *dictkey_yres;
281294

282295
%}

0 commit comments

Comments
 (0)