Skip to content

Commit b5c8e04

Browse files
authored
Merge pull request #254 from JorjMcKie/master
upload v1.14.8
2 parents f4d94b8 + 864562f commit b5c8e04

File tree

12 files changed

+431
-59
lines changed

12 files changed

+431
-59
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.14.7
3+
Version: 1.14.8
44
Author: Ruikai Liu
55
Author-email: [email protected]
66
Maintainer: Ruikai Liu
@@ -10,7 +10,7 @@ Download-url: https://github.com/rk700/PyMuPDF
1010
Summary: PyMuPDF is a Python binding for the PDF rendering library MuPDF
1111
Description:
1212

13-
Release date: January 15, 2019
13+
Release date: January 31, 2019
1414

1515
Authors
1616
=======
@@ -21,7 +21,7 @@ Description:
2121
Introduction
2222
============
2323

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

33
![logo](https://github.com/rk700/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.7 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.8 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

@@ -61,21 +61,23 @@ In addition to wheels, this platform offers [pre-generated binaries](https://git
6161
If you are looking to make your own binary, consult this [Wiki page](https://github.com/rk700/PyMuPDF/wiki/Windows-Binaries-Generation). It explains how to use Visual Studio for generating MuPDF in quite some detail.
6262

6363
# Usage and Documentation
64-
For all document types you can render pages in raster (PNG) or vector (SVG) formats, extract text and access meta information, links, annotations and bookmarks, as well as decrypt the document. For PDF files, most of these objects can also be created, modified or deleted. Plus you can rotate, re-arrange, duplicate, create, or delete pages and join or split documents.
64+
For all document types you can render pages in raster (PNG) or vector (SVG) formats, extract text and images, and access meta information, links, annotations and bookmarks, as well as decrypt the document.
6565

66-
Specifically for PDF files, PyMuPDF provides update access to low-level structure data, supports handling of embedded files and modification of page contents (like inserting images, fonts, text, annotations and drawings).
66+
For PDF files, most of these objects can also be created, modified or deleted. Plus you can rotate, re-arrange, duplicate, create, delete and split or join **pages** and you can **join or split PDF** documents.
67+
68+
Specifically for **PDF files**, PyMuPDF also provides update access to **low-level structure** data, supports handling of embedded files and modification of **page contents** (like inserting images, fonts, text, annotations and drawings).
6769

6870
Other features include embedding vector images (SVG, PDF) such as logos or watermarks, "posterizing" a PDF or creating "booklet" and "4-up" versions.
6971

70-
You can now also create and update Form PDFs and form fields with support for text, checkbox, listbox and combobox widgets.
72+
You can now also create and update **Form PDFs** and **form fields** with support for text, checkbox, listbox and combobox widgets.
7173

72-
To some degree, PyMuPDF can also be used as an [image converter](https://github.com/rk700/PyMuPDF/wiki/How-to-Convert-Images): it can read a broad range of input formats and can produce **Portable Network Graphics (PNG)**, **Portable Anymaps** (PNM, etc.), **Portable Arbitrary Maps (PAM)**, **Targa Image Files (TGA)**, **Adobe Postscript** and **Adobe Photoshop** documents, making the use of other graphics packages obselete in many cases. Interfacing with PIL/Pillow is easy as well.
74+
To some degree, PyMuPDF can also be used as an [image converter](https://github.com/rk700/PyMuPDF/wiki/How-to-Convert-Images): it can read a broad range of input formats and can produce **Portable Network Graphics (PNG)**, **Portable Anymaps** (**PNM**, etc.), **Portable Arbitrary Maps (PAM)**, **Adobe Postscript** and **Adobe Photoshop** documents, making the use of other graphics packages obselete in many cases. But interfacing with e.g. PIL/Pillow for image input and output is easy as well.
7375

7476
Have a look at the basic [demos](https://github.com/rk700/PyMuPDF/tree/master/demo), the [examples](https://github.com/rk700/PyMuPDF/tree/master/examples) (which contain complete, working programs), and the **recipes** section of our [Wiki](https://github.com/rk700/PyMuPDF/wiki) sidebar, which contains more than a dozen of guides in How-To-style.
7577

76-
Our **documentation**, written using Sphinx, is available in various formats from the following sources. It currently is a combination of a reference guide and a user manual. For a quick start to using PyMuPDF look at the [tutorial](https://pymupdf.readthedocs.io/en/latest/tutorial/) and the [recipes](https://pymupdf.readthedocs.io/en/latest/faq/) chapters.
78+
Our **documentation**, written using Sphinx, is available in various formats from the following sources. It currently is a combination of a reference guide and a user manual. For a **quick start** look at the [tutorial](https://pymupdf.readthedocs.io/en/latest/tutorial/) and the [recipes](https://pymupdf.readthedocs.io/en/latest/faq/) chapters.
7779

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

fitz/fitz.i

Lines changed: 41 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -181,6 +181,7 @@ fitz_py2 = str is bytes # if true, this is Python 2
181181
%include helper-other.i
182182
%include helper-out-barray.i
183183
%include helper-write-c.i
184+
%include helper-pixmap.i
184185
%include helper-geo-py.i
185186
%include helper-annot.i
186187
%include helper-stext.i
@@ -1391,7 +1392,9 @@ if links:
13911392
cbuf = fz_compressed_image_buffer(gctx, image);
13921393
type = cbuf == NULL ? FZ_IMAGE_UNKNOWN : cbuf->params.type;
13931394
// ensure returning a PNG for unsupported images ----------
1394-
if (type < FZ_IMAGE_BMP) type = FZ_IMAGE_UNKNOWN;
1395+
if (type < FZ_IMAGE_BMP ||
1396+
type == FZ_IMAGE_JBIG2)
1397+
type = FZ_IMAGE_UNKNOWN;
13951398
13961399
pdf_obj *o = pdf_dict_get(gctx, obj, PDF_NAME(SMask));
13971400
if (o) smask = pdf_to_num(gctx, o);
@@ -3768,7 +3771,7 @@ struct fz_pixmap_s
37683771
//----------------------------------------------------------------------
37693772
void clearWith(int value, PyObject *bbox)
37703773
{
3771-
fz_clear_pixmap_rect_with_value(gctx, $self, value, JM_irect_from_py(bbox));
3774+
JM_clear_pixmap_rect_with_value(gctx, $self, value, JM_irect_from_py(bbox));
37723775
}
37733776
37743777
//----------------------------------------------------------------------
@@ -3964,10 +3967,11 @@ def writePNG(self, filename, savealpha = -1):
39643967
}
39653968
39663969
fz_irect r = JM_irect_from_py(irect);
3967-
if (!fz_is_infinite_irect(r))
3968-
fz_invert_pixmap_rect(gctx, $self, r);
3969-
else
3970-
fz_invert_pixmap(gctx, $self);
3970+
if (fz_is_infinite_irect(r))
3971+
r = fz_pixmap_bbox(gctx, $self);
3972+
3973+
JM_invert_pixmap_rect(gctx, $self, r);
3974+
39713975
}
39723976
39733977
//----------------------------------------------------------------------
@@ -3996,7 +4000,7 @@ def writePNG(self, filename, savealpha = -1):
39964000
}
39974001
39984002
//----------------------------------------------------------------------
3999-
// Set one pixel given as a sequence
4003+
// Set one pixel to a given color tuple
40004004
//----------------------------------------------------------------------
40014005
FITZEXCEPTION(setPixel, !result)
40024006
%feature("autodoc","Set the pixel at (x,y) to the integers in sequence 'value'.") setPixel;
@@ -4032,6 +4036,36 @@ def writePNG(self, filename, savealpha = -1):
40324036
return NONE;
40334037
}
40344038
4039+
//----------------------------------------------------------------------
4040+
// Set a rect to a given color tuple
4041+
//----------------------------------------------------------------------
4042+
FITZEXCEPTION(setRect, !result)
4043+
%feature("autodoc","Set a rectangle to the integers in sequence 'value'.") setRect;
4044+
PyObject *setRect(PyObject *irect, PyObject *value)
4045+
{
4046+
fz_try(gctx)
4047+
{
4048+
int n = $self->n;
4049+
if (!PySequence_Check(value) || PySequence_Size(value) != n)
4050+
THROWMSG("bad pixel value");
4051+
int i, j;
4052+
unsigned char c[5];
4053+
for (j = 0; j < n; j++)
4054+
{
4055+
i = (int) PyInt_AsLong(PySequence_ITEM(value, j));
4056+
if (!INRANGE(i, 0, 255)) THROWMSG("bad pixel component");
4057+
c[j] = (unsigned char) i;
4058+
}
4059+
JM_fill_pixmap_rect_with_color(gctx, $self, c, JM_irect_from_py(irect));
4060+
}
4061+
fz_catch(gctx)
4062+
{
4063+
PyErr_Clear();
4064+
return NULL;
4065+
}
4066+
return NONE;
4067+
}
4068+
40354069
//----------------------------------------------------------------------
40364070
// get length of one image row
40374071
//----------------------------------------------------------------------

fitz/fitz.py

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -105,9 +105,9 @@ class _object:
105105

106106

107107
VersionFitz = "1.14.0"
108-
VersionBind = "1.14.7"
109-
VersionDate = "2019-01-17 16:53:54"
110-
version = (VersionBind, VersionFitz, "20190117165354")
108+
VersionBind = "1.14.8"
109+
VersionDate = "2019-01-30 16:03:25"
110+
version = (VersionBind, VersionFitz, "20190130160325")
111111

112112

113113
class Matrix():
@@ -407,13 +407,16 @@ def abs_unit(self):
407407

408408
def distance_to(self, *args):
409409
"""Return the distance to a rectangle or another point."""
410-
assert len(args) > 0, "at least one parameter must be given"
410+
if not len(args) > 0:
411+
raise ValueError("at least one parameter must be given")
412+
411413
x = args[0]
412414
if len(args) > 1:
413415
unit = args[1]
414416
else:
415417
unit = "px"
416-
u = {"px": (1.,1.), "in": (1.,72.), "cm": (2.54, 72.), "mm": (25.4, 72.)}
418+
u = {"px": (1.,1.), "in": (1.,72.), "cm": (2.54, 72.),
419+
"mm": (25.4, 72.)}
417420
f = u[unit][0] / u[unit][1]
418421
if type(x) is Point:
419422
return abs(self - x) * f
@@ -3248,6 +3251,11 @@ def setPixel(self, x, y, value):
32483251
"""Set the pixel at (x,y) to the integers in sequence 'value'."""
32493252
return _fitz.Pixmap_setPixel(self, x, y, value)
32503253

3254+
3255+
def setRect(self, irect, value):
3256+
"""Set a rectangle to the integers in sequence 'value'."""
3257+
return _fitz.Pixmap_setRect(self, irect, value)
3258+
32513259
@property
32523260

32533261
def stride(self):

0 commit comments

Comments
 (0)