Skip to content

Commit 36f56f9

Browse files
committed
Changes for v1.9.2
1 parent 52964c5 commit 36f56f9

24 files changed

+1070
-207
lines changed

doc/PyMuPDF.pdf

127 KB
Binary file not shown.

doc/html/.doctrees/changes.doctree

3.45 KB
Binary file not shown.

doc/html/.doctrees/document.doctree

16.8 KB
Binary file not shown.

doc/html/.doctrees/environment.pickle

1000 Bytes
Binary file not shown.

doc/html/.doctrees/tutorial.doctree

4.15 KB
Binary file not shown.

doc/html/_sources/changes.txt

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,22 @@
22

33
PageBreak
44

5-
=========================
6-
Changes in Version 1.9.1
7-
=========================
85
This version of PyMuPDF is based on MuPDF library source code version 1.9a published on April 21, 2016.
96

107
Please have a look at MuPDF's website to see which changes and enhancements are contained herein.
118

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:
1321

1422
* New methods ``getRectArea()`` for both ``fitz.Rect`` and ``fitz.IRect``
1523
* 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:
3240
* ``Matrix``, ``IRect``, ``Rect`` and ``Point`` classes now support compact, algebraic formulations for manipulating such objects.
3341
* Incremental saves for changes are possible now using the call pattern ``doc.save(doc.name, incremental=True)``.
3442
* 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.

doc/html/_sources/document.txt

Lines changed: 33 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ Since version 1.9.0 there exists an alias ``open`` for this class.
2626
:meth:`Document.select` PDF only: select a subset of pages
2727
:meth:`Document.setMetadata` PDF only: set the metadata
2828
:meth:`Document.setToC` PDF only: replace the table of contents (TOC)
29+
:meth:`Document.insertPDF` insert a PDF's page range
2930
:attr:`Document.isClosed` has document been closed?
3031
:attr:`Document.outline` first `Outline` item
3132
:attr:`Document.name` filename of document
@@ -53,13 +54,13 @@ Since version 1.9.0 there exists an alias ``open`` for this class.
5354

5455
.. method:: __init__(self, filetype, stream)
5556

56-
Constructs a ``Document`` object from bytearray ``stream``.
57+
Constructs a ``Document`` object from memory ``stream``.
5758

5859
: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.
5960
:type `filetype`: string
6061

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
6364

6465
:rtype: ``Document``
6566
:returns: A ``Document`` object.
@@ -220,6 +221,35 @@ Since version 1.9.0 there exists an alias ``open`` for this class.
220221
:rtype: int
221222
:returns: Zero upon successful execution.
222223

224+
.. method:: insertPDF(doc2, from_page = -1, to_page = -1, start_at = -1, rotate = -1, links = True)
225+
226+
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+
223253
.. method:: close()
224254

225255
Releases space allocations associated with the document. If created from a file, also closes ``filename`` (releasing control to the OS).

doc/html/_sources/tutorial.txt

Lines changed: 17 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ Some :ref:`Document` Methods and Attributes
5252

5353
Access Meta Data
5454
========================
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.
5656

5757
============== ==============================
5858
**Key** **Value**
@@ -166,7 +166,7 @@ Please also do have a look at the demo program ``demo.py``. Among others it cont
166166

167167
Output
168168
=======
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.
170170

171171
Re-arrange and Delete Pages
172172
----------------------------------
@@ -178,14 +178,27 @@ To make any such changes permanent, execute :meth:`Document.save()` (see below)
178178

179179
The saved document will contain all links, annotations and bookmarks referenced by its pages.
180180

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
189+
doc1.insertPDF(doc2, from_page = 21, to_page = 25, start_at = 15)
190+
191+
# same example, but source pages are inserted rotated and in reversed order
192+
doc1.insertPDF(doc2, from_page = 25, to_page = 21, start_at = 15, rotate = 90)
193+
181194
Save
182195
-------
183196

184197
If the document had been successfully decrypted before, ``save()`` will automatically save a decrypted copy.
185198

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.
187200

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.
189202

190203
As part of ``save()``, some clean-up will always take place:
191204

doc/html/changes.html

Lines changed: 20 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
<head>
77
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
88

9-
<title>Changes in Version 1.9.1 &mdash; PyMuPDF 1.9.1 documentation</title>
9+
<title>Changes in Version 1.9.2 &mdash; PyMuPDF 1.9.1 documentation</title>
1010

