Skip to content

Commit

Permalink
Merge pull request #254 from JorjMcKie/master
Browse files Browse the repository at this point in the history
upload v1.14.8
  • Loading branch information
JorjMcKie authored Jan 31, 2019
2 parents f4d94b8 + 864562f commit b5c8e04
Show file tree
Hide file tree
Showing 12 changed files with 431 additions and 59 deletions.
6 changes: 3 additions & 3 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.7
Version: 1.14.8
Author: Ruikai Liu
Author-email: [email protected]
Maintainer: Ruikai Liu
Expand All @@ -10,7 +10,7 @@ Download-url: https://github.com/rk700/PyMuPDF
Summary: PyMuPDF is a Python binding for the PDF rendering library MuPDF
Description:

Release date: January 15, 2019
Release date: January 31, 2019

Authors
=======
Expand All @@ -21,7 +21,7 @@ Description:
Introduction
============

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

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

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 @@ -61,21 +61,23 @@ In addition to wheels, this platform offers [pre-generated binaries](https://git
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.

# Usage and Documentation
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.
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.

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

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

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

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

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

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.

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

* You can view it online at [Read the Docs](https://pymupdf.readthedocs.io/). For **best quality downloads** use the following links.
* 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/rk700/PyMuPDF/tree/master/doc/html.zip)
* [Windows CHM](https://github.com/JorjMcKie/PyMuPDF-optional-material/tree/master/doc/PyMuPDF.chm)
* [PDF](https://github.com/rk700/PyMuPDF/blob/master/doc/PyMuPDF.pdf)
Expand Down
48 changes: 41 additions & 7 deletions fitz/fitz.i
Original file line number Diff line number Diff line change
Expand Up @@ -181,6 +181,7 @@ fitz_py2 = str is bytes # if true, this is Python 2
%include helper-other.i
%include helper-out-barray.i
%include helper-write-c.i
%include helper-pixmap.i
%include helper-geo-py.i
%include helper-annot.i
%include helper-stext.i
Expand Down Expand Up @@ -1391,7 +1392,9 @@ if links:
cbuf = fz_compressed_image_buffer(gctx, image);
type = cbuf == NULL ? FZ_IMAGE_UNKNOWN : cbuf->params.type;
// ensure returning a PNG for unsupported images ----------
if (type < FZ_IMAGE_BMP) type = FZ_IMAGE_UNKNOWN;
if (type < FZ_IMAGE_BMP ||
type == FZ_IMAGE_JBIG2)
type = FZ_IMAGE_UNKNOWN;
pdf_obj *o = pdf_dict_get(gctx, obj, PDF_NAME(SMask));
if (o) smask = pdf_to_num(gctx, o);
Expand Down Expand Up @@ -3768,7 +3771,7 @@ struct fz_pixmap_s
//----------------------------------------------------------------------
void clearWith(int value, PyObject *bbox)
{
fz_clear_pixmap_rect_with_value(gctx, $self, value, JM_irect_from_py(bbox));
JM_clear_pixmap_rect_with_value(gctx, $self, value, JM_irect_from_py(bbox));
}
//----------------------------------------------------------------------
Expand Down Expand Up @@ -3964,10 +3967,11 @@ def writePNG(self, filename, savealpha = -1):
}
fz_irect r = JM_irect_from_py(irect);
if (!fz_is_infinite_irect(r))
fz_invert_pixmap_rect(gctx, $self, r);
else
fz_invert_pixmap(gctx, $self);
if (fz_is_infinite_irect(r))
r = fz_pixmap_bbox(gctx, $self);
JM_invert_pixmap_rect(gctx, $self, r);
}
//----------------------------------------------------------------------
Expand Down Expand Up @@ -3996,7 +4000,7 @@ def writePNG(self, filename, savealpha = -1):
}
//----------------------------------------------------------------------
// Set one pixel given as a sequence
// Set one pixel to a given color tuple
//----------------------------------------------------------------------
FITZEXCEPTION(setPixel, !result)
%feature("autodoc","Set the pixel at (x,y) to the integers in sequence 'value'.") setPixel;
Expand Down Expand Up @@ -4032,6 +4036,36 @@ def writePNG(self, filename, savealpha = -1):
return NONE;
}
//----------------------------------------------------------------------
// Set a rect to a given color tuple
//----------------------------------------------------------------------
FITZEXCEPTION(setRect, !result)
%feature("autodoc","Set a rectangle to the integers in sequence 'value'.") setRect;
PyObject *setRect(PyObject *irect, PyObject *value)
{
fz_try(gctx)
{
int n = $self->n;
if (!PySequence_Check(value) || PySequence_Size(value) != n)
THROWMSG("bad pixel value");
int i, j;
unsigned char c[5];
for (j = 0; j < n; j++)
{
i = (int) PyInt_AsLong(PySequence_ITEM(value, j));
if (!INRANGE(i, 0, 255)) THROWMSG("bad pixel component");
c[j] = (unsigned char) i;
}
JM_fill_pixmap_rect_with_color(gctx, $self, c, JM_irect_from_py(irect));
}
fz_catch(gctx)
{
PyErr_Clear();
return NULL;
}
return NONE;
}
//----------------------------------------------------------------------
// get length of one image row
//----------------------------------------------------------------------
Expand Down
18 changes: 13 additions & 5 deletions fitz/fitz.py
Original file line number Diff line number Diff line change
Expand Up @@ -105,9 +105,9 @@ class _object:


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


class Matrix():
Expand Down Expand Up @@ -407,13 +407,16 @@ def abs_unit(self):

def distance_to(self, *args):
"""Return the distance to a rectangle or another point."""
assert len(args) > 0, "at least one parameter must be given"
if not len(args) > 0:
raise ValueError("at least one parameter must be given")

x = args[0]
if len(args) > 1:
unit = args[1]
else:
unit = "px"
u = {"px": (1.,1.), "in": (1.,72.), "cm": (2.54, 72.), "mm": (25.4, 72.)}
u = {"px": (1.,1.), "in": (1.,72.), "cm": (2.54, 72.),
"mm": (25.4, 72.)}
f = u[unit][0] / u[unit][1]
if type(x) is Point:
return abs(self - x) * f
Expand Down Expand Up @@ -3248,6 +3251,11 @@ def setPixel(self, x, y, value):
"""Set the pixel at (x,y) to the integers in sequence 'value'."""
return _fitz.Pixmap_setPixel(self, x, y, value)


def setRect(self, irect, value):
"""Set a rectangle to the integers in sequence 'value'."""
return _fitz.Pixmap_setRect(self, irect, value)

@property

def stride(self):
Expand Down
Loading

0 comments on commit b5c8e04

Please sign in to comment.