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: July 6, 2020
12
+
Release date: July 31, 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.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".
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.4 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.
Copy file name to clipboardExpand all lines: docs/changes.rst
+12Lines changed: 12 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1,6 +1,18 @@
1
1
Change Logs
2
2
===============
3
3
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
+
4
16
Changes in Version 1.17.3
5
17
---------------------------
6
18
* **Fixed** an undocumented issue, which prevented fully cleaning a PDF page when using :meth:`Page.cleanContents`.
Copy file name to clipboardExpand all lines: docs/document.rst
+28-6Lines changed: 28 additions & 6 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -53,7 +53,8 @@ For details on **embedded files** refer to Appendix 3.
53
53
:meth:`Document.loadPage` read a page
54
54
:meth:`Document.makeBookmark` create a page pointer in reflowable documents
55
55
: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
57
58
:meth:`Document.newPage` PDF only: insert a new empty page
58
59
:meth:`Document.nextLocation` return (chapter, pno) of following page
59
60
:meth:`Document.pages` iterator over a page range
@@ -70,10 +71,10 @@ For details on **embedded files** refer to Appendix 3.
70
71
:meth:`Document.setToC` PDF only: set the table of contents (TOC)
71
72
:meth:`Document.updateObject` PDF only: replace object source
72
73
: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
74
75
: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`
77
78
:attr:`Document.chapterCount` number of chapters
78
79
:attr:`Document.FormFonts` PDF only: list of global widget fonts
79
80
:attr:`Document.isClosed` has document been closed?
@@ -719,7 +720,11 @@ For details on **embedded files** refer to Appendix 3.
719
720
720
721
:arg int to: the page number in front of which to copy. The default inserts **after** the last page.
721
722
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.
723
728
724
729
.. method:: movePage(pno, to=-1)
725
730
@@ -729,9 +734,26 @@ For details on **embedded files** refer to Appendix 3.
729
734
730
735
:arg int to: the page number in front of which to insert the moved page. The default moves **after** the last page.
731
736
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
+
732
754
.. method:: getSigFlags()
733
755
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.
Copy file name to clipboardExpand all lines: docs/faq.rst
+3-1Lines changed: 3 additions & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1046,7 +1046,9 @@ In v1.14.0, annotation handling has been considerably extended:
1046
1046
How to Add and Modify Annotations
1047
1047
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
1048
1048
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.
1050
1052
1051
1053
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:
Copy file name to clipboardExpand all lines: docs/font.rst
+20-4Lines changed: 20 additions & 4 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -19,6 +19,11 @@ A Font object also contains useful general information, like the font bbox, the
19
19
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.
20
20
21
21
: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
+
22
27
:arg str filename: the filename of a fontfile somewhere on your system [#f1]_.
23
28
:arg bytes,bytearray,io.BytesIO fontbuffer: a fontfile loaded in memory [#f1]_.
24
29
: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
48
53
look for fallback font
49
54
50
55
.. note::
51
-
56
+
52
57
With the usual abbreviations "helv", "tiro", etc., you will create fonts with the expected names "Helvetica", "Times-Roman" and so on.
53
58
54
59
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
57
62
58
63
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.
59
64
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).
61
66
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:
63
68
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.
@@ -87,6 +90,49 @@ Yet others are handy, general-purpose utilities.
87
90
fitz.Rect(0.0, 0.0, 792.0, 612.0)
88
91
>>>
89
92
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.
0 commit comments