Skip to content

Commit

Permalink
Merge pull request #250 from JorjMcKie/master
Browse files Browse the repository at this point in the history
upgrade to v1.14.7
  • Loading branch information
JorjMcKie authored Jan 17, 2019
2 parents ecb0fb0 + 0b6c02e commit 70691fc
Show file tree
Hide file tree
Showing 11 changed files with 412 additions and 226 deletions.
78 changes: 78 additions & 0 deletions PKG-INFO
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
Metadata-Version: 1.1
Name: PyMuPDF
Version: 1.14.7
Author: Ruikai Liu
Author-email: [email protected]
Maintainer: Ruikai Liu
Maintainer-email: [email protected]
Home-page: https://github.com/rk700/PyMuPDF
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

Authors
=======

* Ruikai Liu
* Jorj X. McKie

Introduction
============

This is **version 1.14.7 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.

With PyMuPDF you therefore can access files with extensions ``*.pdf``, ``*.xps``, ``*.oxps``, ``*.epub``, ``*.cbz`` or ``*.fb2`` from your Python scripts. A number of popular image formats is supported as well, including multi-page TIFF images.

PyMuPDF should run on all platforms that are supported by both, MuPDF and Python. These include, but are not limited to, Windows (XP/SP2 and up), Mac OS and Linux, 32-bit or 64-bit. If you can generate MuPDF on a Python supported platform, then also PyMuPDF can be used there.

PyMuPDF is hosted on `GitHub <https://github.com/rk700/PyMuPDF>`_ where you find up-to-date information of its features, our `issue tracker <https://github.com/rk700/PyMuPDF/issues>`_, `Wikis <https://github.com/rk700/PyMuPDF/wiki>`_ and much more.

Installation
============

For all MS Windows versions as well as popular Max OS and Linux versions, we are providing Python wheels - see the download section of this site and the current `release directory <https://github.com/rk700/PyMuPDF/releases/latest>`_ of our home page. For Windows users, `zip-based installation <https://github.com/JorjMcKie/PyMuPDF-Optional-Material>`_ options are also available. Other platforms need to download and generate the MuPDF library first and then set up PyMuPDF. Do visit our GitHub home, which has more details on this, including latest bugfixes, pre-releases, etc.

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.

Specifically for PDF files, PyMuPDF provides update access to low-level structure information, supports handling of embedded files and modification of page contents (like inserting images, fonts, text, annotations and drawings). When saving changes to password protected PDFs you can now choose, whether to keep or remove encryption.

Other features include embedding vector images (SVG, PDF) such as logos or watermarks, joining or splitting single PDF pages (including things like posterizing and 2-up / 4-up processing).

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

Our home page provides many examples and How-Tos for all of this. At a minimum, read the tutorial and the the recipes sections of our documentation.

Written using **Sphinx**, documentation is available here:

* View it online at `Read The Docs <https://pymupdf.readthedocs.io/en/latest/>`_. For **best quality downloads**, use the following links.

* `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/tree/master/doc/pymupdf.pdf>`_


Classifier: Development Status :: 5 - Production/Stable
Classifier: Environment :: Console
Classifier: Intended Audience :: Developers
Classifier: License :: OSI Approved :: GNU Affero General Public License v3 or later (AGPLv3+)
Classifier: License :: OSI Approved :: GNU General Public License v3 or later (GPLv3+)
Classifier: Operating System :: MacOS
Classifier: Operating System :: Microsoft :: Windows
Classifier: Operating System :: POSIX :: Linux
Classifier: Programming Language :: C
Classifier: Programming Language :: Python :: 2.7
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.4
Classifier: Programming Language :: Python :: 3.5
Classifier: Programming Language :: Python :: 3.6
Classifier: Programming Language :: Python :: 3.7
Classifier: Topic :: Utilities
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.6
# PyMuPDF 1.14.7

