Skip to content

Commit a5c578b

Browse files
committed
publish 1.16.9
1 parent 6fec422 commit a5c578b

14 files changed

+261
-180
lines changed

PKG-INFO

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
Metadata-Version: 1.1
22
Name: PyMuPDF
3-
Version: 1.16.8
3+
Version: 1.16.9
44
Author: Ruikai Liu
55
Author-email: [email protected]
66
Maintainer: Jorj X. McKie
@@ -9,7 +9,7 @@ Home-page: https://github.com/pymupdf/PyMuPDF
99
Download-url: https://github.com/pymupdf/PyMuPDF
1010
Summary: PyMuPDF is a Python binding for the PDF rendering library MuPDF
1111
Description:
12-
Release date: November 20, 2019
12+
Release date: December 5, 2019
1313

1414
Authors
1515
=======
@@ -20,7 +20,7 @@ Description:
2020
Introduction
2121
============
2222

23-
This is **version 1.16.8 of PyMuPDF**, a Python binding for `MuPDF <http://mupdf.com/>`_ - "a lightweight PDF and XPS viewer".
23+
This is **version 1.16.9 of PyMuPDF**, a Python binding for `MuPDF <http://mupdf.com/>`_ - "a lightweight PDF and XPS viewer".
2424

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

README.md

+8-8
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
1-
# PyMuPDF 1.16.8
1+
# PyMuPDF 1.16.9
22

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

