Skip to content

Commit 8ddd2ce

Browse files
JorjMcKieCopilot
andcommitted
Update docs/textpage.rst
Co-Authored-By: Copilot <175728472+Copilot@users.noreply.github.com>
1 parent a09bad6 commit 8ddd2ce

2 files changed

Lines changed: 12 additions & 9 deletions

File tree

docs/textpage.rst

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -54,15 +54,15 @@ For a description of what this class is all about, see Appendix 2.
5454

5555
For an **image block**, its bbox and a text line with some image meta information is included -- not the image **content**. Image blocks are included only if the extraction flag bit :data:`TEXT_PRESERVE_IMAGES` is set. An image block tuple will look like this::
5656

57-
``(x0, y0, x1, y1, "<image: colorspace-name, w: width, h: height, bpc: bits_per_component>\n", block_no, 1)``
57+
``(x0, y0, x1, y1, "<image: colorspace-name, w: width, h: height, bpc: bits_per_component>\n", block_no, 1)``
5858

5959
For a **vector block**, the following item will be included. Vector blocks are included only if the extraction flag bit :data:`TEXT_COLLECT_VECTORS` is set. A vector block tuple will look like this::
6060

6161
``(x0, y0, x1, y1, "<vector stroked, color: #rrggbb, alpha: 255, is-rect: true, continues: false>\n", block_no, 3)``
6262

6363
The keyword "vector" is followed by either "stroked" or "filled". The color is given in HTML (hexadecimal RGB) format. Property ``is-rect`` is true, if the vector is no curve and parallel to the x- or y-axis. So in essence is either a real rectangle or a line segment. Property ``continues`` indicates whether the vector is part of a path (and not the first item).
6464

65-
.. note:: When no further details are needed (as provided by :meth:`Page.get_drawings`), then this extraction method is an inexpensive way to extract vector graphics. Another advantage is that all block types (text, images and vectors) are included in the output in the same order as they are present in the page's :data:`contents` stream.
65+
.. note:: When no further details are needed (as provided by :meth:`Page.get_drawings`), then this is an **inexpensive** way to extract basic vector graphics information. Another major advantage is that all block types (text, images and vectors) are included in the output in the same order as they are present in the page's :data:`contents` stream.
6666

6767
This is a high-speed method with just enough information to output plain text in desired reading sequence.
6868

@@ -227,7 +227,7 @@ color sRGB integer, e.g. 0xRRGGBB (``int``).
227227
alpha Transparency, a value in ``range(256)`` (``int``).
228228
=============== =========================================================================================================================
229229

230-
This information is a true subset of the output of :meth:`Page.get_drawings`. Its advantage is its speed (because extracted with one :ref:`TextPage` creation) and the fact that vector blocks are included in the overall page content sequence together with text and images.
230+
This information is a true subset of the output of :meth:`Page.get_drawings`. Its advantage is its speed (because it is extracted with one :ref:`TextPage` creation) and the fact that vector blocks are included in the overall page content sequence together with text and images.
231231

232232
**Image block:**
233233

docs/vars.rst

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -251,26 +251,29 @@ For the PyMuPDF programmer, some combination (using Python's `|` operator, or si
251251

252252
.. py:data:: TEXT_COLLECT_STRUCTURE
253253
254-
256 -- Not supported.
254+
256 -- Extract or generate the :ref:`Document` structure. Detail documentation pending.
255255

256256
.. py:data:: TEXT_ACCURATE_BBOXES
257257
258-
512 -- Ignore metric values of all fonts when computing character boundary boxes -- most prominently the `ascender <https://en.wikipedia.org/wiki/Ascender_(typography)>`_ and `descender <https://en.wikipedia.org/wiki/Descender>`_ values. Instead, follow the drawing commands of each character's glyph and compute its rectangle hull. This is the smallest rectangle wrapping all points used for drawing the visual appearance - see the :ref:`Shape` class for understanding the background. This will especially result in individual character heights. For instance a (white) space will have a **bbox of height 0** (because nothing is drawn) -- in contrast to the non-zero boundary box generated when using font metrics. This option may be useful to cope with getting meaningful boundary boxes even for fonts containing errors. Its use will slow down text extraction somewhat because of the incurred computational effort.
258+
512 -- Ignore metric values of all fonts when computing character boundary boxes -- most prominently the `ascender <https://en.wikipedia.org/wiki/Ascender_(typography)>`_ and `descender <https://en.wikipedia.org/wiki/Descender>`_ values. Instead, follow the drawing commands of each character's glyph and compute their rectangle hull as the bbox. This is the smallest rectangle wrapping all points used for drawing the visual appearance - see the :ref:`Shape` class for understanding the background. This will especially result in individual character heights. For instance a (white) space will have a **bbox of zero height** (because nothing is drawn) -- in contrast to the non-zero boundary box generated when using font metrics. This option may be useful to cope with failures of getting meaningful boundary boxes, even for fonts containing errors. Its use will slow down text extraction somewhat because of the incurred computational effort.
259259

260-
Note that this has no effect by default - one must also disable the global
261-
quad corrections setting with `pymupdf.TOOLS.unset_quad_corrections(True)`.
260+
Note that this has no effect by default - one must also disable the global quad corrections setting with `pymupdf.TOOLS.unset_quad_corrections(True)`.
262261

263262
.. py:data:: TEXT_COLLECT_VECTORS
264263
265-
1024 -- Not supported.
264+
1024 -- Collect vector drawings into the :ref:`TextPage`. These are stored as blocks alongside text and image blocks, depending on other extraction flags. See :meth:`TextPage.extractBLOCKS` and :meth:`TextPage.extractDICT` for details. Beyond these two methods, vector graphics extraction is also available for :meth:`TextPage.extractJSON`, :meth:`TextPage.extractRAWDICT`, :meth:`TextPage.extractRAWJSON` and :meth:`TextPage.extractXML`.
266265

267266
.. py:data:: TEXT_IGNORE_ACTUALTEXT
268267
269268
2048 -- Ignore built-in differences between text appearing in e.g. PDF viewers versus text stored in the PDF. See :ref:`AdobeManual`, page 615 for background. If set, the **stored** ("replacement" text) is ignored in favor of the displayed text.
270269

271270
.. py:data:: TEXT_SEGMENT
272271
273-
4096 -- Attempt to segment page into different regions.
272+
4096 -- Attempt to segment page into different regions. Detail documentation pending.
273+
274+
.. py:data:: TEXT_COLLECT_STYLES
275+
276+
32768 -- Request collecting text **decoration** properties. This includes text underlining and strikeout. In contrast to public awareness, these are no font properties, but are drawn separately as vector graphics or annotations on top of the text. In addition, the flag bit will also cause MuPDF to detect "fake bold" text. In many cases, Document creators **simulate bold** text by printing the same text multiple times with slight offsets. If this flag is set, such text will be marked as bold in the resulting text spans.
274277

275278
The following constants represent the default combinations of the above for text extraction and searching:
276279

0 commit comments

Comments
 (0)