![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.6 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.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".

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
71 changes: 43 additions & 28 deletions fitz/fitz.i
Original file line number Diff line number Diff line change
Expand Up @@ -6352,6 +6352,12 @@ struct Tools
JM_point_from_py(p)));
}
%feature("autodoc","Transform point with matrix.") _transform_point;
PyObject *_transform_point(PyObject *point, PyObject *matrix)
{
return JM_py_from_point(fz_transform_point(JM_point_from_py(point), JM_matrix_from_py(matrix)));
}
%feature("autodoc","Replace r1 with smallest rect containing both.") _union_rect;
PyObject *_union_rect(PyObject *r1, PyObject *r2)
{
Expand Down Expand Up @@ -6389,15 +6395,24 @@ struct Tools
}
%feature("autodoc","Measure length of a string for a Base14 font.") measure_string;
float measure_string(const char *text, const char *fontname, float fontsize)
float measure_string(const char *text, const char *fontname, float fontsize,
int encoding = 0)
{
fz_font *font = fz_new_base14_font(gctx, fontname);
float w = 0;
while (*text)
{
int c, g;
text += fz_chartorune(&c, text);
c = pdf_winansi_from_unicode(c);
switch (encoding)
{
case PDF_SIMPLE_ENCODING_GREEK:
c = pdf_greek_from_unicode(c); break;
case PDF_SIMPLE_ENCODING_CYRILLIC:
c = pdf_cyrillic_from_unicode(c); break;
default:
c = pdf_winansi_from_unicode(c); break;
}
if (c < 0) c = 0xB7;
g = fz_encode_character(gctx, font, c);
w += fz_advance_glyph(gctx, font, g, 0);
Expand Down Expand Up @@ -6440,7 +6455,7 @@ def _oval_string(self, p1, p2, p3, p4):
"""Return /AP string defining an oval within a 4-polygon provided as points
"""
def bezier(p, q, r):
f = "%g %g %g %g %g %g c\n"
f = "%f %f %f %f %f %f c\n"
return f % (p.x, p.y, q.x, q.y, r.x, r.y)
kappa = 0.55228474983 # magic number
Expand All @@ -6457,7 +6472,7 @@ def _oval_string(self, p1, p2, p3, p4):
ul1 = mu + (p4 - mu) * kappa
ul2 = ml + (p4 - ml) * kappa
# now draw, starting from middle point of left side
ap = "%g %g m\n" % (ml.x, ml.y)
ap = "%f %f m\n" % (ml.x, ml.y)
ap += bezier(ol1, ol2, mo)
ap += bezier(or1, or2, mr)
ap += bezier(ur1, ur2, mu)
Expand All @@ -6474,13 +6489,13 @@ def _le_diamond(self, annot, p1, p2, lr):
r = Rect(M, M) + (-d, -d, d, d) # the square
# the square makes line longer by (2*shift - 1)*width
p = (r.tl + (r.bl - r.tl) * 0.5) * im
ap = "q\n%s%g %g m\n" % (opacity, p.x, p.y)
ap = "q\n%s%f %f m\n" % (opacity, p.x, p.y)
p = (r.tl + (r.tr - r.tl) * 0.5) * im
ap += "%g %g l\n" % (p.x, p.y)
ap += "%f %f l\n" % (p.x, p.y)
p = (r.tr + (r.br - r.tr) * 0.5) * im
ap += "%g %g l\n" % (p.x, p.y)
ap += "%f %f l\n" % (p.x, p.y)
p = (r.br + (r.bl - r.br) * 0.5) * im
ap += "%g %g l\n" % (p.x, p.y)
ap += "%f %f l\n" % (p.x, p.y)
ap += "%g w\n" % w
ap += scol + fcol + "b\nQ\n"
return ap
Expand All @@ -6495,13 +6510,13 @@ def _le_square(self, annot, p1, p2, lr):
r = Rect(M, M) + (-d, -d, d, d) # the square
# the square makes line longer by (2*shift - 1)*width
p = r.tl * im
ap = "q\n%s%g %g m\n" % (opacity, p.x, p.y)
ap = "q\n%s%f %f m\n" % (opacity, p.x, p.y)
p = r.tr * im
ap += "%g %g l\n" % (p.x, p.y)
ap += "%f %f l\n" % (p.x, p.y)
p = r.br * im
ap += "%g %g l\n" % (p.x, p.y)
ap += "%f %f l\n" % (p.x, p.y)
p = r.bl * im
ap += "%g %g l\n" % (p.x, p.y)
ap += "%f %f l\n" % (p.x, p.y)
ap += "%g w\n" % w
ap += scol + fcol + "b\nQ\n"
return ap
Expand All @@ -6528,8 +6543,8 @@ def _le_butt(self, annot, p1, p2, lr):
M = R if lr else L
top = (M + (0, -d/2.)) * im
bot = (M + (0, d/2.)) * im
ap = "\nq\n%s%g %g m\n" % (opacity, top.x, top.y)
ap += "%g %g l\n" % (bot.x, bot.y)
ap = "\nq\n%s%f %f m\n" % (opacity, top.x, top.y)
ap += "%f %f l\n" % (bot.x, bot.y)
ap += "%g w\n" % w
ap += scol + "s\nQ\n"
return ap
Expand All @@ -6543,8 +6558,8 @@ def _le_slash(self, annot, p1, p2, lr):
r = Rect(M.x - rw, M.y - 2 * w, M.x + rw, M.y + 2 * w)
top = r.tl * im
bot = r.br * im
ap = "\nq\n%s%g %g m\n" % (opacity, top.x, top.y)
ap += "%g %g l\n" % (bot.x, bot.y)
ap = "\nq\n%s%f %f m\n" % (opacity, top.x, top.y)
ap += "%f %f l\n" % (bot.x, bot.y)
ap += "%g w\n" % w
ap += scol + "s\nQ\n"
return ap
Expand All @@ -6561,9 +6576,9 @@ def _le_openarrow(self, annot, p1, p2, lr):
p1 *= im
p2 *= im
p3 *= im
ap = "\nq\n%s%g %g m\n" % (opacity, p1.x, p1.y)
ap += "%g %g l\n" % (p2.x, p2.y)
ap += "%g %g l\n" % (p3.x, p3.y)
ap = "\nq\n%s%f %f m\n" % (opacity, p1.x, p1.y)
ap += "%f %f l\n" % (p2.x, p2.y)
ap += "%f %f l\n" % (p3.x, p3.y)
ap += "%g w\n" % w
ap += scol + "S\nQ\n"
return ap
Expand All @@ -6580,9 +6595,9 @@ def _le_closedarrow(self, annot, p1, p2, lr):
p1 *= im
p2 *= im
p3 *= im
ap = "\nq\n%s%g %g m\n" % (opacity, p1.x, p1.y)
ap += "%g %g l\n" % (p2.x, p2.y)
ap += "%g %g l\n" % (p3.x, p3.y)
ap = "\nq\n%s%f %f m\n" % (opacity, p1.x, p1.y)
ap += "%f %f l\n" % (p2.x, p2.y)
ap += "%f %f l\n" % (p3.x, p3.y)
ap += "%g w\n" % w
ap += scol + fcol + "b\nQ\n"
return ap
Expand All @@ -6599,9 +6614,9 @@ def _le_ropenarrow(self, annot, p1, p2, lr):
p1 *= im
p2 *= im
p3 *= im
ap = "\nq\n%s%g %g m\n" % (opacity, p1.x, p1.y)
ap += "%g %g l\n" % (p2.x, p2.y)
ap += "%g %g l\n" % (p3.x, p3.y)
ap = "\nq\n%s%f %f m\n" % (opacity, p1.x, p1.y)
ap += "%f %f l\n" % (p2.x, p2.y)
ap += "%f %f l\n" % (p3.x, p3.y)
ap += "%g w\n" % w
ap += scol + fcol + "S\nQ\n"
return ap
Expand All @@ -6618,9 +6633,9 @@ def _le_rclosedarrow(self, annot, p1, p2, lr):
p1 *= im
p2 *= im
p3 *= im
ap = "\nq\n%s%g %g m\n" % (opacity, p1.x, p1.y)
ap += "%g %g l\n" % (p2.x, p2.y)
ap += "%g %g l\n" % (p3.x, p3.y)
ap = "\nq\n%s%f %f m\n" % (opacity, p1.x, p1.y)
ap += "%f %f l\n" % (p2.x, p2.y)
ap += "%f %f l\n" % (p3.x, p3.y)
ap += "%g w\n" % w
ap += scol + fcol + "b\nQ\n"
return ap
Expand Down
Loading

0 comments on commit 70691fc

Please sign in to comment.