5-
Release date: November 20, 2019
5+
Release date: December 5, 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.16.8 of PyMuPDF (formerly python-fitz)**, a Python binding with support for [MuPDF 1.16.*](http://mupdf.com/) - "a lightweight PDF, XPS, and E-book viewer".
17+
This is **version 1.16.9 of PyMuPDF (formerly python-fitz)**, a Python binding with support for [MuPDF 1.16.*](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

@@ -39,7 +39,7 @@ For all supported document types (i.e. including images) types you can
3939
* PDFs can be reformatted to support double-sided printing, posterizing, applying logos or watermarks
4040
* Password protection is fully supported: decryption, encryption, encryption method selection, permmission level and user / owner password setting.
4141
* Low-level PDF structures can be accessed and modified.
42-
* Starting with v1.16.8, PyMuPDF can also be used as a **module in the command line** using ``"python -m fitz ..."``. This is a versatile utility, which we will further develop over time. It currently supports PDF document
42+
* Starting with v1.16.9, PyMuPDF can also be used as a **module in the command line** using ``"python -m fitz ..."``. This is a versatile utility, which we will further develop over time. It currently supports PDF document
4343

4444
- **encryption / decryption / optimization**
4545
- creating **sub-documents**
@@ -63,7 +63,7 @@ For the major **Windows** and (thanks to our user **@jbarlow83**!) **Mac OSX** o
6363

6464
> The Mac OSX platform tags are `macosx_10_6_intel` (up to Python 3.7) or ``macosx_10_9_x86_64``. For Linux the tag is ``manylinux2010_x86_64``.
6565
66-
> As of November 2019 and starting with PyMuPDF v1.16.8, wheel creation is supported for Python 64bit versions 2.7, 3.5, 3.6, 3.7 and 3.8 only. **Support of Python 3.4 has been dropped.**
66+
> As of November 2019 and starting with PyMuPDF v1.16.9, wheel creation is supported for Python 64bit versions 2.7, 3.5, 3.6, 3.7 and 3.8 only. **Support for Python 3.4 has been dropped.**
6767
6868
For other Python versions or operating systems you need to generate PyMuPDF yourself as follows (and of course you can choose to do so for a wheel-supported platform, too).
6969

@@ -73,16 +73,16 @@ To do this, you must download and generate MuPDF. This process depends very much
7373

7474
* Be sure to download the official MuPDF source release from [here](https://mupdf.com/downloads/archive). Do **not use** MuPDF's [GitHub repo](https://github.com/ArtifexSoftware/mupdf). It contains their current **development source**, which is **not compatible** with this PyMuPDF version most of the time.
7575

76-
* This repo's `fitz` folder contains one or more files whose names start with an underscore `"_"`. These files contain configuration data and hotfixes. Each one must be copy-renamed to its correct target location **inside the MuPDF source** that you have downloaded, **before you generate MuPDF**. Currently, these files are:
76+
* This repo's `fitz` folder contains one or more files whose names start with a sinlge underscore `"_"`. These files contain configuration data and hotfixes. Each one must be copy-renamed to its correct target location **inside the MuPDF source** that you have downloaded, **before you generate MuPDF**. Currently, these files are:
7777
- fitz configuration file `_config.h` copy-replace to: `mupdf/include/mupdf/fitz/config.h`. It contains configuration data like e.g. which fonts to support.
7878

7979
- Now MuPDF can be generated.
8080

81-
* Since PyMuPDF v1.14.17, the sources provided in this repository **no longer contain** the interface files ``fitz.py`` and ``fitz.wrap.c`` - they are generated **"on the fly"** by ``setup.py`` using the interface generator [SWIG](http://www.swig.org/). So you need SWIG being installed on your system. Please refer to issue #312 for some background.
81+
* Since PyMuPDF v1.14.17, the sources provided in this repository **no longer contain** the interface files ``fitz.py`` and ``fitz.wrap.c`` - they are instead generated **"on the fly"** by ``setup.py`` using the interface generator [SWIG](http://www.swig.org/). So you need SWIG being installed on your system. Please refer to issue #312 for some background.
8282
- PyMuPDF wheels have been generated using **SWIG v4.0.1**.
8383

8484

85-
* If you do **not (want to) use SWIG**, please download the **sources from PyPI** - they continue to contain those generated interface files, and installation should work like any other generation of Python extensions for your system.
85+
* If you do **not (want to) use SWIG**, please download the **sources from PyPI** - they continue to contain those generated files, so installation should work like any other Python extension generation on your system.
8686

8787
Once this is done, adjust directories in ``setup.py`` and run ``python setup.py install``.
8888

doc/PyMuPDF.pdf

22.2 KB
Binary file not shown.

doc/html.zip

38 KB
Binary file not shown.

fitz/__main__.py

+27-27
Original file line numberDiff line numberDiff line change
@@ -26,13 +26,13 @@ def getimage(pix):
2626

2727
"""Sanity check:
2828
- both pixmaps must have the same rectangle
29-
- both pixmaps must not have alpha
29+
- both pixmaps must have alpha=0
3030
- pix2 must consist of 1 byte per pixel
3131
"""
3232
if not (pix1.irect == pix2.irect and pix1.alpha == pix2.alpha == 0 and pix2.n == 1):
3333
pix2 = None
3434
print("Warning: unsupported /SMask %i for %i." % (s, x))
35-
return getimage(pix1)
35+
return getimage(pix1) # return the pixmap as is
3636

3737
pix = fitz.Pixmap(pix1) # copy of pix1, with an alpha channel added
3838
pix.setAlpha(pix2.samples) # treat pix2.samples as the alpha values
@@ -42,13 +42,13 @@ def getimage(pix):
4242
return getimage(pix)
4343

4444

45-
def open_file(filename, password, show=False):
46-
"""Open and authenticate a PDF.
45+
def open_file(filename, password, show=False, pdf=True):
46+
"""Open and authenticate a document.
4747
"""
4848
doc = fitz.open(filename)
49+
if not doc.isPDF and pdf is True:
50+
sys.exit("this command supports PDF files only")
4951
rc = -1
50-
if not doc.isPDF:
51-
sys.exit("not a PDF document")
5252
if not doc.needsPass:
5353
return doc
5454
if password:
@@ -63,7 +63,7 @@ def open_file(filename, password, show=False):
6363

6464

6565
def print_dict(item):
66-
"""Print a dictionary.
66+
"""Print a Python dictionary.
6767
"""
6868
l = max([len(k) for k in item.keys()]) + 1
6969
for k, v in item.items():
@@ -75,7 +75,8 @@ def print_dict(item):
7575
def print_xref(doc, xref):
7676
"""Print an object given by XREF number.
7777
78-
Simulate the PDF source in "pretty" format. If a stream also include its size.
78+
Simulate the PDF source in "pretty" format.
79+
For a stream also print its size.
7980
"""
8081
print("%i 0 obj" % xref)
8182
xref_str = doc.xrefObject(xref)
@@ -95,7 +96,7 @@ def print_xref(doc, xref):
9596

9697

9798
def get_list(rlist, limit):
98-
"""Transform a page or xref specification into a list.
99+
"""Transform a page / xref specification into a list of integers.
99100
100101
Args:
101102
rlist: (str) the specification
@@ -197,7 +198,7 @@ def show(args):
197198

198199

199200
def clean(args):
200-
doc = open_file(args.input, args.password)
201+
doc = open_file(args.input, args.password, pdf=True)
201202
encryption = args.encryption
202203
encrypt = ("keep", "none", "rc4-40", "rc4-128", "aes-128", "aes-256").index(
203204
encryption
@@ -250,7 +251,7 @@ def doc_join(args):
250251
for src_item in doc_list: # process one input PDF
251252
src_list = src_item.split(",")
252253
password = src_list[1] if len(src_list) > 1 else None
253-
src = open_file(src_list[0], password)
254+
src = open_file(src_list[0], password, pdf=True)
254255
pages = ",".join(src_list[2:]) # get 'pages' specifications
255256
if pages: # if anything there, retrieve a list of desired pages
256257
page_list = get_list(",".join(src_list[2:]), src.pageCount + 1)
@@ -267,7 +268,7 @@ def doc_join(args):
267268
def embedded_copy(args):
268269
"""Copy embedded files between PDFs.
269270
"""
270-
doc = open_file(args.input, args.password)
271+
doc = open_file(args.input, args.password, pdf=True)
271272
if not doc.can_save_incrementally() and (not args.output or args.output == args.input):
272273
sys.exit("cannot save PDF incrementally")
273274
src = open_file(args.source, args.pwdsource)
@@ -306,7 +307,7 @@ def embedded_copy(args):
306307
def embedded_del(args):
307308
"""Delete an embedded file entry.
308309
"""
309-
doc = open_file(args.input, args.password)
310+
doc = open_file(args.input, args.password, pdf=True)
310311
if not doc.can_save_incrementally() and (not args.output or args.output == args.input):
311312
sys.exit("cannot save PDF incrementally")
312313

@@ -324,7 +325,7 @@ def embedded_del(args):
324325
def embedded_get(args):
325326
"""Retrieve contents of an embedded file.
326327
"""
327-
doc = open_file(args.input, args.password)
328+
doc = open_file(args.input, args.password, pdf=True)
328329
try:
329330
stream = doc.embeddedFileGet(args.name)
330331
d = doc.embeddedFileInfo(args.name)
@@ -341,7 +342,7 @@ def embedded_get(args):
341342
def embedded_add(args):
342343
"""Insert a new embedded file.
343344
"""
344-
doc = open_file(args.input, args.password)
345+
doc = open_file(args.input, args.password, pdf=True)
345346
if not doc.can_save_incrementally() and (args.output is None or args.output == args.input):
346347
sys.exit("cannot save PDF incrementally")
347348

@@ -373,7 +374,7 @@ def embedded_add(args):
373374
def embedded_upd(args):
374375
"""Update contents or metadata of an embedded file
375376
"""
376-
doc = open_file(args.input, args.password)
377+
doc = open_file(args.input, args.password, pdf=True)
377378
if not doc.can_save_incrementally() and (args.output is None or args.output == args.input):
378379
sys.exit("cannot save PDF incrementally")
379380

@@ -421,7 +422,7 @@ def embedded_upd(args):
421422
def embedded_list(args):
422423
"""List embedded files.
423424
"""
424-
doc = open_file(args.input, args.password)
425+
doc = open_file(args.input, args.password, pdf=True)
425426
names = doc.embeddedFileNames()
426427
if args.name is not None:
427428
if args.name not in names:
@@ -460,7 +461,7 @@ def extract_objects(args):
460461
"""
461462
if not args.fonts and not args.images:
462463
sys.exit("neither fonts nor images requested")
463-
doc = open_file(args.input, args.password)
464+
doc = open_file(args.input, args.password, pdf=True)
464465

465466
if args.pages:
466467
pages = get_list(args.pages, doc.pageCount)
@@ -601,11 +602,10 @@ def main():
601602
help="format for fast web display",
602603
)
603604

604-
ps_clean.add_argument("-permission", type=int, default=-1, help="permission levels")
605+
ps_clean.add_argument("-permission", type=int, default=-1, help="integer with permission levels")
605606

606607
ps_clean.add_argument(
607-
"-san",
608-
"--sanitize",
608+
"-sanitize",
609609
action="store_true",
610610
default=False,
611611
help="sanitize / clean contents",
@@ -638,10 +638,10 @@ def main():
638638
ps_extract.add_argument("input", type=str, help="PDF filename")
639639
ps_extract.add_argument("-images", action="store_true", help="extract images")
640640
ps_extract.add_argument("-fonts", action="store_true", help="extract fonts")
641-
ps_extract.add_argument("-output", help="output directory, defaults to current")
641+
ps_extract.add_argument("-output", help="folder to receive output, defaults to current")
642642
ps_extract.add_argument("-password", help="password")
643643
ps_extract.add_argument(
644-
"-pages", type=str, help="consider only selected pages, format: 1,5-7,50-N"
644+
"-pages", type=str, help="consider these pages only, format: 1,5-7,50-N"
645645
)
646646
ps_extract.set_defaults(func=extract_objects)
647647

@@ -742,18 +742,18 @@ def main():
742742
)
743743
ps_embed_copy.add_argument("-source", required=True, help="copy embedded files from here")
744744
ps_embed_copy.add_argument("-pwdsource", help="password of 'source' PDF")
745-
ps_embed_copy.add_argument("-name", nargs="*", help="copy these entries, or all if omitted")
745+
ps_embed_copy.add_argument("-name", nargs="*", help="restrict copy to these entries")
746746
ps_embed_copy.set_defaults(func=embedded_copy)
747747

748748

749749
# -------------------------------------------------------------------------
750750
# start program
751751
# -------------------------------------------------------------------------
752-
args = parser.parse_args()
752+
args = parser.parse_args() # create parameter arguments class
753753
if not hasattr(args, "func"): # no function selected
754-
parser.print_help()
754+
parser.print_help() # so print top level help
755755
else:
756-
args.func(args)
756+
args.func(args) # execute requested command
757757

758758

759759
if __name__ == "__main__":

0 commit comments

Comments
 (0)