Skip to content

Commit 4646630

Browse files
authored
Merge pull request #281 from JorjMcKie/master
upgrade to v1.14.13
2 parents fb8e181 + df3613d commit 4646630

15 files changed

+613
-353
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.12
3+
Version: 1.14.13
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.12 of PyMuPDF**, a Python binding for `MuPDF <http://mupdf.com/>`_ - "a lightweight PDF and XPS viewer".
24+
This is **version 1.14.13 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: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
1-
# PyMuPDF 1.14.12
1+
# PyMuPDF 1.14.13
22

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

5-
Release date: January 15, 2018
5+
Release date: April 7, 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.14.12 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.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".
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

@@ -79,7 +79,7 @@ Our **documentation**, written using Sphinx, is available in various formats fro
7979

8080
* You can view it online at [Read the Docs](https://pymupdf.readthedocs.io/). For **best quality downloads** you should however use the following links.
8181
* zipped [HTML](https://github.com/pymupdf/PyMuPDF/tree/master/doc/html.zip)
82-
* [Windows CHM](https://github.com/JorjMcKie/PyMuPDF-optional-material/tree/master/doc/PyMuPDF.chm)
82+
* [Windows CHM](https://github.com/pymupdf/PyMuPDF-optional-material/tree/master/doc/PyMuPDF.chm)
8383
* [PDF](https://github.com/pymupdf/PyMuPDF/blob/master/doc/PyMuPDF.pdf)
8484

8585
# Earlier Versions

doc/PyMuPDF.pdf

3.72 KB
Binary file not shown.

doc/html.zip

3.81 KB
Binary file not shown.

fitz/fitz.i

Lines changed: 181 additions & 123 deletions
Large diffs are not rendered by default.

fitz/fitz.py

Lines changed: 51 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -98,16 +98,17 @@ class _object:
9898

9999
import os
100100
import weakref
101+
import io
101102
from binascii import hexlify
102103
import math
103104

104105
fitz_py2 = str is bytes # if true, this is Python 2
105106

106107

107108
VersionFitz = "1.14.0"
108-
VersionBind = "1.14.12"
109-
VersionDate = "2019-03-21 06:59:25"
110-
version = (VersionBind, VersionFitz, "20190321065925")
109+
VersionBind = "1.14.13"
110+
VersionDate = "2019-04-07 06:43:20"
111+
version = (VersionBind, VersionFitz, "20190407064320")
111112

112113

113114
class Matrix():
@@ -174,7 +175,7 @@ def preTranslate(self, tx, ty):
174175
return self
175176

176177
def preScale(self, sx, sy):
177-
"""Calculate pre scaling and replacing current matrix."""
178+
"""Calculate pre scaling and replace current matrix."""
178179
self.a *= sx
179180
self.b *= sx
180181
self.c *= sy
@@ -1782,28 +1783,36 @@ def __init__(self, filename=None, stream=None, filetype=None, rect=None, width=0
17821783
if not filename or type(filename) is str:
17831784
pass
17841785
else:
1785-
if fitz_py2: # Python 2
1786+
if fitz_py2: # Python 2
17861787
if type(filename) is unicode:
17871788
filename = filename.encode("utf8")
17881789
else:
1789-
filename = str(filename) # should take care of pathlib
1790+
filename = str(filename) # should take care of pathlib
17901791

1791-
self.streamlen = len(stream) if stream else 0
1792+
if stream:
1793+
if not (filename or filetype):
1794+
raise ValueError("need filetype for opening a stream")
1795+
1796+
if type(stream) is bytes:
1797+
self.stream = stream
1798+
elif type(stream) is bytearray:
1799+
self.stream = bytes(stream)
1800+
elif type(stream) is io.BytesIO:
1801+
self.stream = stream.getvalue()
1802+
else:
1803+
raise ValueError("'stream' has bad type")
1804+
stream = self.stream
1805+
else:
1806+
self.stream = None
17921807

1793-
self.name = ""
1794-
if filename and self.streamlen == 0:
1808+
if filename and not stream:
17951809
self.name = filename
1796-
1797-
if self.streamlen > 0:
1798-
if not (filename or filetype):
1799-
raise ValueError("filetype missing with stream specified")
1800-
if type(stream) not in (bytes, bytearray):
1801-
raise ValueError("stream must be bytes or bytearray")
1810+
else:
1811+
self.name = ""
18021812

18031813
self.isClosed = False
18041814
self.isEncrypted = 0
18051815
self.metadata = None
1806-
self.stream = stream # prevent garbage collecting this
18071816
self.openErrCode = 0
18081817
self.openErrMsg = ''
18091818
self.FontInfos = []
@@ -1920,9 +1929,6 @@ def embeddedFileInfo(self, id):
19201929

19211930
def embeddedFileUpd(self, id, buffer=None, filename=None, ufilename=None, desc=None):
19221931
"""Change an embedded file given its entry number or name."""
1923-
if self.isClosed or self.isEncrypted:
1924-
raise ValueError("operation illegal for closed / encrypted doc")
1925-
19261932
return _fitz.Document_embeddedFileUpd(self, id, buffer, filename, ufilename, desc)
19271933

19281934

@@ -1941,9 +1947,11 @@ def embeddedFileGet(self, id):
19411947

19421948
def embeddedFileAdd(self, buffer, name, filename=None, ufilename=None, desc=None):
19431949
"""Embed a new file."""
1950+
19441951
if self.isClosed or self.isEncrypted:
19451952
raise ValueError("operation illegal for closed / encrypted doc")
19461953

1954+
19471955
return _fitz.Document_embeddedFileAdd(self, buffer, name, filename, ufilename, desc)
19481956

19491957

@@ -2126,7 +2134,7 @@ def save(self, filename, garbage=0, clean=0, deflate=0, incremental=0, ascii=0,
21262134
if self.pageCount < 1:
21272135
raise ValueError("cannot save with zero pages")
21282136
if incremental:
2129-
if self.name != filename or self.streamlen > 0:
2137+
if self.name != filename or self.stream:
21302138
raise ValueError("incremental needs original file")
21312139

21322140

@@ -2461,17 +2469,17 @@ def saveIncr(self):
24612469

24622470
def __repr__(self):
24632471
m = "closed " if self.isClosed else ""
2464-
if self.streamlen == 0:
2465-
if self.name == "":
2466-
return m + "fitz.Document(<new PDF>)"
2472+
if self.stream is None:
2473+
if self.name is "":
2474+
return m + "fitz.Document(<new PDF, doc# %i>)" % self._graft_id
24672475
return m + "fitz.Document('%s')" % (self.name,)
2468-
return m + "fitz.Document('%s', <memory>)" % (self.name,)
2476+
return m + "fitz.Document('%s', <memory, doc# %i>)" % (self.name, self._graft_id)
24692477

24702478
def __getitem__(self, i=0):
24712479
if type(i) is not int:
2472-
raise ValueError("invalid page number(s)")
2480+
raise ValueError("bad page number(s)")
24732481
if i >= len(self):
2474-
raise IndexError("invalid page number(s)")
2482+
raise IndexError("bad page number(s)")
24752483
return self.loadPage(i)
24762484

24772485
def __len__(self):
@@ -2500,11 +2508,12 @@ def __del__(self):
25002508
for gmap in self.Graftmaps:
25012509
self.Graftmaps[gmap] = None
25022510
if hasattr(self, "this") and self.thisown:
2503-
self.thisown = False
25042511
self.__swig_destroy__(self)
2512+
self.thisown = False
2513+
25052514
self.Graftmaps = {}
25062515
self.ShownPages = {}
2507-
self.stream = None
2516+
self.stream = None
25082517
self._reset_page_refs = DUMMY
25092518
self.__swig_destroy__ = DUMMY
25102519
self.isClosed = True
@@ -3045,19 +3054,19 @@ def _setContents(self, xref=0):
30453054
def __str__(self):
30463055
CheckParent(self)
30473056
x = self.parent.name
3048-
if self.parent.streamlen > 0:
3049-
x += " (memory)"
3057+
if self.parent.stream is not None:
3058+
x = "<memory, doc# %i>" % (self.parent._graft_id,)
30503059
if x == "":
3051-
x = "<new PDF>"
3060+
x = "<new PDF, doc# %i>" % self.parent._graft_id
30523061
return "page %s of %s" % (self.number, x)
30533062

30543063
def __repr__(self):
30553064
CheckParent(self)
30563065
x = self.parent.name
3057-
if self.parent.streamlen > 0:
3058-
x += " (memory)"
3066+
if self.parent.stream is not None:
3067+
x = "<memory, doc# %i>" % (self.parent._graft_id,)
30593068
if x == "":
3060-
x = "<new PDF>"
3069+
x = "<new PDF, doc# %i>" % self.parent._graft_id
30613070
return "page %s of %s" % (self.number, x)
30623071

30633072
def _forget_annot(self, annot):
@@ -3877,9 +3886,11 @@ def fileGet(self):
38773886

38783887

38793888
def fileUpd(self, buffer=None, filename=None, ufilename=None, desc=None):
3880-
"""Update annotation attached file content."""
3889+
"""Update annotation attached file."""
3890+
38813891
CheckParent(self)
38823892

3893+
38833894
return _fitz.Annot_fileUpd(self, buffer, filename, ufilename, desc)
38843895

38853896
@property
@@ -4382,6 +4393,11 @@ def store_shrink(self, percent):
43824393
"""Free 'percent' of current store size."""
43834394
return _fitz.Tools_store_shrink(self, percent)
43844395

4396+
4397+
def image_size(self, imagedata):
4398+
"""Determine dimension and other image data."""
4399+
return _fitz.Tools_image_size(self, imagedata)
4400+
43854401
@property
43864402

43874403
def store_size(self):

0 commit comments

Comments
 (0)