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
Copy file name to clipboardExpand all lines: doc/html/_sources/changes.txt
+13-5Lines changed: 13 additions & 5 deletions
Original file line number
Diff line number
Diff line change
@@ -2,14 +2,22 @@
2
2
3
3
PageBreak
4
4
5
-
=========================
6
-
Changes in Version 1.9.1
7
-
=========================
8
5
This version of PyMuPDF is based on MuPDF library source code version 1.9a published on April 21, 2016.
9
6
10
7
Please have a look at MuPDF's website to see which changes and enhancements are contained herein.
11
8
12
-
Changes in these bindings compared to version 1.8.0 are the following:
9
+
Changes in Version 1.9.2
10
+
=========================
11
+
Changes compared to version 1.9.1:
12
+
13
+
* ``fitz.open()`` now accepts all of the formats ``open(filename)``, ``open(filename, None)``, ``open(filetype, stream)``. Type of memory area ``stream`` may be ``str`` (Python 2), ``bytes`` (Python 3) or ``bytearray`` (Python 2 and 3).
14
+
15
+
* New method ``Document.insertPDF()`` (PDFs only) inserts a range of pages of another PDF.
16
+
17
+
18
+
Changes in Version 1.9.1
19
+
=========================
20
+
Changes compared to version 1.8.0:
13
21
14
22
* New methods ``getRectArea()`` for both ``fitz.Rect`` and ``fitz.IRect``
15
23
* Pixmaps can now be created directly from files using the new constructor ``fitz.Pixmap(filename)``.
@@ -32,4 +40,4 @@ Changes in these bindings compared to version 1.8.0 are the following:
32
40
* ``Matrix``, ``IRect``, ``Rect`` and ``Point`` classes now support compact, algebraic formulations for manipulating such objects.
33
41
* Incremental saves for changes are possible now using the call pattern ``doc.save(doc.name, incremental=True)``.
34
42
* A PDF's metadata can now be deleted, set or changed by document method ``setMetadata()``. Supports incremental saves.
35
-
* A PDF's bookmarks (or table of contents) can now be deleted, set or changed with the entries of a list using document method ``setToC(list)``. Supports incremental saves.
43
+
* A PDF's bookmarks (or table of contents) can now be deleted, set or changed with the entries of a list using document method ``setToC(list)``. Supports incremental saves.
Copy file name to clipboardExpand all lines: doc/html/_sources/document.txt
+33-3Lines changed: 33 additions & 3 deletions
Original file line number
Diff line number
Diff line change
@@ -26,6 +26,7 @@ Since version 1.9.0 there exists an alias ``open`` for this class.
26
26
:meth:`Document.select` PDF only: select a subset of pages
27
27
:meth:`Document.setMetadata` PDF only: set the metadata
28
28
:meth:`Document.setToC` PDF only: replace the table of contents (TOC)
29
+
:meth:`Document.insertPDF` insert a PDF's page range
29
30
:attr:`Document.isClosed` has document been closed?
30
31
:attr:`Document.outline` first `Outline` item
31
32
:attr:`Document.name` filename of document
@@ -53,13 +54,13 @@ Since version 1.9.0 there exists an alias ``open`` for this class.
53
54
54
55
.. method:: __init__(self, filetype, stream)
55
56
56
-
Constructs a ``Document`` object from bytearray ``stream``.
57
+
Constructs a ``Document`` object from memory ``stream``.
57
58
58
59
:param `filetype`: A string specifying the type of document contained in ``stream``. This may be either something that looks like a filename (e.g. ``x.pdf``), in which case MuPDF uses the extension to determine the type, or a mime type like ``application/pdf``. Recommended is using the filename scheme, or even the name of the original file for documentation purposes.
59
60
:type `filetype`: string
60
61
61
-
:param `stream`: A bytearray representing the content of a supported document type.
62
-
:type `stream`: bytearray
62
+
:param `stream`: A memory area representing the content of a supported document type.
63
+
:type `stream`: bytearray, bytes or (Python 2 only) str
63
64
64
65
:rtype: ``Document``
65
66
:returns: A ``Document`` object.
@@ -220,6 +221,35 @@ Since version 1.9.0 there exists an alias ``open`` for this class.
PDF documents only: Copies the page range [from_page, to_page] (including both) of the PDF document object ``doc2`` into the current PDF. ``from_page`` will start with page number ``start_at``. All pages thus copied will be rotated as specified. Links can be excluded in the target. See details at explanations below.
227
+
228
+
:param `doc2`: An opened PDF document.
229
+
:type `doc2`: ``Document``
230
+
231
+
:param `from_page`: Zero-based page number in ``doc2`` to start with. Default is zero.
232
+
:type `from_page`: int
233
+
234
+
:param `to_page`: The last page number in ``doc2`` to copy. Default is the last page.
235
+
:type `to_page`: int
236
+
237
+
:param `start_at`: Page number ``from_page`` will become page ``start_at`` in the destination. If omitted, the page range will be appended. If zero, the page range will be inserted before current first page.
238
+
:type `start_at`: int
239
+
240
+
:param `rotate`: All copied pages will be rotated by the provided value (degrees). If you do not specify a value, the original will not be changed. This must be a (positive or negative) integer multiple of 90. The validity of this parameter will not be checked - it is your responsibility to provide meaningful values.
241
+
:type `rotate`: int
242
+
243
+
:param `links`: Choose whether links should be included with the copy. Default is ``True``.
244
+
:type `links`: bool
245
+
246
+
:rtype: int
247
+
:returns: Zero upon successful execution.
248
+
249
+
.. note:: Page range values may be specified **reversed**, i.e. ``from_page > to_page`` is valid. In this case pages will be copied back to front, starting with ``to_page``.
250
+
251
+
.. note:: The functionality of this method is a conversion of MuPDF's CLI utility ``mutool merge``. Due to current restrictions of this tool, ``doc2`` annotations will **not** be copied. However, relevant **links will be copied** (actually reconstructed), if ``links = True`` (default) and if they do not point to source pages outside the copied range. Bookmarks (table of contents) are copied if and only if the complete ``doc2`` is appended to the complete current document, like e.g. ``doc1.insertPDF(doc2)``. But look at the example program ``PDF_joiner.py``, which can join PDF documents and at the same time piece together respective parts of the tables of contents.
252
+
223
253
.. method:: close()
224
254
225
255
Releases space allocations associated with the document. If created from a file, also closes ``filename`` (releasing control to the OS).
Copy file name to clipboardExpand all lines: doc/html/_sources/tutorial.txt
+17-4Lines changed: 17 additions & 4 deletions
Original file line number
Diff line number
Diff line change
@@ -52,7 +52,7 @@ Some :ref:`Document` Methods and Attributes
52
52
53
53
Access Meta Data
54
54
========================
55
-
:attr:`Document.metadata` is a Python dictionary with the following keys. For details of their meanings and formats consult the PDF manuals, e.g. `Adobe PDF Reference sixth edition 1.7 November 2006 <http://www.adobe.com/content/dam/Adobe/en/devnet/acrobat/pdfs/pdf_reference_1-7.pdf>`_. Further information can also be found in chapter :ref:`Document`. The meta data fields are of type string if not otherwise indicated. Be aware that not all of them may be present or do contain meaningfull data.
55
+
:attr:`Document.metadata` is a Python dictionary with the following keys. For details of their meanings and formats consult the PDF manuals, e.g. `Adobe PDF Reference sixth edition 1.7 November 2006 <http://www.adobe.com/content/dam/Adobe/en/devnet/acrobat/pdfs/pdf_reference_1-7.pdf>`_. Further information can also be found in chapter :ref:`Document`. The meta data fields are of type string if not otherwise indicated. Be aware that not all of them may be present or do contain meaningful data.
56
56
57
57
============== ==============================
58
58
**Key** **Value**
@@ -166,7 +166,7 @@ Please also do have a look at the demo program ``demo.py``. Among others it cont
166
166
167
167
Output
168
168
=======
169
-
Output capabilities of MuPDF (such as PDF generation) have improved in version 1.9. Output is supported for PDF documents only.
169
+
Output capabilities of MuPDF (such as PDF generation) have improved in version 1.9. Output is supported for **PDF documents only**. Obviously, results of any of the following methods will become permanent only, if the PDF is saved. Just closing it is equivalent to cancelling such changes.
170
170
171
171
Re-arrange and Delete Pages
172
172
----------------------------------
@@ -178,14 +178,27 @@ To make any such changes permanent, execute :meth:`Document.save()` (see below)
178
178
179
179
The saved document will contain all links, annotations and bookmarks referenced by its pages.
180
180
181
+
Join PDF Documents
182
+
-----------------------
183
+
Method :meth:`Document.insertPDF()` inserts (part of) another PDF document at a specified place of the current one. Here are some examples:
184
+
::
185
+
# append complete doc2 at the end of doc1
186
+
doc1.insertPDF(doc2) # also appends doc2's table of content
187
+
188
+
# insert 5 pages of doc2, where source page 21 becomes page 15 in doc1
If the document had been successfully decrypted before, ``save()`` will automatically save a decrypted copy.
185
198
186
-
If you altered the document via :meth:`Document.select()`, :meth:`Document.setToC()` or :meth:`Document.setMetadata()`, then the resulting document will be saved.
199
+
If you altered the document via :meth:`Document.select()`, :meth:`Document.setToC()`, :meth:`Document.insertPDF()` or :meth:`Document.setMetadata()`, then the resulting document will be saved.
187
200
188
-
Since MuPDF 1.9, you can also write changes back to the original file by specifying ``incremental = True``. This process is **extremely fast**, since any changes are **appended to the original file** - it will not be rewritten as a whole.
201
+
Since MuPDF 1.9, you can also write changes **back to the original file** by specifying ``incremental = True``. This process is **extremely fast**, since any changes are **appended to the original file** - it will not be rewritten as a whole.
189
202
190
203
As part of ``save()``, some clean-up will always take place:
<h1>Changes in Version 1.9.2<aclass="headerlink" href="#changes-in-version-1-9-2" title="Permalink to this headline">¶</a></h1>
89
+
<p>Changes compared to version 1.9.1:</p>
90
+
<ulclass="simple">
91
+
<li><codeclass="docutils literal"><spanclass="pre">fitz.open()</span></code> now accepts all of the formats <codeclass="docutils literal"><spanclass="pre">open(filename)</span></code>, <codeclass="docutils literal"><spanclass="pre">open(filename,</span><spanclass="pre">None)</span></code>, <codeclass="docutils literal"><spanclass="pre">open(filetype,</span><spanclass="pre">stream)</span></code>. Type of memory area <codeclass="docutils literal"><spanclass="pre">stream</span></code> may be <codeclass="docutils literal"><spanclass="pre">str</span></code> (Python 2), <codeclass="docutils literal"><spanclass="pre">bytes</span></code> (Python 3) or <codeclass="docutils literal"><spanclass="pre">bytearray</span></code> (Python 2 and 3).</li>
92
+
<li>New method <codeclass="docutils literal"><spanclass="pre">Document.insertPDF()</span></code> (PDFs only) inserts a range of pages of another PDF.</li>
<h1>Changes in Version 1.9.1<aclass="headerlink" href="#changes-in-version-1-9-1" title="Permalink to this headline">¶</a></h1>
97
+
<p>Changes compared to version 1.8.0:</p>
84
98
<ulclass="simple">
85
99
<li>New methods <codeclass="docutils literal"><spanclass="pre">getRectArea()</span></code> for both <codeclass="docutils literal"><spanclass="pre">fitz.Rect</span></code> and <codeclass="docutils literal"><spanclass="pre">fitz.IRect</span></code></li>
86
100
<li>Pixmaps can now be created directly from files using the new constructor <codeclass="docutils literal"><spanclass="pre">fitz.Pixmap(filename)</span></code>.</li>
0 commit comments