Skip to content

Commit b0babae

Browse files
authored
Merge pull request #832 from user202729/patch-2
Several small changes
2 parents 407805a + 50caae0 commit b0babae

File tree

7 files changed

+25
-24
lines changed

7 files changed

+25
-24
lines changed

docs/document.rst

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -219,7 +219,7 @@ For details on **embedded files** refer to Appendix 3.
219219

220220
>>> for item in doc.layer_configs: print(item)
221221
{'number': 0, 'name': 'my-config', 'creator': ''}
222-
>>> # use 'number' as config identifyer in add_ocg
222+
>>> # use 'number' as config identifier in add_ocg
223223

224224
.. method:: add_layer_config(name, creator=None, on=None)
225225

@@ -1307,27 +1307,27 @@ For details on **embedded files** refer to Appendix 3.
13071307

13081308
*(New in version 1.16.8)*
13091309

1310-
PDF only: Return the definition of a PDF object. For details please refer to :meth:`Document.xrefObject`.
1310+
PDF only: Return the definition of a PDF object.
13111311

13121312
.. method:: PDFCatalog()
13131313

13141314
*(New in version 1.16.8)*
13151315

1316-
PDF only: Return the :data:`xref` of the PDF catalog (or root) object. For details please refer to :meth:`Document._getPDFroot`.
1316+
PDF only: Return the :data:`xref` of the PDF catalog (or root) object.
13171317

13181318

13191319
.. method:: PDFTrailer(compressed=False)
13201320

13211321
*(New in version 1.16.8)*
13221322

1323-
PDF only: Return the trailer of the PDF (UTF-8), which is usually located at the PDF file's end. For details please refer to :meth:`Document._getTrailerString`.
1323+
PDF only: Return the trailer of the PDF (UTF-8), which is usually located at the PDF file's end.
13241324

13251325

13261326
.. method:: metadataXML()
13271327

13281328
*(New in version 1.16.8)*
13291329

1330-
PDF only: Return the :data:`xref` of the document's XML metadata. For details please refer to :meth:`Document._getXmlMetadataXref`.
1330+
PDF only: Return the :data:`xref` of the document's XML metadata.
13311331

13321332
.. method:: xrefStream(xref)
13331333

@@ -1517,7 +1517,7 @@ Clear metadata information. If you do this out of privacy / data protection conc
15171517
{'producer': 'none', 'format': 'PDF 1.4', 'encryption': None, 'author': 'none',
15181518
'modDate': 'none', 'keywords': 'none', 'title': 'none', 'creationDate': 'none',
15191519
'creator': 'none', 'subject': 'none'}
1520-
>>> doc._delXmlMetadata() # clear any XML metadata
1520+
>>> doc.del_xml_metadata() # clear any XML metadata
15211521
>>> doc.save("anonymous.pdf", garbage = 4) # save anonymized doc
15221522

15231523
:meth:`setToC` Demonstration

docs/faq.rst

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1952,12 +1952,12 @@ If it is *False* or if you want to be on the safe side, pick one of the followin
19521952

19531953
* **Prepend** the missing stacking command by executing *fitz.TOOLS._insert_contents(page, b"q\n", False)*.
19541954
* **Append** an unstacking command by executing *fitz.TOOLS._insert_contents(page, b"\nQ", True)*.
1955-
* Alternatively, just use :meth:`Page._wrapContents`, which executes the previous two functions.
1955+
* Alternatively, just use :meth:`Page.wrap_contents`, which executes the previous two functions.
19561956

19571957
.. note:: If small incremental update deltas are a concern, this approach is the most effective. Other contents objects are not touched. The utility method creates two new PDF :data:`stream` objects and inserts them before, resp. after the page's other :data:`contents`. We therefore recommend the following snippet to get this situation under control:
19581958

19591959
>>> if not page._isWrapped:
1960-
page._wrapContents()
1960+
page.wrap_contents()
19611961
>>> # start inserting text, images or annotations here
19621962

19631963
--------------------------
@@ -2034,7 +2034,7 @@ How to Handle Object Streams
20342034
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
20352035
Some object types contain additional data apart from their object definition. Examples are images, fonts, embedded files or commands describing the appearance of a page.
20362036

