Skip to content

Commit 917f2d8

Browse files
authored
Merge pull request #282 from JorjMcKie/master
upgrade to v1.14.14
2 parents 4646630 + 93ac8bc commit 917f2d8

File tree

10 files changed

+222
-90
lines changed

10 files changed

+222
-90
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.14.13
3+
Version: 1.14.14
44
Author: Ruikai Liu
55
Author-email: [email protected]
66
Maintainer: Jorj X. McKie
@@ -21,7 +21,7 @@ Description:
2121
Introduction
2222
============
2323

24-
This is **version 1.14.13 of PyMuPDF**, a Python binding for `MuPDF <http://mupdf.com/>`_ - "a lightweight PDF and XPS viewer".
24+
This is **version 1.14.14 of PyMuPDF**, a Python binding for `MuPDF <http://mupdf.com/>`_ - "a lightweight PDF and XPS viewer".
2525

2626
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.
2727

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# PyMuPDF 1.14.13
1+
# PyMuPDF 1.14.14
22

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

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

1515
# Introduction
1616

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

fitz/fitz.i

Lines changed: 29 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -231,7 +231,7 @@ struct fz_document_s
231231
elif type(stream) is io.BytesIO:
232232
self.stream = stream.getvalue()
233233
else:
234-
raise ValueError("'stream' has bad type")
234+
raise ValueError("bad type: 'stream'")
235235
stream = self.stream
236236
else:
237237
self.stream = None
@@ -523,7 +523,7 @@ struct fz_document_s
523523
if (!filespec) THROWMSG("bad PDF: /EF object not found");
524524
525525
res = JM_BufferFromBytes(gctx, buffer);
526-
if (buffer && !res) THROWMSG("'buffer' has bad type");
526+
if (buffer && !res) THROWMSG("bad type: 'buffer'");
527527
if (res)
528528
{
529529
JM_update_stream(gctx, pdf, filespec, res);
@@ -605,7 +605,7 @@ if self.isClosed or self.isEncrypted:
605605
{
606606
assert_PDF(pdf);
607607
data = JM_BufferFromBytes(gctx, buffer);
608-
if (!data) THROWMSG("bad type 'buffer'");
608+
if (!data) THROWMSG("bad type: 'buffer'");
609609
size = fz_buffer_storage(gctx, data, &buffdata);
610610
611611
// we do not allow duplicate names
@@ -1710,7 +1710,7 @@ if links:
17101710
//---------------------------------------------------------------------
17111711
FITZEXCEPTION(_getXrefString, !result)
17121712
CLOSECHECK0(_getXrefString)
1713-
PyObject *_getXrefString(int xref)
1713+
PyObject *_getXrefString(int xref, int compressed=1)
17141714
{
17151715
pdf_document *pdf = pdf_specifics(gctx, $self); // conv doc to pdf
17161716
pdf_obj *obj = NULL;
@@ -1726,7 +1726,7 @@ if links:
17261726
res = fz_new_buffer(gctx, 1024);
17271727
out = fz_new_output_with_buffer(gctx, res);
17281728
obj = pdf_load_object(gctx, pdf, xref);
1729-
pdf_print_obj(gctx, out, pdf_resolve_indirect(gctx, obj), 1);
1729+
pdf_print_obj(gctx, out, pdf_resolve_indirect(gctx, obj), compressed);
17301730
text = JM_StrFromBuffer(gctx, res);
17311731
}
17321732
fz_always(gctx)
@@ -1744,7 +1744,7 @@ if links:
17441744
//---------------------------------------------------------------------
17451745
FITZEXCEPTION(_getTrailerString, !result)
17461746
CLOSECHECK0(_getTrailerString)
1747-
PyObject *_getTrailerString()
1747+
PyObject *_getTrailerString(int compressed=1)
17481748
{
17491749
pdf_document *pdf = pdf_specifics(gctx, $self); // conv doc to pdf
17501750
if (!pdf) return NONE;
@@ -1759,7 +1759,7 @@ if links:
17591759
{
17601760
res = fz_new_buffer(gctx, 1024);
17611761
out = fz_new_output_with_buffer(gctx, res);
1762-
pdf_print_obj(gctx, out, obj, 1);
1762+
pdf_print_obj(gctx, out, obj, compressed);
17631763
text = JM_StrFromBuffer(gctx, res);
17641764
}
17651765
else text = NONE;
@@ -1863,7 +1863,7 @@ if links:
18631863
if (!new && !pdf_is_stream(gctx, obj))
18641864
THROWMSG("xref not a stream object");
18651865
res = JM_BufferFromBytes(gctx, stream);
1866-
if (!res) THROWMSG("stream must be bytes or bytearray");
1866+
if (!res) THROWMSG("bad type: 'stream'");
18671867
JM_update_stream(gctx, pdf, obj, res);
18681868
18691869
}
@@ -2318,7 +2318,7 @@ struct fz_page_s {
23182318
{
23192319
assert_PDF(page);
23202320
filebuf = JM_BufferFromBytes(gctx, buffer);
2321-
if (!filebuf) THROWMSG("bad 'buffer' data");
2321+
if (!filebuf) THROWMSG("bad type: 'buffer'");
23222322
annot = pdf_create_annot(gctx, page, ANNOT_FILEATTACHMENT);
23232323
pdf_set_annot_rect(gctx, annot, r);
23242324
pdf_set_annot_icon_name(gctx, annot, "PushPin");
@@ -3036,7 +3036,7 @@ fannot._erase()
30363036
//---------------------------------------------------------------------
30373037
FITZEXCEPTION(_insertImage, !result)
30383038
PyObject *_insertImage(const char *filename=NULL, struct fz_pixmap_s *pixmap=NULL, PyObject *stream=NULL, int overlay=1, PyObject *matrix=NULL,
3039-
const char *_imgname=NULL)
3039+
const char *_imgname=NULL, PyObject *_imgpointer=NULL)
30403040
{
30413041
pdf_page *page = pdf_page_from_fz_page(gctx, $self);
30423042
pdf_document *pdf;
@@ -3057,16 +3057,27 @@ fannot._erase()
30573057
//-------------------------------------------------------------
30583058
// create the image
30593059
//-------------------------------------------------------------
3060-
if (filename || stream)
3060+
if (filename ||
3061+
(stream && stream != NONE) ||
3062+
(_imgpointer && _imgpointer != NONE))
30613063
{
3064+
30623065
if (filename)
3066+
{
30633067
image = fz_new_image_from_file(gctx, filename);
3064-
else
3068+
}
3069+
3070+
else if (stream && stream != NONE)
30653071
{
30663072
imgbuf = JM_BufferFromBytes(gctx, stream);
30673073
image = fz_new_image_from_buffer(gctx, imgbuf);
30683074
}
30693075
3076+
else // fz_image pointer has been handed in
3077+
{
3078+
image = (fz_image *)PyLong_AsVoidPtr(_imgpointer);
3079+
}
3080+
30703081
// test for alpha (which would require making an SMask)
30713082
pix = fz_get_pixmap_from_image(gctx, image, NULL, NULL, 0, 0);
30723083
if (pix->alpha == 1)
@@ -3802,7 +3813,7 @@ struct fz_pixmap_s
38023813
if (data && data_len < w * h)
38033814
THROWMSG("not enough alpha values");
38043815
}
3805-
else THROWMSG("bad type 'alphavalues'");
3816+
else THROWMSG("bad type: 'alphavalues'");
38063817
}
38073818
int i = 0, k = 0;
38083819
while (i < balen)
@@ -5207,7 +5218,7 @@ CheckParent(self)
52075218
52085219
// file content given
52095220
res = JM_BufferFromBytes(gctx, buffer);
5210-
if (buffer && !res) THROWMSG("'buffer' has bad type");
5221+
if (buffer && !res) THROWMSG("bad type: 'buffer'");
52115222
if (res)
52125223
{
52135224
JM_update_stream(gctx, pdf, stream, res);
@@ -6294,9 +6305,9 @@ struct Tools
62946305
}
62956306
62966307
%feature("autodoc","Determine dimension and other image data.") image_size;
6297-
PyObject *image_size(PyObject *imagedata)
6308+
PyObject *image_size(PyObject *imagedata, int keep_image=0)
62986309
{
6299-
return JM_image_size(gctx, imagedata);
6310+
return JM_image_size(gctx, imagedata, keep_image);
63006311
}
63016312
63026313
%feature("autodoc","Current store size.") store_size;
@@ -6339,8 +6350,8 @@ struct Tools
63396350
xref = JM_insert_contents(gctx, page->doc, page->obj, contbuf, overlay);
63406351
page->doc->dirty = 1;
63416352
}
6342-
fz_always(gctx) fz_drop_buffer(gctx, contbuf);
6343-
fz_catch(gctx) return NULL;
6353+
fz_always(gctx) {fz_drop_buffer(gctx, contbuf);}
6354+
fz_catch(gctx) {return NULL;}
63446355
return Py_BuildValue("i", xref);
63456356
}
63466357

fitz/fitz.py

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -106,9 +106,9 @@ class _object:
106106

107107

108108
VersionFitz = "1.14.0"
109-
VersionBind = "1.14.13"
110-
VersionDate = "2019-04-07 06:43:20"
111-
version = (VersionBind, VersionFitz, "20190407064320")
109+
VersionBind = "1.14.14"
110+
VersionDate = "2019-04-09 13:07:58"
111+
version = (VersionBind, VersionFitz, "20190409130758")
112112

113113

114114
class Matrix():
@@ -1800,7 +1800,7 @@ def __init__(self, filename=None, stream=None, filetype=None, rect=None, width=0
18001800
elif type(stream) is io.BytesIO:
18011801
self.stream = stream.getvalue()
18021802
else:
1803-
raise ValueError("'stream' has bad type")
1803+
raise ValueError("bad type: 'stream'")
18041804
stream = self.stream
18051805
else:
18061806
self.stream = None
@@ -2330,20 +2330,20 @@ def _delXmlMetadata(self):
23302330
return _fitz.Document__delXmlMetadata(self)
23312331

23322332

2333-
def _getXrefString(self, xref):
2334-
"""_getXrefString(self, xref) -> PyObject *"""
2333+
def _getXrefString(self, xref, compressed=1):
2334+
"""_getXrefString(self, xref, compressed=1) -> PyObject *"""
23352335
if self.isClosed:
23362336
raise ValueError("operation illegal for closed doc")
23372337

2338-
return _fitz.Document__getXrefString(self, xref)
2338+
return _fitz.Document__getXrefString(self, xref, compressed)
23392339

23402340

2341-
def _getTrailerString(self):
2342-
"""_getTrailerString(self) -> PyObject *"""
2341+
def _getTrailerString(self, compressed=1):
2342+
"""_getTrailerString(self, compressed=1) -> PyObject *"""
23432343
if self.isClosed:
23442344
raise ValueError("operation illegal for closed doc")
23452345

2346-
return _fitz.Document__getTrailerString(self)
2346+
return _fitz.Document__getTrailerString(self, compressed)
23472347

23482348

23492349
def _getXrefStream(self, xref):
@@ -2956,9 +2956,9 @@ def _showPDFpage(self, fz_srcpage, overlay=1, matrix=None, xref=0, clip=None, gr
29562956
return _fitz.Page__showPDFpage(self, fz_srcpage, overlay, matrix, xref, clip, graftmap, _imgname)
29572957

29582958

2959-
def _insertImage(self, filename=None, pixmap=None, stream=None, overlay=1, matrix=None, _imgname=None):
2960-
"""_insertImage(self, filename=None, pixmap=None, stream=None, overlay=1, matrix=None, _imgname=None) -> PyObject *"""
2961-
return _fitz.Page__insertImage(self, filename, pixmap, stream, overlay, matrix, _imgname)
2959+
def _insertImage(self, filename=None, pixmap=None, stream=None, overlay=1, matrix=None, _imgname=None, _imgpointer=None):
2960+
"""_insertImage(self, filename=None, pixmap=None, stream=None, overlay=1, matrix=None, _imgname=None, _imgpointer=None) -> PyObject *"""
2961+
return _fitz.Page__insertImage(self, filename, pixmap, stream, overlay, matrix, _imgname, _imgpointer)
29622962

29632963

29642964
def insertFont(self, fontname="helv", fontfile=None, fontbuffer=None,
@@ -4394,9 +4394,9 @@ def store_shrink(self, percent):
43944394
return _fitz.Tools_store_shrink(self, percent)
43954395

43964396

4397-
def image_size(self, imagedata):
4397+
def image_size(self, imagedata, keep_image=0):
43984398
"""Determine dimension and other image data."""
4399-
return _fitz.Tools_image_size(self, imagedata)
4399+
return _fitz.Tools_image_size(self, imagedata, keep_image)
44004400

44014401
@property
44024402

0 commit comments

Comments
 (0)