Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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.12
Version: 1.14.13
Author: Ruikai Liu
Author-email: lrk700@gmail.com
Maintainer: Jorj X. McKie
Expand All @@ -21,7 +21,7 @@ Description:
Introduction
============

This is **version 1.14.12 of PyMuPDF**, a Python binding for `MuPDF <http://mupdf.com/>`_ - "a lightweight PDF and XPS viewer".
This is **version 1.14.13 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
8 changes: 4 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
# PyMuPDF 1.14.12
# PyMuPDF 1.14.13

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

Release date: January 15, 2018
Release date: April 7, 2019

**Travis-CI:** [![Build Status](https://travis-ci.org/JorjMcKie/py-mupdf.svg?branch=master)](https://travis-ci.org/JorjMcKie/py-mupdf)

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

# Introduction

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

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 Expand Up @@ -79,7 +79,7 @@ Our **documentation**, written using Sphinx, is available in various formats fro

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

# Earlier Versions
Expand Down
Binary file modified doc/PyMuPDF.pdf
Binary file not shown.
Binary file modified doc/html.zip
Binary file not shown.
304 changes: 181 additions & 123 deletions fitz/fitz.i

Large diffs are not rendered by default.

86 changes: 51 additions & 35 deletions fitz/fitz.py
Original file line number Diff line number Diff line change
Expand Up @@ -98,16 +98,17 @@ class _object:

import os
import weakref
import io
from binascii import hexlify
import math

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


VersionFitz = "1.14.0"
VersionBind = "1.14.12"
VersionDate = "2019-03-21 06:59:25"
version = (VersionBind, VersionFitz, "20190321065925")
VersionBind = "1.14.13"
VersionDate = "2019-04-07 06:43:20"
version = (VersionBind, VersionFitz, "20190407064320")


class Matrix():
Expand Down Expand Up @@ -174,7 +175,7 @@ def preTranslate(self, tx, ty):
return self

def preScale(self, sx, sy):
"""Calculate pre scaling and replacing current matrix."""
"""Calculate pre scaling and replace current matrix."""
self.a *= sx
self.b *= sx
self.c *= sy
Expand Down Expand Up @@ -1782,28 +1783,36 @@ def __init__(self, filename=None, stream=None, filetype=None, rect=None, width=0
if not filename or type(filename) is str:
pass
else:
if fitz_py2: # Python 2
if fitz_py2: # Python 2
if type(filename) is unicode:
filename = filename.encode("utf8")
else:
filename = str(filename) # should take care of pathlib
filename = str(filename) # should take care of pathlib

self.streamlen = len(stream) if stream else 0
if stream:
if not (filename or filetype):
raise ValueError("need filetype for opening a stream")

if type(stream) is bytes:
self.stream = stream
elif type(stream) is bytearray:
self.stream = bytes(stream)
elif type(stream) is io.BytesIO:
self.stream = stream.getvalue()
else:
raise ValueError("'stream' has bad type")
stream = self.stream
else:
self.stream = None

self.name = ""
if filename and self.streamlen == 0:
if filename and not stream:
self.name = filename

if self.streamlen > 0:
if not (filename or filetype):
raise ValueError("filetype missing with stream specified")
if type(stream) not in (bytes, bytearray):
raise ValueError("stream must be bytes or bytearray")
else:
self.name = ""

self.isClosed = False
self.isEncrypted = 0
self.metadata = None
self.stream = stream # prevent garbage collecting this
self.openErrCode = 0
self.openErrMsg = ''
self.FontInfos = []
Expand Down Expand Up @@ -1920,9 +1929,6 @@ def embeddedFileInfo(self, id):

def embeddedFileUpd(self, id, buffer=None, filename=None, ufilename=None, desc=None):
"""Change an embedded file given its entry number or name."""
if self.isClosed or self.isEncrypted:
raise ValueError("operation illegal for closed / encrypted doc")

return _fitz.Document_embeddedFileUpd(self, id, buffer, filename, ufilename, desc)


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

def embeddedFileAdd(self, buffer, name, filename=None, ufilename=None, desc=None):
"""Embed a new file."""

if self.isClosed or self.isEncrypted:
raise ValueError("operation illegal for closed / encrypted doc")


return _fitz.Document_embeddedFileAdd(self, buffer, name, filename, ufilename, desc)


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


Expand Down Expand Up @@ -2461,17 +2469,17 @@ def saveIncr(self):

def __repr__(self):
m = "closed " if self.isClosed else ""
if self.streamlen == 0:
if self.name == "":
return m + "fitz.Document(<new PDF>)"
if self.stream is None:
if self.name is "":
return m + "fitz.Document(<new PDF, doc# %i>)" % self._graft_id
return m + "fitz.Document('%s')" % (self.name,)
return m + "fitz.Document('%s', <memory>)" % (self.name,)
return m + "fitz.Document('%s', <memory, doc# %i>)" % (self.name, self._graft_id)

def __getitem__(self, i=0):
if type(i) is not int:
raise ValueError("invalid page number(s)")
raise ValueError("bad page number(s)")
if i >= len(self):
raise IndexError("invalid page number(s)")
raise IndexError("bad page number(s)")
return self.loadPage(i)

def __len__(self):
Expand Down Expand Up @@ -2500,11 +2508,12 @@ def __del__(self):
for gmap in self.Graftmaps:
self.Graftmaps[gmap] = None
if hasattr(self, "this") and self.thisown:
self.thisown = False
self.__swig_destroy__(self)
self.thisown = False

self.Graftmaps = {}
self.ShownPages = {}
self.stream = None
self.stream = None
self._reset_page_refs = DUMMY
self.__swig_destroy__ = DUMMY
self.isClosed = True
Expand Down Expand Up @@ -3045,19 +3054,19 @@ def _setContents(self, xref=0):
def __str__(self):
CheckParent(self)
x = self.parent.name
if self.parent.streamlen > 0:
x += " (memory)"
if self.parent.stream is not None:
x = "<memory, doc# %i>" % (self.parent._graft_id,)
if x == "":
x = "<new PDF>"
x = "<new PDF, doc# %i>" % self.parent._graft_id
return "page %s of %s" % (self.number, x)

def __repr__(self):
CheckParent(self)
x = self.parent.name
if self.parent.streamlen > 0:
x += " (memory)"
if self.parent.stream is not None:
x = "<memory, doc# %i>" % (self.parent._graft_id,)
if x == "":
x = "<new PDF>"
x = "<new PDF, doc# %i>" % self.parent._graft_id
return "page %s of %s" % (self.number, x)

def _forget_annot(self, annot):
Expand Down Expand Up @@ -3877,9 +3886,11 @@ def fileGet(self):


def fileUpd(self, buffer=None, filename=None, ufilename=None, desc=None):
"""Update annotation attached file content."""
"""Update annotation attached file."""

CheckParent(self)


return _fitz.Annot_fileUpd(self, buffer, filename, ufilename, desc)

@property
Expand Down Expand Up @@ -4382,6 +4393,11 @@ def store_shrink(self, percent):
"""Free 'percent' of current store size."""
return _fitz.Tools_store_shrink(self, percent)


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

@property

def store_size(self):
Expand Down
Loading