2037-
Objects of these types are called "stream objects". PyMuPDF allows reading an object's stream via method :meth:`Document.xrefStream` with the object's :data:`xref` as an argument. And it is also possible to write back a modified version of a stream using :meth:`Document.updatefStream`.
2037+
Objects of these types are called "stream objects". PyMuPDF allows reading an object's stream via method :meth:`Document.xrefStream` with the object's :data:`xref` as an argument. And it is also possible to write back a modified version of a stream using :meth:`Document.updateStream`.
20382038

20392039
Assume that the following snippet wants to read all streams of a PDF for whatever reason::
20402040

@@ -2044,9 +2044,9 @@ Assume that the following snippet wants to read all streams of a PDF for whateve
20442044
# do something with it (it is a bytes object or None)
20452045
# e.g. just write it back:
20462046
if stream:
2047-
doc.updatefStream(xref, stream)
2047+
doc.updateStream(xref, stream)
20482048

2049-
:meth:`Document.xrefStream` automatically returns a stream decompressed as a bytes object -- and :meth:`Document.updatefStream` automatically compresses it (where beneficial).
2049+
:meth:`Document.xrefStream` automatically returns a stream decompressed as a bytes object -- and :meth:`Document.updateStream` automatically compresses it (where beneficial).
20502050

20512051
----------------------------------
20522052

@@ -2125,11 +2125,11 @@ ID array File identifier consisting of two byte strings.
21252125
XRefStm int Offset of a cross-reference stream. See :ref:`AdobeManual` p. 109.
21262126
======= =========== ===================================================================================
21272127

2128-
Access this information via PyMuPDF with :meth:`Document._getTrailerString`.
2128+
Access this information via PyMuPDF with :meth:`Document.PDFTrailer`.
21292129

