Skip to content

Commit

Permalink
Merge pull request #282 from JorjMcKie/master
Browse files Browse the repository at this point in the history
upgrade to v1.14.14
  • Loading branch information
JorjMcKie authored Apr 9, 2019
2 parents 4646630 + 93ac8bc commit 917f2d8
Show file tree
Hide file tree
Showing 10 changed files with 222 additions and 90 deletions.
4 changes: 2 additions & 2 deletions PKG-INFO
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Metadata-Version: 1.1
Name: PyMuPDF
Version: 1.14.13
Version: 1.14.14
Author: Ruikai Liu
Author-email: [email protected]
Maintainer: Jorj X. McKie
Expand All @@ -21,7 +21,7 @@ Description:
Introduction
============

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

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.

Expand Down
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# PyMuPDF 1.14.13
# PyMuPDF 1.14.14

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

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

# Introduction

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".
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".

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.

Expand Down
47 changes: 29 additions & 18 deletions fitz/fitz.i
Original file line number Diff line number Diff line change
Expand Up @@ -231,7 +231,7 @@ struct fz_document_s
elif type(stream) is io.BytesIO:
self.stream = stream.getvalue()
else:
raise ValueError("'stream' has bad type")
raise ValueError("bad type: 'stream'")
stream = self.stream
else:
self.stream = None
Expand Down Expand Up @@ -523,7 +523,7 @@ struct fz_document_s
if (!filespec) THROWMSG("bad PDF: /EF object not found");
res = JM_BufferFromBytes(gctx, buffer);
if (buffer && !res) THROWMSG("'buffer' has bad type");
if (buffer && !res) THROWMSG("bad type: 'buffer'");
if (res)
{
JM_update_stream(gctx, pdf, filespec, res);
Expand Down Expand Up @@ -605,7 +605,7 @@ if self.isClosed or self.isEncrypted:
{
assert_PDF(pdf);
data = JM_BufferFromBytes(gctx, buffer);
if (!data) THROWMSG("bad type 'buffer'");
if (!data) THROWMSG("bad type: 'buffer'");
size = fz_buffer_storage(gctx, data, &buffdata);
// we do not allow duplicate names
Expand Down Expand Up @@ -1710,7 +1710,7 @@ if links:
//---------------------------------------------------------------------
FITZEXCEPTION(_getXrefString, !result)
CLOSECHECK0(_getXrefString)
PyObject *_getXrefString(int xref)
PyObject *_getXrefString(int xref, int compressed=1)
{
pdf_document *pdf = pdf_specifics(gctx, $self); // conv doc to pdf
pdf_obj *obj = NULL;
Expand All @@ -1726,7 +1726,7 @@ if links:
res = fz_new_buffer(gctx, 1024);
out = fz_new_output_with_buffer(gctx, res);
obj = pdf_load_object(gctx, pdf, xref);
pdf_print_obj(gctx, out, pdf_resolve_indirect(gctx, obj), 1);
pdf_print_obj(gctx, out, pdf_resolve_indirect(gctx, obj), compressed);
text = JM_StrFromBuffer(gctx, res);
}
fz_always(gctx)
Expand All @@ -1744,7 +1744,7 @@ if links:
//---------------------------------------------------------------------
FITZEXCEPTION(_getTrailerString, !result)
CLOSECHECK0(_getTrailerString)
PyObject *_getTrailerString()
PyObject *_getTrailerString(int compressed=1)
{
pdf_document *pdf = pdf_specifics(gctx, $self); // conv doc to pdf
if (!pdf) return NONE;
Expand All @@ -1759,7 +1759,7 @@ if links:
{
res = fz_new_buffer(gctx, 1024);
out = fz_new_output_with_buffer(gctx, res);
pdf_print_obj(gctx, out, obj, 1);
pdf_print_obj(gctx, out, obj, compressed);
text = JM_StrFromBuffer(gctx, res);
}
else text = NONE;
Expand Down Expand Up @@ -1863,7 +1863,7 @@ if links:
if (!new && !pdf_is_stream(gctx, obj))
THROWMSG("xref not a stream object");
res = JM_BufferFromBytes(gctx, stream);
if (!res) THROWMSG("stream must be bytes or bytearray");
if (!res) THROWMSG("bad type: 'stream'");
JM_update_stream(gctx, pdf, obj, res);
}
Expand Down Expand Up @@ -2318,7 +2318,7 @@ struct fz_page_s {
{
assert_PDF(page);
filebuf = JM_BufferFromBytes(gctx, buffer);
if (!filebuf) THROWMSG("bad 'buffer' data");
if (!filebuf) THROWMSG("bad type: 'buffer'");
annot = pdf_create_annot(gctx, page, ANNOT_FILEATTACHMENT);
pdf_set_annot_rect(gctx, annot, r);
pdf_set_annot_icon_name(gctx, annot, "PushPin");
Expand Down Expand Up @@ -3036,7 +3036,7 @@ fannot._erase()
//---------------------------------------------------------------------
FITZEXCEPTION(_insertImage, !result)
PyObject *_insertImage(const char *filename=NULL, struct fz_pixmap_s *pixmap=NULL, PyObject *stream=NULL, int overlay=1, PyObject *matrix=NULL,
const char *_imgname=NULL)
const char *_imgname=NULL, PyObject *_imgpointer=NULL)
{
pdf_page *page = pdf_page_from_fz_page(gctx, $self);
pdf_document *pdf;
Expand All @@ -3057,16 +3057,27 @@ fannot._erase()
//-------------------------------------------------------------
// create the image
//-------------------------------------------------------------
if (filename || stream)
if (filename ||
(stream && stream != NONE) ||
(_imgpointer && _imgpointer != NONE))
{
if (filename)
{
image = fz_new_image_from_file(gctx, filename);
else
}
else if (stream && stream != NONE)
{
imgbuf = JM_BufferFromBytes(gctx, stream);
image = fz_new_image_from_buffer(gctx, imgbuf);
}
else // fz_image pointer has been handed in
{
image = (fz_image *)PyLong_AsVoidPtr(_imgpointer);
}
// test for alpha (which would require making an SMask)
pix = fz_get_pixmap_from_image(gctx, image, NULL, NULL, 0, 0);
if (pix->alpha == 1)
Expand Down Expand Up @@ -3802,7 +3813,7 @@ struct fz_pixmap_s
if (data && data_len < w * h)
THROWMSG("not enough alpha values");
}
else THROWMSG("bad type 'alphavalues'");
else THROWMSG("bad type: 'alphavalues'");
}
int i = 0, k = 0;
while (i < balen)
Expand Down Expand Up @@ -5207,7 +5218,7 @@ CheckParent(self)
// file content given
res = JM_BufferFromBytes(gctx, buffer);
if (buffer && !res) THROWMSG("'buffer' has bad type");
if (buffer && !res) THROWMSG("bad type: 'buffer'");
if (res)
{
JM_update_stream(gctx, pdf, stream, res);
Expand Down Expand Up @@ -6294,9 +6305,9 @@ struct Tools
}
%feature("autodoc","Determine dimension and other image data.") image_size;
PyObject *image_size(PyObject *imagedata)
PyObject *image_size(PyObject *imagedata, int keep_image=0)
{
return JM_image_size(gctx, imagedata);
return JM_image_size(gctx, imagedata, keep_image);
}
%feature("autodoc","Current store size.") store_size;
Expand Down Expand Up @@ -6339,8 +6350,8 @@ struct Tools
xref = JM_insert_contents(gctx, page->doc, page->obj, contbuf, overlay);
page->doc->dirty = 1;
}
fz_always(gctx) fz_drop_buffer(gctx, contbuf);
fz_catch(gctx) return NULL;
fz_always(gctx) {fz_drop_buffer(gctx, contbuf);}
fz_catch(gctx) {return NULL;}
return Py_BuildValue("i", xref);
}
Expand Down
30 changes: 15 additions & 15 deletions fitz/fitz.py
Original file line number Diff line number Diff line change
Expand Up @@ -106,9 +106,9 @@ class _object:


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


class Matrix():
Expand Down Expand Up @@ -1800,7 +1800,7 @@ def __init__(self, filename=None, stream=None, filetype=None, rect=None, width=0
elif type(stream) is io.BytesIO:
self.stream = stream.getvalue()
else:
raise ValueError("'stream' has bad type")
raise ValueError("bad type: 'stream'")
stream = self.stream
else:
self.stream = None
Expand Down Expand Up @@ -2330,20 +2330,20 @@ def _delXmlMetadata(self):
return _fitz.Document__delXmlMetadata(self)


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

return _fitz.Document__getXrefString(self, xref)
return _fitz.Document__getXrefString(self, xref, compressed)


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

return _fitz.Document__getTrailerString(self)
return _fitz.Document__getTrailerString(self, compressed)


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


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


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


def image_size(self, imagedata):
def image_size(self, imagedata, keep_image=0):
"""Determine dimension and other image data."""
return _fitz.Tools_image_size(self, imagedata)
return _fitz.Tools_image_size(self, imagedata, keep_image)

@property

Expand Down
Loading

0 comments on commit 917f2d8

Please sign in to comment.