Skip to content

Commit 2cf119b

Browse files
committed
Clarifications
Several clarifications.
1 parent c984a00 commit 2cf119b

File tree

2 files changed

+11
-24
lines changed

2 files changed

+11
-24
lines changed

docs/page.rst

Lines changed: 3 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -300,30 +300,17 @@ In a nutshell, this is what you can do with PyMuPDF:
300300

301301
.. method:: add_redact_annot(quad, text=None, fontname=None, fontsize=11, align=TEXT_ALIGN_LEFT, fill=(1, 1, 1), text_color=(0, 0, 0), cross_out=True)
302302

303-
**PDF only**: Add a redaction annotation. A redaction annotation identifies content to be removed from the document. Adding such an annotation is the first of two steps. It makes visible what will be removed in the subsequent step, :meth:`Page.apply_redactions`.
303+
**PDF only**: Add a redaction annotation. A redaction annotation identifies an area whose content should be removed from the document. Adding such an annotation is the first of two steps. It makes visible what will be removed in the subsequent step, :meth:`Page.apply_redactions`.
304304

305305
:arg quad_like,rect_like quad: specifies the (rectangular) area to be removed which is always equal to the annotation rectangle. This may be a :data:`rect_like` or :data:`quad_like` object. If a quad is specified, then the enveloping rectangle is taken.
306306

307307
:arg str text: text to be placed in the rectangle after applying the redaction (and thus removing old content). (New in v1.16.12)
308308

309-
:arg str fontname: the font to use when *text* is given, otherwise ignored. The same rules apply as for :meth:`Page.insert_textbox` -- which is the method :meth:`Page.apply_redactions` internally invokes. The replacement text will be **vertically centered**, if this is one of the CJK or :ref:`Base-14-Fonts`. (New in v1.16.12)
310-
311-
.. note::
312-
313-
* For an **existing** font of the page, use its reference name as *fontname* (this is *item[4]* of its entry in :meth:`Page.get_fonts`).
314-
* For a **new, non-builtin** font, proceed as follows::
315-
316-
page.insert_text(point, # anywhere, but outside all redaction rectangles
317-
"something", # some non-empty string
318-
fontname="newname", # new, unused reference name
319-
fontfile="...", # desired font file
320-
render_mode=3, # makes the text invisible
321-
)
322-
page.add_redact_annot(..., fontname="newname")
309+
:arg str fontname: the font to use when ``text`` is given, otherwise ignored. Only CJK and the :ref:`Base-14-Fonts` are supported. Apart from this, the same rules apply as for :meth:`Page.insert_textbox` -- which is what the method :meth:`Page.apply_redactions` internally invokes.
323310

324311
:arg float fontsize: the :data:`fontsize` to use for the replacing text. If the text is too large to fit, several insertion attempts will be made, gradually reducing the :data:`fontsize` to no less than 4. If then the text will still not fit, no text insertion will take place at all. (New in v1.16.12)
325312

326-
:arg int align: the horizontal alignment for the replacing text. See :meth:`insert_textbox` for available values. The vertical alignment is (approximately) centered if a PDF built-in font is used (CJK or :ref:`Base-14-Fonts`). (New in v1.16.12)
313+
:arg int align: the horizontal alignment for the replacing text. See :meth:`insert_textbox` for available values. The vertical alignment is (approximately) centered.
327314

328315
:arg sequence fill: the fill color of the rectangle **after applying** the redaction. The default is *white = (1, 1, 1)*, which is also taken if ``None`` is specified. To suppress a fill color altogether, specify ``False``. In this cases the rectangle remains transparent. (New in v1.16.12)
329316

docs/rect.rst

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -104,11 +104,11 @@ The following remarks are also valid for :ref:`IRect` objects:
104104

105105
If "rect" is specified, the constructor creates a **new copy** of it.
106106

107-
Without parameters, the empty rectangle *Rect(0.0, 0.0, 0.0, 0.0)* is created.
107+
Without parameters, the empty rectangle ``Rect(0.0, 0.0, 0.0, 0.0)`` is created.
108108

109109
.. method:: round()
110110

111-
Creates the smallest containing :ref:`IRect`. This is **not** the same as simply rounding the rectangle's edges: The top left corner is rounded upwards and to the left while the bottom right corner is rounded downwards and to the right.
111+
Creates the smallest containing :ref:`IRect`. This is **not the same** as simply rounding the rectangle's edges: The top left corner is rounded upwards and to the left while the bottom right corner is rounded downwards and to the right.
112112

113113
>>> pymupdf.Rect(0.5, -0.01, 123.88, 455.123456).round()
114114
IRect(0, -1, 124, 456)
@@ -131,7 +131,7 @@ The following remarks are also valid for :ref:`IRect` objects:
131131
Transforms the rectangle with a matrix and **replaces the original**. If the rectangle is empty or infinite, this is a no-operation.
132132

133133
:arg m: The matrix for the transformation.
134-
:type m: :ref:`Matrix`
134+
:type m: :data:`matrix_like`
135135

136136
:rtype: *Rect*
137137
:returns: the smallest rectangle that contains the transformed original.
@@ -141,21 +141,21 @@ The following remarks are also valid for :ref:`IRect` objects:
141141
The intersection (common rectangular area, largest rectangle contained in both) of the current rectangle and *r* is calculated and **replaces the current** rectangle. If either rectangle is empty, the result is also empty. If *r* is infinite, this is a no-operation. If the rectangles are (mathematically) disjoint sets, then the result is invalid. If the result is valid but empty, then the rectangles touch each other in a corner or (part of) a side.
142142

143143
:arg r: Second rectangle
144-
:type r: :ref:`Rect`
144+
:type r: :data:`rect_like`
145145

146146
.. method:: include_rect(r)
147147

148-
The smallest rectangle containing the current one and *r* is calculated and **replaces the current** one. If either rectangle is infinite, the result is also infinite. If one is empty, the other one will be taken as the result.
148+
The smallest rectangle containing the current one and ``r`` is calculated and **replaces the current** one. If either rectangle is infinite, the result is also infinite. If ``r`` is empty, the current rectangle remains unchanged. Else if the current rectangle is empty, it is replaced by ``r``.
149149

150150
:arg r: Second rectangle
151-
:type r: :ref:`Rect`
151+
:type r: :data:`rect_like`
152152

153153
.. method:: include_point(p)
154154

155-
The smallest rectangle containing the current one and point *p* is calculated and **replaces the current** one. **The infinite rectangle remains unchanged.** To create a rectangle containing a series of points, start with (the empty) *pymupdf.Rect(p1, p1)* and successively include the remaining points.
155+
The smallest rectangle containing the current one and :data:`point_like` ``p`` is calculated and **replaces the current** one. **The infinite rectangle remains unchanged.** To create the rectangle that wraps a sequence of points, start with :meth:`EMPTY_RECT` and successively include the members of the sequence.
156156

157157
:arg p: Point to include.
158-
:type p: :ref:`Point`
158+
:type p: :data:`point_like`
159159

160160

161161
.. method:: get_area([unit])

0 commit comments

Comments
 (0)