21302130
>>> import fitz
21312131
>>> doc=fitz.open("PyMuPDF.pdf")
2132-
>>> trailer=doc._getTrailerString()
2132+
>>> trailer=doc.PDFTrailer()
21332133
>>> print(trailer)
21342134
<</Size 5535/Info 5275 0 R/Root 5274 0 R/ID[(\340\273fE\225^l\226\232O|\003\201\325g\245)(}#1,\317\205\000\371\251wO6\352Oa\021)]>>
21352135
>>>
@@ -2159,7 +2159,7 @@ PyMuPDF has no way to **interpret or change** this information directly, because
21592159
Using some XML package, the XML data can be interpreted and / or modified and then stored back::
21602160

21612161
>>> # write back modified XML metadata:
2162-
>>> doc.updatefStream(metaxref, xmlmetadata)
2162+
>>> doc.updateStream(metaxref, xmlmetadata)
21632163
>>>
21642164
>>> # if these data are not wanted, delete them:
2165-
>>> doc._delXmlMetadata()
2165+
>>> doc.del_xml_metadata()

docs/functions.rst

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ Yet others are handy, general-purpose utilities.
2020
:meth:`ConversionTrailer` return trailer string for *getText* methods
2121
:meth:`Document.del_xml_metadata` PDF only: remove XML metadata
2222
:meth:`Document.set_xml_metadata` PDF only: remove XML metadata
23-
:meth:`Document.delete_object` PDF only: delete an object
23+
:meth:`Document._deleteObject` PDF only: delete an object
2424
:meth:`Document.get_new_xref` PDF only: create and return a new :data:`xref` entry
2525
:meth:`Document._getOLRootNumber` PDF only: return / create :data:`xref` of */Outline*
2626
:meth:`Document.pdf_catalog` PDF only: return the :data:`xref` of the catalog
@@ -346,7 +346,7 @@ Yet others are handy, general-purpose utilities.
346346

347347
-----
348348

349-
.. method:: Document.delete_object(xref)
349+
.. method:: Document._deleteObject(xref)
350350

351351
PDF only: Delete an object given by its cross reference number.
352352

@@ -410,7 +410,7 @@ Yet others are handy, general-purpose utilities.
410410

411411
.. method:: Document.xml_metadata_xref()
412412

413-
Return the XML-based metadata :data:`xref` of the PDF if present -- also refer to :meth:`Document._delXmlMetadata`. You can use it to retrieve the content via :meth:`Document.xrefStream` and then work with it using some XML software.
413+
Return the XML-based metadata :data:`xref` of the PDF if present -- also refer to :meth:`Document.del_xml_metadata`. You can use it to retrieve the content via :meth:`Document.xrefStream` and then work with it using some XML software.
414414

415415
:rtype: int
416416
:returns: :data:`xref` of PDF file level XML metadata -- or 0 if none exists.
@@ -521,9 +521,9 @@ Yet others are handy, general-purpose utilities.
521521

522522
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.
523523

524-
Changed in version 1.16.0 Annotations are no longer implicitely cleaned by this method. Use :meth:`Annot._cleanContents` separately.
524+
Changed in version 1.16.0 Annotations are no longer implicitly cleaned by this method. Use :meth:`Annot.cleanContents` separately.
525525

526-
: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.
526+
:arg bool sanitize: *(new in v1.17.6)* if true, synchronization between resources and their actual use in the contents object is synchronized. 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.
527527

528528
.. 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"*.
529529

docs/page.rst

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,7 @@ In a nutshell, this is what you can do with PyMuPDF:
9696
:meth:`Page.showPDFpage` PDF only: display PDF page image
9797
:meth:`Page.updateLink` PDF only: modify a link
9898
:meth:`Page.widgets` return a generator over the fields on the page
99-
:meth:`Page.writeText` write one or more :ref:`Textwriter` objects
99+
:meth:`Page.writeText` write one or more :ref:`TextWriter` objects
100100
:attr:`Page.CropBox` the page's :data:`CropBox`
101101
:attr:`Page.CropBoxPosition` displacement of the :data:`CropBox`
102102
:attr:`Page.firstAnnot` first :ref:`Annot` on the page
@@ -472,7 +472,7 @@ In a nutshell, this is what you can do with PyMuPDF:
472472

473473
*(New in version 1.16.18)*
474474

475-
PDF only: Write the text of one or more :ref:`Textwriter` ojects to the page.
475+
PDF only: Write the text of one or more :ref:`TextWriter` objects to the page.
476476

477477
:arg rect_like rect: where to place the text. If omitted, the rectangle union of the text writers is used.
478478
:arg sequence writers: a non-empty tuple / list of :ref:`TextWriter` objects or a single :ref:`TextWriter`.

docs/rect.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ Hence some useful classification:
3333
:meth:`Rect.morph` transform with a point and a matrix
3434
:meth:`Rect.norm` the Euclidean norm
3535
:meth:`Rect.normalize` makes a rectangle finite
36-
:meth:`Rect.round` create smallest :ref:`Irect` containing rectangle
36+
:meth:`Rect.round` create smallest :ref:`IRect` containing rectangle
3737
:meth:`Rect.transform` transform rectangle with a matrix
3838
:attr:`Rect.bottom_left` bottom left point, synonym *bl*
3939
:attr:`Rect.bottom_right` bottom right point, synonym *br*

docs/tools.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ This class is a collection of utility methods and attributes, mainly around memo
88
====================================== =================================================
99
**Method / Attribute** **Description**
1010
====================================== =================================================
11-
:meth:`Tools.gen_id` generate a unique identifyer
11+
:meth:`Tools.gen_id` generate a unique identifier
1212
:meth:`Tools.image_profile` report basic image properties
1313
:meth:`Tools.store_shrink` shrink the storables cache [#f1]_
1414
:meth:`Tools.mupdf_warnings` return the accumulated MuPDF warnings

fitz/fitz.i

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10002,6 +10002,7 @@ struct TextPage {
1000210002
"""Return simple, bare text on the page."""
1000310003
return self._extractText(0)
1000410004

10005+
extractTEXT = extractText
1000510006

1000610007
def extractHTML(self) -> str:
1000710008
"""Return page content as a HTML string."""

0 commit comments

Comments
 (0)