Skip to content

Commit 12d0201

Browse files
committed
upload v1.17.4
1 parent e404343 commit 12d0201

21 files changed

+1297
-444
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.17.3
3+
Version: 1.17.4
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 6, 2020
12+
Release date: July 31, 2020
1313

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

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

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

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

5-
Release date: July 6, 2020
5+
Release date: July 31, 2020
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.17.3 of PyMuPDF**, a Python binding with support for [MuPDF 1.17.*](http://mupdf.com/) - "a lightweight PDF, XPS, and E-book viewer".
17+
This is **version 1.17.4 of PyMuPDF**, a Python binding with support for [MuPDF 1.17.*](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

docs/annot.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ There is a parent-child relationship between an annotation and its page. If the
6767

6868
:rtype: :ref:`Pixmap`
6969

70-
.. note:: If the annotation has just been created or modified
70+
.. note:: If the annotation has just been created or modified, you should reload the page first via *page = doc.reload_page(page)*.
7171

7272
.. method:: setInfo(info=None, content=None, title=None, creationDate=None, modDate=None, subject=None)
7373

docs/changes.rst

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,18 @@
11
Change Logs
22
===============
33

4+
Changes in Version 1.17.4
5+
---------------------------
6+
* **Fixed** issue `#561 <https://github.com/pymupdf/PyMuPDF/issues/561>`_. Handling of more than 10 :ref:`Font` objects on one page should now work correctly.
7+
* **Fixed** issue `#562 <https://github.com/pymupdf/PyMuPDF/issues/562>`_. Annotation pixmaps are no longer derived from the page pixmap, thus avoiding unintended inclusion of page content.
8+
* **Fixed** issue `#559 <https://github.com/pymupdf/PyMuPDF/issues/559>`_. This **MuPDF** bug is being temporarily fixed with a pre-version of MuPDF's next release.
9+
* **Added** utility function :meth:`repair_mono_font` for correcting displayed character spacing for some mono-spaced fonts.
10+
* **Added** utility method :meth:`Document.need_appearances` for fine-controlling Form PDF behavior. Addresses issue `#563 <https://github.com/pymupdf/PyMuPDF/issues/563>`_.
11+
* **Added** utility function :meth:`sRGB_to_pdf` to recover the PDF color triple for a given color integer in sRGB format.
12+
* **Added** utility function :meth:`sRGB_to_rgb` to recover the (R, G, B) color triple for a given color integer in sRGB format.
13+
* **Added** utility function :meth:`make_table` which delivers table cells for a given rectangle and desired numbers of columns and rows.
14+
* **Added** support for optional fonts in repository `pymupdf-fonts <https://github.com/pymupdf/pymupdf-fonts>`_.
15+
416
Changes in Version 1.17.3
517
---------------------------
618
* **Fixed** an undocumented issue, which prevented fully cleaning a PDF page when using :meth:`Page.cleanContents`.

docs/conf.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
# -- General configuration ------------------------------------------------
1313

1414
# If your documentation needs a minimal Sphinx version, state it here.
15-
# needs_sphinx = "2.0"
15+
# needs_sphinx = "3.1"
1616

1717
# Add any Sphinx extension module names here, as strings. They can be
1818
# extensions coming with Sphinx (named 'sphinx.ext.*') or your custom
@@ -46,7 +46,7 @@
4646
# built documents.
4747
#
4848
# The full version, including alpha/beta/rc tags.
49-
release = "1.17.3"
49+
release = "1.17.4"
5050

5151
# The short X.Y version
5252
version = release
@@ -207,7 +207,7 @@
207207
latex_show_pagerefs = False
208208

209209
# If true, show URL addresses after external links.
210-
latex_show_urls = True
210+
# latex_show_urls = True
211211
# latex_use_xindy = True
212212
# Documents to append as an appendix to all manuals.
213213
# latex_appendices = []

docs/document.rst

Lines changed: 28 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,8 @@ For details on **embedded files** refer to Appendix 3.
5353
:meth:`Document.loadPage` read a page
5454
:meth:`Document.makeBookmark` create a page pointer in reflowable documents
5555
:meth:`Document.metadataXML` PDF only: :data:`xref` of XML metadata
56-
:meth:`Document.movePage` PDF only: move a page to another location
56+
:meth:`Document.movePage` PDF only: move a page to different location in doc
57+
:meth:`Document.need_appearances` PDF only: get/set */NeedAppearances* property
5758
:meth:`Document.newPage` PDF only: insert a new empty page
5859
:meth:`Document.nextLocation` return (chapter, pno) of following page
5960
:meth:`Document.pages` iterator over a page range
@@ -70,10 +71,10 @@ For details on **embedded files** refer to Appendix 3.
7071
:meth:`Document.setToC` PDF only: set the table of contents (TOC)
7172
:meth:`Document.updateObject` PDF only: replace object source
7273
:meth:`Document.updateStream` PDF only: replace stream source
73-
:meth:`Document.write` PDF only: writes the document to memory
74+
:meth:`Document.write` PDF only: writes document to memory
7475
:meth:`Document.xrefObject` PDF only: object source at the :data:`xref`
75-
:meth:`Document.xrefStream` PDF only: stream source at the :data:`xref`
76-
:meth:`Document.xrefStreamRaw` PDF only: raw stream source at the :data:`xref`
76+
:meth:`Document.xrefStream` PDF only: decompressed stream source at :data:`xref`
77+
:meth:`Document.xrefStreamRaw` PDF only: raw stream source at :data:`xref`
7778
:attr:`Document.chapterCount` number of chapters
7879
:attr:`Document.FormFonts` PDF only: list of global widget fonts
7980
:attr:`Document.isClosed` has document been closed?
@@ -719,7 +720,11 @@ For details on **embedded files** refer to Appendix 3.
719720

720721
:arg int to: the page number in front of which to copy. The default inserts **after** the last page.
721722

722-
.. note:: In contrast to :meth:`copyPage`, this method creates a completely identical new page object -- with the exception of :attr:`Page.xref` of course, which will be different. So changes to a copy will only show there.
723+
.. note::
724+
725+
* In contrast to :meth:`copyPage`, this method creates a new page object (with a new :data:`xref`), which can be changed independently from the original.
726+
727+
* Any Popup and "IRT" ("in response to") annotations are **not copied** to avoid potentially incorrect situations.
723728

724729
.. method:: movePage(pno, to=-1)
725730

@@ -729,9 +734,26 @@ For details on **embedded files** refer to Appendix 3.
729734

730735
:arg int to: the page number in front of which to insert the moved page. The default moves **after** the last page.
731736

737+
738+
.. method:: need_appearances(value=None)
739+
740+
*(New in v1.17.4)*
741+
742+
PDF only: Get or set the */NeedAppearances* property of Form PDFs. Quote: *"(Optional) A flag specifying whether to construct appearance streams and appearance dictionaries for all widget annotations in the document ... Default value: false."* This may help controlling the behavior of some readers / viewers.
743+
744+
:arg bool value: set the property to this value. If omitted or *None*, inquire the current value.
745+
746+
:rtype: bool
747+
:returns:
748+
* None: not a Form PDF or property not defined.
749+
* True / False: the value of the property (either just set or existing for inquiries).
750+
751+
Once set, the property cannot be removed again (which is no problem).
752+
753+
732754
.. method:: getSigFlags()
733755

734-
PDF only: Return whether the document contains signature fields. This is an optional PDF property: if not present, no conclusions can be drawn, because the PDF creator may just not have bothered to use it.
756+
PDF only: Return whether the document contains signature fields. This is an optional PDF property: if not present (return value -1), no conclusions can be drawn -- the PDF creator may just not have bothered to use it.
735757

736758
:rtype: int
737759
:returns:

docs/faq.rst

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1046,7 +1046,9 @@ In v1.14.0, annotation handling has been considerably extended:
10461046
How to Add and Modify Annotations
10471047
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
10481048

1049-
In PyMuPDF, new annotations are added via :ref:`Page` methods. To keep code duplication effort small, we only offer a minimal set of options here. For example, to add a 'Circle' annotation, only the containing rectangle can be specified. The result is a circle (or ellipsis) with white interior, black border and a line width of 1, exactly fitting into the rectangle. To adjust the annot's appearance, :ref:`Annot` methods must then be used. After having made all required changes, the annot's :meth:`Annot.update` methods must be invoked to finalize all your changes.
1049+
In PyMuPDF, new annotations can be added added via :ref:`Page` methods. Once an annotation exists, it can be modified to a large extent using methods of the :ref:`Annot` class.
1050+
1051+
In contrast to many other tools, initial insert of annotations happens with a minimum number of properties. We leave it to the programmer to e.g. set attributes like author, creation date or subject.
10501052

10511053
As an overview for these capabilities, look at the following script that fills a PDF page with most of the available annotations. Look in the next sections for more special situations:
10521054

docs/font.rst

Lines changed: 20 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,11 @@ A Font object also contains useful general information, like the font bbox, the
1919
Font constructor. The large number of parameters are used to locate font, which most closely resembles the requirements. Not all parameters are ever required -- see the below pseudo code explaining the logic how the parameters are evaluated.
2020

2121
:arg str fontname: one of the :ref:`Base-14-Fonts` or CJK fontnames. Also possible are a select few of other names like (watch the correct spelling): "Arial", "Times", "Times Roman".
22+
23+
*(Changed in v1.17.4)*
24+
25+
If you have installed `pymupdf-fonts <https://pypi.org/project/pymupdf-fonts/>`_, you can also use the following new "reserved" fontnames: "figo", "figbo", "figit", "figbi", "fimo", and "fimbo". This will provide one of the "FiraGo" or resp. "FiraMono" fonts, created by Mozilla.org.
26+
2227
:arg str filename: the filename of a fontfile somewhere on your system [#f1]_.
2328
:arg bytes,bytearray,io.BytesIO fontbuffer: a fontfile loaded in memory [#f1]_.
2429
:arg in script: the number of a UCDN script. Currently supported in PyMuPDF are numbers 24, and 32 through 35.
@@ -48,7 +53,7 @@ A Font object also contains useful general information, like the font bbox, the
4853
look for fallback font
4954

5055
.. note::
51-
56+
5257
With the usual abbreviations "helv", "tiro", etc., you will create fonts with the expected names "Helvetica", "Times-Roman" and so on.
5358

5459
Using *ordering >= 0*, or fontnames starting with "china", "japan" or "korea" will always create the same **"universal"** font **"Droid Sans Fallback Regular"**. This font supports **all CJK and all Latin characters**.
@@ -57,11 +62,22 @@ A Font object also contains useful general information, like the font bbox, the
5762

5863
If you **know** you have a mixture of CJK and Latin text, consider just using ``Font(ordering=0)`` because this supports everything and also significantly (by a factor of two to three) speeds up execution: MuPDF will always find any character in this single font and need not check fallbacks.
5964

60-
But if you do specify a Base-14 fontname, you will still be able to also write CJK characters! MuPDF automatically detects this situation and silently falls back to the universal font (which will then of course also be included in your PDF).
65+
But if you do specify a Base-14 fontname, you will still be able to also write CJK characters! MuPDF automatically detects this situation and silently falls back to the universal font (which will then of course also be embedded in your PDF).
6166

62-
**All fonts mentioned here** also support Greek and Cyrillic letters.
67+
*(New in v1.17.4)* Optionally, a set of new "reserved" fontnames becomes available if you install `pymupdf-fonts <https://pypi.org/project/pymupdf-fonts/>`_. The currently available fonts are from the Fira fonts family created by Mozilla. "Fira Mono" is a nice mono-spaced sans font set and FiraGO is another non-serifed "universal" font, set which supports all European languages (including Cyrillic and Greek) plus Thai, Arabian, Hewbrew and Devanagari -- however none of the CJK languages. The size of a FiraGO font is only a quarter of the "Droid Sans Fallback" size (compressed 400 KB vs. 1.65 MB) -- and the style variants bold and italic are available..The following table maps a fontname to the corresponding font:
6368

64-
*Monospaced* fonts are an issue: They are written with a too large width, e.g. ``" a"`` instead of ``"a"``. This applies to "cour" variants as well as most other mono fonts. The only exception we know of so far is ``consola.ttf``. If you want to output monospaced text, we recommend using the Consolas font for the time being.
69+
=========== =======================================
70+
Fontname Font
71+
=========== =======================================
72+
figo FiraGO Regular
73+
figbo FiraGO Bold
74+
figit FiraGO Italic
75+
figbi FiraGO Bold Italic
76+
fimo Fira Mono Regular
77+
fimbo Fira Mono Bold
78+
=========== =======================================
79+
80+
**All fonts mentioned here** also support Greek and Cyrillic letters.
6581

6682
.. method:: has_glyph(chr, language=None, script=0)
6783

docs/functions.rst

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,9 @@ Yet others are handy, general-purpose utilities.
5555
:meth:`planishLine` matrix to map a line to the x-axis
5656
:meth:`PaperSize` return width, height for a known paper format
5757
:meth:`PaperRect` return rectangle for a known paper format
58+
:meth:`sRGB_to_pdf` return PDF RGB color tuple from a sRGB integer
59+
:meth:`sRGB_to_rgb` return (R, G, B) color tuple from a sRGB integer
60+
:meth:`make_table` return list of table cells for a given rectangle
5861
:attr:`paperSizes` dictionary of pre-defined paper formats
5962
==================================== ==============================================================
6063

@@ -87,6 +90,49 @@ Yet others are handy, general-purpose utilities.
8790
fitz.Rect(0.0, 0.0, 792.0, 612.0)
8891
>>>
8992

93+
-----
94+
95+
.. method:: sRGB_to_pdf(srgb)
96+
97+
*New in v1.17.4*
98+
99+
Convenience function returning a PDF color triple (red, green, blue) for a given sRGB color integer as it occurs in :meth:`Page.getText` dictionaries "dict" and "rawdict".
100+
101+
:arg int srgb: an integer of format RRGGBB, where each color component is an integer in range(255).
102+
103+
:returns: a tuple (red, green, blue) with float items in intervall *0 <= item <= 1* representing the same color.
104+
105+
-----
106+
107+
.. method:: sRGB_to_rgb(srgb)
108+
109+
*New in v1.17.4*
110+
111+
Convenience function returning a color (red, green, blue) for a given sRGB color integer .
112+
113+
:arg int srgb: an integer of format RRGGBB, where each color component is an integer in range(255).
114+
115+
:returns: a tuple (red, green, blue) with integer items in intervall *0 <= item <= 255* representing the same color.
116+
117+
-----
118+
119+
.. method:: make_table(rect=(0, 0, 1, 1), cols=1, rows=1)
120+
121+
*New in v1.17.4*
122+
123+
Convenience function returning a list of <rows x cols> :ref:`Rect` objects representing equal sized table cells for the given rectangle.
124+
125+
:arg rect_like rect: the rectangle to contain the table.
126+
:arg int cols: the desired number of columns.
127+
:arg int rows: the desired number of rows.
128+
:returns: a list of :ref:`Rect` objects of equal size, whose union equals *rect*::
129+
130+
[
131+
[cell00, cell01, ...] # row 0
132+
...
133+
[...] # last row
134+
]
135+
90136
-----
91137

92138
.. method:: planishLine(p1, p2)

docs/images/img-annots.jpg

0 Bytes
Loading

0 commit comments

Comments
 (0)