You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Summary: PyMuPDF is a Python binding for the PDF rendering library MuPDF
11
11
Description:
12
-
Release date: August 6, 2020
12
+
Release date: August 26, 2020
13
13
14
14
Authors
15
15
=======
@@ -20,7 +20,7 @@ Description:
20
20
Introduction
21
21
============
22
22
23
-
This is **version 1.17.5 of PyMuPDF**, a Python binding for `MuPDF <http://mupdf.com/>`_ - "a lightweight PDF and XPS viewer".
23
+
This is **version 1.17.6 of PyMuPDF**, a Python binding for `MuPDF <http://mupdf.com/>`_ - "a lightweight PDF and XPS viewer".
24
24
25
25
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.
@@ -14,7 +14,7 @@ On **[PyPI](https://pypi.org/project/PyMuPDF)** since August 2016: [ - "a lightweight PDF, XPS, and E-book viewer".
17
+
This is **version 1.17.6 of PyMuPDF**, a Python binding with support for [MuPDF 1.17.*](http://mupdf.com/) - "a lightweight PDF, XPS, and E-book viewer".
18
18
19
19
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.
* **Fixed** issue `#600 <https://github.com/pymupdf/PyMuPDF/issues/600>`_ -- text should now be correctly positioned also for pages with a CropBox smaller than MediaBox.
8
+
* **Added** text span dictionary key ``origin`` which contains the lower left coordinate of the first character in that span.
9
+
* **Added** attribute :attr:`Font.buffer`, a *bytes* copy of the font file.
10
+
* **Added** parameter *sanitize* to :meth:`Page.cleanContents`. Allows switching of sanitization, so only syntax cleaning will be done.
11
+
4
12
Changes in Version 1.17.5
5
13
---------------------------
6
14
* **Fixed** issue `#561 <https://github.com/pymupdf/PyMuPDF/issues/561>`_ -- second go: certain :ref:`TextWriter` usages with many alternating fonts did not work correctly.
Copy file name to clipboardExpand all lines: docs/font.rst
+18-10Lines changed: 18 additions & 10 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -69,13 +69,13 @@ A Font object also contains useful general information, like the font bbox, the
69
69
70
70
*(New in v1.17.5)* Optionally, some new "reserved" fontnames become available if you install `pymupdf-fonts <https://pypi.org/project/pymupdf-fonts/>`_. **"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** it provides the style variants bold, italic, bold-italic.
71
71
72
-
**"Space Mono"** is another nice and small fixed-width font from Google Fonts, which supports Latin Extended characters.
72
+
**"Space Mono"** is another nice and small fixed-width font from Google Fonts, which supports Latin Extended characters and comes with all 4 important font weights.
73
73
74
74
The following table maps a fontname to the corresponding font:
@@ -105,7 +105,9 @@ A Font object also contains useful general information, like the font bbox, the
105
105
106
106
.. method:: valid_codepoints()
107
107
108
-
*(New in v1.17.5)* Return an array of unicodes which are supported by this font.
108
+
*(New in v1.17.5)*
109
+
110
+
Return an array of unicodes supported by this font.
109
111
110
112
:returns: an *array.array* [#f2]_ of length :attr:`Font.glyph_count` (or less). I.e. *chr()* of every item in this array will be found in the font without using fallbacks. This is an example display of the supported glyphs:
111
113
@@ -176,6 +178,12 @@ A Font object also contains useful general information, like the font bbox, the
176
178
177
179
:returns: a float representing the length of the string when stored in the PDF. Internally :meth:`glyph_advance` is used on a by-character level. If the font does not have a character, it will automatically be looked up in a fallback font.
178
180
181
+
.. attribute:: buffer
182
+
183
+
*(New in v1.17.6)*
184
+
185
+
A *bytes* copy of the binary font file.
186
+
179
187
.. attribute:: flags
180
188
181
189
A dictionary with various font properties, each represented as bools.
Copy file name to clipboardExpand all lines: docs/functions.rst
+8-4Lines changed: 8 additions & 4 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -451,13 +451,17 @@ Yet others are handy, general-purpose utilities.
451
451
452
452
-----
453
453
454
-
.. method:: Page.cleanContents()
454
+
.. method:: Page.cleanContents(sanitize=True)
455
455
456
-
Clean and concatenate all :data:`contents` objects associated with this page. "Cleaning" includes syntactical corrections, standardizations and "pretty printing" of the contents stream. Discrepancies between :data:`contents` and :data:`resources` objects will also be corrected. See :meth:`Page._getContents` for more details.
456
+
*(Changed in v1.17.6)*
457
+
458
+
PDF only: Clean and concatenate all :data:`contents` objects associated with this page. "Cleaning" includes syntactical corrections, standardizations and "pretty printing" of the contents stream. Discrepancies between :data:`contents` and :data:`resources` objects will also be corrected if sanitize is true. See :meth:`Page.getContents` for more details.
457
459
458
460
Changed in version 1.16.0 Annotations are no longer implicitely cleaned by this method. Use :meth:`Annot._cleanContents` separately.
459
461
460
-
.. warning:: This is a complex function which may generate large amounts of new data and render other data unused. It is **not recommended** using it together with the **incremental save** option. Also note that the resulting singleton new */Contents* object is **uncompressed**. So you should save to a **new file** using options *"deflate=True, garbage=3"*.
462
+
:arg bool sanitize: *(new in v1.17.6)* if true, synchronization between resources and their actual use in the contents object is snychronized. For example, if a font is not actually used for any text of the page, then it will be deleted from the ``/Resources/Font`` object.
463
+
464
+
.. warning:: This is a complex function which may generate large amounts of new data and render old data unused. It is **not recommended** using it together with the **incremental save** option. Also note that the resulting singleton new */Contents* object is **uncompressed**. So you should save to a **new file** using options *"deflate=True, garbage=3"*.
461
465
462
466
-----
463
467
@@ -471,7 +475,7 @@ Yet others are handy, general-purpose utilities.
471
475
472
476
.. method:: Annot._cleanContents()
473
477
474
-
Clean the :data:`contents` streams associated with the annotation. This is the same type of action which :meth:`Page._cleanContents` performs -- just restricted to this annotation.
478
+
Clean the :data:`contents` streams associated with the annotation. This is the same type of action which :meth:`Page.cleanContents` performs -- just restricted to this annotation.
.. [#f1] If you need a **vector image** from the SVG, you must first convert it to a PDF. Try :meth:`Document.convertToPDF`. If this is not not good enough, look for other SVG-to-PDF conversion tools like the Python packages `svglib <https://pypi.org/project/svglib>`_, `CairoSVG <https://pypi.org/project/cairosvg>`_, `Uniconvertor <https://sk1project.net/modules.php?name=Products&product=uniconvertor&op=download>`_ or the Java solution `Apache Batik <https://github.com/apache/batik>`_. Have a look at our Wiki for more examples.
453
+
.. [#f1] If you need a **vector image** from the SVG, you must first convert it to a PDF. Try :meth:`Document.convertToPDF`. If this is not good enough, look for other SVG-to-PDF conversion tools like the Python packages `svglib <https://pypi.org/project/svglib>`_, `CairoSVG <https://pypi.org/project/cairosvg>`_, `Uniconvertor <https://sk1project.net/modules.php?name=Products&product=uniconvertor&op=download>`_ or the Java solution `Apache Batik <https://github.com/apache/batik>`_. Have a look at our Wiki for more examples.
454
454
455
455
.. [#f2] To also set the alpha property, add an additional step to this method by dropping or adding an alpha channel to the result.
bbox span rectangle, formatted as *tuple(fitz.Rect)*
213
+
origin *tuple* coordinates of the first character's bottom left point
212
214
font font name *(str)*
213
215
size font size *(float)*
214
216
flags font characteristics *(int)*
@@ -219,7 +221,7 @@ chars (only for :meth:`extractRAWDICT`) *list* of character dictionari
219
221
220
222
*(New in version 1.16.0)*
221
223
222
-
*"color"* is the text color encoded in sRGB format, e.g. 0xFF0000 for red.
224
+
*"color"* is the text color encoded in sRGB (int) format, e.g. 0xFF0000 for red. There are functions for converting this integer back to formats (r, g, b) (PDF with float values from 0 to 1) :meth:`sRGB_to_pdf`, or (R, G, B), :meth:`sRGB_to_rgb` (with integer values from 0 to 255).
223
225
224
226
*"flags"* is an integer, encoding bools of font properties:
This documentation covers PyMuPDF v1.17.5 features as of **2020-08-06 06:31:06**.
4
+
This documentation covers PyMuPDF v1.17.6 features as of **2020-08-26 14:54:32**.
5
5
6
6
.. note:: The major and minor versions of **PyMuPDF** and **MuPDF** will always be the same. Only the third qualifier (patch level) may deviate from that of MuPDF.
0 commit comments