1111
<link rel="stylesheet" href="_static/sphinxdoc.css" type="text/css" />
1212
<link rel="stylesheet" href="_static/pygments.css" type="text/css" />
@@ -45,6 +45,12 @@ <h3>Navigation</h3>
4545
</div>
4646
<div class="sphinxsidebar" role="navigation" aria-label="main navigation">
4747
<div class="sphinxsidebarwrapper">
48+
<h3><a href="index.html">Table Of Contents</a></h3>
49+
<ul>
50+
<li><a class="reference internal" href="#">Changes in Version 1.9.2</a></li>
51+
<li><a class="reference internal" href="#changes-in-version-1-9-1">Changes in Version 1.9.1</a></li>
52+
</ul>
53+
4854
<h4>Previous topic</h4>
4955
<p class="topless"><a href="intro.html"
5056
title="previous chapter">Introduction</a></p>
@@ -76,11 +82,19 @@ <h3>Quick search</h3>
7682
<div class="bodywrapper">
7783
<div class="body" role="main">
7884

79-
<div class="section" id="changes-in-version-1-9-1">
80-
<h1>Changes in Version 1.9.1<a class="headerlink" href="#changes-in-version-1-9-1" title="Permalink to this headline"></a></h1>
81-
<p>This version of PyMuPDF is based on MuPDF library source code version 1.9a published on April 21, 2016.</p>
85+
<p>This version of PyMuPDF is based on MuPDF library source code version 1.9a published on April 21, 2016.</p>
8286
<p>Please have a look at MuPDF&#8217;s website to see which changes and enhancements are contained herein.</p>
83-
<p>Changes in these bindings compared to version 1.8.0 are the following:</p>
87+
<div class="section" id="changes-in-version-1-9-2">
88+
<h1>Changes in Version 1.9.2<a class="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+
<ul class="simple">
91+
<li><code class="docutils literal"><span class="pre">fitz.open()</span></code> now accepts all of the formats <code class="docutils literal"><span class="pre">open(filename)</span></code>, <code class="docutils literal"><span class="pre">open(filename,</span> <span class="pre">None)</span></code>, <code class="docutils literal"><span class="pre">open(filetype,</span> <span class="pre">stream)</span></code>. Type of memory area <code class="docutils literal"><span class="pre">stream</span></code> may be <code class="docutils literal"><span class="pre">str</span></code> (Python 2), <code class="docutils literal"><span class="pre">bytes</span></code> (Python 3) or <code class="docutils literal"><span class="pre">bytearray</span></code> (Python 2 and 3).</li>
92+
<li>New method <code class="docutils literal"><span class="pre">Document.insertPDF()</span></code> (PDFs only) inserts a range of pages of another PDF.</li>
93+
</ul>
94+
</div>
95+
<div class="section" id="changes-in-version-1-9-1">
96+
<h1>Changes in Version 1.9.1<a class="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>
8498
<ul class="simple">
8599
<li>New methods <code class="docutils literal"><span class="pre">getRectArea()</span></code> for both <code class="docutils literal"><span class="pre">fitz.Rect</span></code> and <code class="docutils literal"><span class="pre">fitz.IRect</span></code></li>
86100
<li>Pixmaps can now be created directly from files using the new constructor <code class="docutils literal"><span class="pre">fitz.Pixmap(filename)</span></code>.</li>
@@ -130,7 +144,7 @@ <h3>Navigation</h3>
130144
</div>
131145
<div class="footer" role="contentinfo">
132146
&copy; Copyright 2016, Jorj X. McKie.
133-
Last updated on 22. Jul 2016.
147+
Last updated on 03. Aug 2016.
134148
Created using <a href="http://sphinx-doc.org/">Sphinx</a> 1.4.1.
135149
</div>
136150
</body>

doc/html/classes.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -124,7 +124,7 @@ <h3>Navigation</h3>
124124
</div>
125125
<div class="footer" role="contentinfo">
126126
&copy; Copyright 2016, Jorj X. McKie.
127-
Last updated on 22. Jul 2016.
127+
Last updated on 03. Aug 2016.
128128
Created using <a href="http://sphinx-doc.org/">Sphinx</a> 1.4.1.
129129
</div>
130130
</body>

0 commit comments

Comments
 (0)