Skip to content

Commit d268944

Browse files
committed
publish v1.14.20
1 parent d49f75a commit d268944

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

43 files changed

+326
-1267
lines changed

PKG-INFO

Lines changed: 3 additions & 4 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.19
3+
Version: 1.14.20
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: July 18, 2019
12+
Release date: August 10, 2019
1313

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

23-
This is **version 1.14.19 of PyMuPDF**, a Python binding for `MuPDF <http://mupdf.com/>`_ - "a lightweight PDF and XPS viewer".
23+
This is **version 1.14.20 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

@@ -57,7 +57,6 @@ Description:
5757
* `Windows CHM <https://github.com/JorjMcKie/PyMuPDF-optional-material/tree/master/doc/PyMuPDF.chm>`_
5858

5959
* `PDF <https://github.com/pymupdf/PyMuPDF/tree/master/doc/pymupdf.pdf>`_
60-
6160

6261
Classifier: Development Status :: 5 - Production/Stable
6362
Classifier: Environment :: Console

README.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
1-
# PyMuPDF 1.14.19
1+
# PyMuPDF 1.14.20
22

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

5-
Release date: Juli 18, 2019
5+
Release date: August 2, 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.14.19 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.20 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

demo/PIL2fitz.py

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,24 +3,26 @@
33
import fitz
44
from PIL import Image
55
import sys
6-
'''
6+
7+
print(fitz.__doc__)
8+
"""
79
Create a Pixmap from any PIL / Pillow supported filetype
810
Changes in v1.10.0
911
-------------------
1012
- omit alpha to save image memory
11-
'''
13+
"""
1214
if len(sys.argv) == 2:
1315
pic_fn = sys.argv[1]
1416
else:
1517
pic_fn = None
1618

1719
if pic_fn:
18-
print('Reading %s' % pic_fn)
20+
print("Reading %s" % pic_fn)
1921
pic_f = open(pic_fn, "rb")
2022
img = Image.open(pic_f).convert("RGB")
2123
samples = img.tobytes()
2224
pix = fitz.Pixmap(fitz.csRGB, img.size[0], img.size[1], samples, 0)
23-
outputFileName = pic_fn + '-from-PIL.png'
24-
print('Writing %s' % outputFileName)
25+
outputFileName = pic_fn + "-from-PIL.png"
26+
print("Writing %s" % outputFileName)
2527
pix.writePNG(outputFileName)
2628
pic_f.close()

demo/README.md

Lines changed: 6 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -2,31 +2,22 @@
22

33
Program | Purpose
44
------- | -------
5-
annot-tests.py | produce a PDF with assorted annotations
65
caustic.py | demo producing a PDF with the catacaustic
7-
list-fields.py | prints field information for a Form PDF
6+
curly-polygon.py | demo draw regular polygon with curly border
7+
decrypt.py | create a decrypted copy of a PDF file
88
demo.py | demonstrates a broad range of PyMuPDF high-level functions
99
demo-lowlevel.py | demonstrates PyMuPDF low-level functions
1010
draw-sines.py | draw sine / cosine functions
11-
extract-img1.py | PDF only: extracts all **page-referenced** images as PNG files
12-
extract-img2.py | PDF only: extracts **all** (valid) images as PNG files
13-
extract-img3.py | PDF only: extracts page images using raw image buffers (variable extensions)
14-
extract-img4.py | Any Document type: extracts page images (with variable extensions) using the v1.13.1 getText("dict") method
1511
fitz2PIL.py | save a pixmap as a PIL / Pillow supported file
16-
PIL2fitz.py | create a pixmap from any PIL / Pillow supported file
12+
fitz-logo.py | put any document as logo an each PDF page.
1713
numpy2fitz.py | how to create pixmaps from NumPy arrays
14+
pdf-converter.py | convert arbitrary documents (XPS, EPUB, CBZ, etc.) to PDF
1815
PDFdisplay.py | display a document using wxPython
1916
pdfviewer(wx).py | alternative wxPython viewer
20-
pencil.py | create the pencil of the ReportLab User Guide with PyMuPDF
21-
piechart1.py | create a circular pie chart
22-
piechart2.py | create a semi-circular pie chart
17+
PIL2fitz.py | create a pixmap from any PIL / Pillow supported file
2318
pixmap-tiles.py | use pixmap to create tiled copies of an image file
24-
decrypt.py | create a decrypted copy of a PDF file
2519
sierpinski.py | create a Sierpinski carpet (fractal) fast with pixmaps
2620
splitter.py | split a PDF into its pages (1 PDF per page)
27-
fitz-logo.py | put any document as logo an each PDF page.
28-
svg-logo.py | put an SVG as logo an each PDF page.
2921
spumoni.py | create the ReportLab drawing on page 26 with PyMuPDF
22+
svg-logo.py | put an SVG as logo an each PDF page.
3023
text2pdf.py | convert a text file to PDF
31-
wavy-polygon.py | draw a regular polygon with curly borders
32-
pdf-converter.py | convert arbitrary documents (XPS, EPUB, CBZ, etc.) to PDF

demo/caustic.py

Lines changed: 29 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,10 @@
33
import fitz
44
from fitz.utils import getColor
55
import gzip
6+
67
"""
8+
@Copyright 2017-2019, Jorj McKie, mailto:<[email protected]>
9+
710
@created: 2017-06-18 10:00:00
811
912
@author: (c) Jorj X. McKie
@@ -26,42 +29,48 @@
2629
The resulting picture is save in three image formats: PDF, PNG and SVG / SVGZ
2730
2831
"""
32+
print(fitz.__doc__)
33+
34+
2935
def pvon(a):
3036
"""Starting point of a reflected sun ray, given an angle a."""
31-
return(math.cos(a), math.sin(a))
37+
return (math.cos(a), math.sin(a))
38+
3239

3340
def pbis(a):
3441
"""End point of a reflected sun ray, given an angle a."""
35-
return(math.cos(3*a - math.pi), (math.sin(3*a - math.pi)))
42+
return (math.cos(3 * a - math.pi), (math.sin(3 * a - math.pi)))
43+
3644

37-
fileprfx = "catacaustic" # filename prefix
38-
coffee = getColor("coffee") # color: latte macchiato?
39-
yellow = getColor("yellow") # color of sun rays
40-
blue = getColor("blue") # color cup border
41-
doc = fitz.open() # new empty PDF
42-
page = doc.newPage(-1, width = 800, height = 800)# create square sized page
43-
center = fitz.Point(page.rect.width / 2, # center of circle on page
44-
page.rect.height / 2)
45+
fileprfx = "catacaustic" # filename prefix
46+
coffee = getColor("coffee") # color: latte macchiato?
47+
yellow = getColor("yellow") # color of sun rays
48+
blue = getColor("blue") # color cup border
49+
doc = fitz.open() # new empty PDF
50+
page = doc.newPage(-1, width=800, height=800) # create square sized page
51+
center = fitz.Point(
52+
page.rect.width / 2, page.rect.height / 2 # center of circle on page
53+
)
4554

46-
radius = page.rect.width / 2 - 20 # leave a border of 20 pixels
55+
radius = page.rect.width / 2 - 20 # leave a border of 20 pixels
4756

4857
img = page.newShape()
4958
img.drawCircle(center, radius)
50-
img.finish(color = coffee, fill = coffee) # fill coffee into the cup
59+
img.finish(color=coffee, fill=coffee) # fill coffee into the cup
5160

52-
count = 200 # how many sun rays we draw
53-
interval = math.pi / count # angle fraction
61+
count = 200 # how many sun rays we draw
62+
interval = math.pi / count # angle fraction
5463
for i in range(1, count):
55-
a = -math.pi / 2 + i * interval # go from -90 to +90 degrees
64+
a = -math.pi / 2 + i * interval # go from -90 to +90 degrees
5665
von = fitz.Point(pvon(a)) * radius + center # start point adjusted
5766
bis = fitz.Point(pbis(a)) * radius + center # end point adjusted
5867
img.drawLine(von, bis)
59-
60-
img.finish(width = 1, color = yellow, closePath = False) # a ray is a fine yellow line
68+
69+
img.finish(width=1, color=yellow, closePath=False) # a ray is a fine yellow line
6170

6271
img.drawCircle(center, radius)
63-
img.finish(color = blue) # cup border is blue
64-
page.setCropBox(img.rect) # adjust visible page
72+
img.finish(color=blue) # cup border is blue
73+
page.setCropBox(img.rect) # adjust visible page
6574
img.commit()
6675
doc.save(fileprfx + ".pdf")
6776

@@ -76,4 +85,4 @@ def pbis(a):
7685
fout.close()
7786
fout = open(fileprfx + ".svgz", "wb")
7887
fout.write(svgz)
79-
fout.close()
88+
fout.close()

demo/curly-polygon.py

Lines changed: 18 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
"""
22
Created on 2017-09-06
33
4-
@author: (c) 2017, Jorj X. McKie
4+
Copyright 2017-2019, Jorj McKie, mailto:<[email protected]>
55
66
License: GNU GPL V3
77
@@ -22,17 +22,20 @@
2222
"""
2323

2424
import fitz
25+
26+
print(fitz.__doc__)
27+
2528
fname1 = "curly-polygon"
26-
doc = fitz.open()
27-
page = doc.newPage()
28-
img = page.newShape()
29-
nedge = 5 # number of polygon edges
30-
breadth = 2 # wave amplitude
31-
beta = -1.0 * 360 / nedge # our angle, drawn clockwise
32-
center = fitz.Point(300,300) # center of circle
33-
p0 = fitz.Point(300,200) # start here (1st edge = north)
34-
p1 = +p0 # save as last edge to add
35-
points = [p0] # to store the polygon edges
29+
doc = fitz.open()
30+
page = doc.newPage()
31+
img = page.newShape()
32+
nedge = 5 # number of polygon edges
33+
breadth = 2 # wave amplitude
34+
beta = -1.0 * 360 / nedge # our angle, drawn clockwise
35+
center = fitz.Point(300, 300) # center of circle
36+
p0 = fitz.Point(300, 200) # start here (1st edge = north)
37+
p1 = +p0 # save as last edge to add
38+
points = [p0] # to store the polygon edges
3639

3740
# we only use this to calculate the polygon edges
3841
# we will delete the resp. draw commands
@@ -41,14 +44,14 @@
4144
points.append(p0)
4245

4346
# erase previous draw commands in contents buffer
44-
img.contents = ""
47+
img.draw_cont = ""
4548

46-
points.append(p1) # add starting point to edges list
49+
points.append(p1) # add starting point to edges list
4750
# now draw the lines along stored edges
4851
for i in range(nedge):
49-
img.drawSquiggle(points[i], points[i+1], breadth = breadth)
52+
img.drawSquiggle(points[i], points[i + 1], breadth=breadth)
5053

51-
img.finish(color = (0,0,1), fill = (1,1,0), closePath = False)
54+
img.finish(color=(0, 0, 1), fill=(1, 1, 0), closePath=False)
5255

5356
# adjust visible page to dimensions of the drawing
5457
page.setCropBox(img.rect)

demo/decrypt.py

Lines changed: 15 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
11
"""
2+
Copyright 2016-2019, Jorj McKie, mailto:<[email protected]>
3+
24
This demo will open an encrypted PDF document, decrypt it with the provided
35
password and save as a new PDF document.
46
@@ -7,17 +9,21 @@
79
import fitz
810
import sys
911

10-
assert len(sys.argv) == 4, \
11-
'Usage: %s <input file> <password> <output file>' % sys.argv[0]
12+
print(fitz.__doc__)
13+
assert len(sys.argv) == 4, (
14+
"Usage: %s <input file> <password> <output file>" % sys.argv[0]
15+
)
1216

1317
doc = fitz.Document(sys.argv[1])
14-
#the document should be password protected
18+
# the document should be password protected
1519
assert doc.needsPass, sys.argv[0] + " not password protected"
1620

17-
#decrypt the document
18-
#return non-zero if failed
19-
assert doc.authenticate(sys.argv[2]), \
20-
'cannot decrypt %s with password "%s"' % (sys.argv[1], sys.argv[2])
21+
# decrypt the document
22+
# return non-zero if failed
23+
assert doc.authenticate(sys.argv[2]), 'cannot decrypt %s with password "%s"' % (
24+
sys.argv[1],
25+
sys.argv[2],
26+
)
2127

22-
#save as a new PDF
23-
doc.save(sys.argv[3], decrypt=True) # decrypt=False is default
28+
# save as a new PDF
29+
doc.save(sys.argv[3], decrypt=True) # decrypt=False is default

0 commit comments

Comments
 (0)