Skip to content

Commit 6f61833

Browse files
committed
Keyword-only requirements
Change Page and Shape methods to require keyword-only specifications as required `.insert_text()` and `.insert_textbox()`.
1 parent 57d1d63 commit 6f61833

File tree

3 files changed

+10
-6
lines changed

3 files changed

+10
-6
lines changed

docs/page.rst

+3-3
Original file line numberDiff line numberDiff line change
@@ -728,9 +728,9 @@ In a nutshell, this is what you can do with PyMuPDF:
728728
pair: fill_opacity; insert_text
729729
pair: oc; insert_text
730730

731-
.. method:: insert_text(point, text, fontsize=11, fontname="helv", fontfile=None, idx=0, color=None, fill=None, render_mode=0, border_width=1, encoding=TEXT_ENCODING_LATIN, rotate=0, morph=None, stroke_opacity=1, fill_opacity=1, overlay=True, oc=0)
731+
.. method:: insert_text(point, text, *, fontsize=11, fontname="helv", fontfile=None, idx=0, color=None, fill=None, render_mode=0, border_width=1, encoding=TEXT_ENCODING_LATIN, rotate=0, morph=None, stroke_opacity=1, fill_opacity=1, overlay=True, oc=0)
732732

733-
PDF only: Insert text starting at :data:`point_like` *point*. See :meth:`Shape.insert_text`.
733+
PDF only: Insert text lines starting at :data:`point_like` ``point``. See :meth:`Shape.insert_text`.
734734

735735
|history_begin|
736736

@@ -756,7 +756,7 @@ In a nutshell, this is what you can do with PyMuPDF:
756756
pair: fill_opacity; insert_textbox
757757
pair: oc; insert_textbox
758758

759-
.. method:: insert_textbox(rect, buffer, fontsize=11, fontname="helv", fontfile=None, idx=0, color=None, fill=None, render_mode=0, border_width=1, encoding=TEXT_ENCODING_LATIN, expandtabs=8, align=TEXT_ALIGN_LEFT, charwidths=None, rotate=0, morph=None, stroke_opacity=1, fill_opacity=1, oc=0, overlay=True)
759+
.. method:: insert_textbox(rect, buffer, *, fontsize=11, fontname="helv", fontfile=None, idx=0, color=None, fill=None, render_mode=0, border_width=1, encoding=TEXT_ENCODING_LATIN, expandtabs=8, align=TEXT_ALIGN_LEFT, charwidths=None, rotate=0, morph=None, stroke_opacity=1, fill_opacity=1, oc=0, overlay=True)
760760

761761
PDF only: Insert text into the specified :data:`rect_like` *rect*. See :meth:`Shape.insert_textbox`.
762762

docs/shape.rst

+3-3
Original file line numberDiff line numberDiff line change
@@ -291,9 +291,9 @@ Several draw methods can be executed in a row and each one of them will contribu
291291
pair: fill_opacity; insert_text
292292
pair: oc; insert_text
293293

294-
.. method:: insert_text(point, text, fontsize=11, fontname="helv", fontfile=None, set_simple=False, encoding=TEXT_ENCODING_LATIN, color=None, lineheight=None, fill=None, render_mode=0, border_width=1, rotate=0, morph=None, stroke_opacity=1, fill_opacity=1, oc=0)
294+
.. method:: insert_text(point, text, *, fontsize=11, fontname="helv", fontfile=None, set_simple=False, encoding=TEXT_ENCODING_LATIN, color=None, lineheight=None, fill=None, render_mode=0, border_width=1, rotate=0, morph=None, stroke_opacity=1, fill_opacity=1, oc=0)
295295

296-
Insert text lines start at *point*.
296+
Insert text lines starting at ``point``.
297297

298298
:arg point_like point: the bottom-left position of the first character of *text* in pixels. It is important to understand, how this works in conjunction with the *rotate* parameter. Please have a look at the following picture. The small red dots indicate the positions of *point* in each of the four possible cases.
299299

@@ -331,7 +331,7 @@ Several draw methods can be executed in a row and each one of them will contribu
331331
pair: rotate; insert_textbox
332332
pair: oc; insert_textbox
333333

334-
.. method:: insert_textbox(rect, buffer, fontsize=11, fontname="helv", fontfile=None, set_simple=False, encoding=TEXT_ENCODING_LATIN, color=None, fill=None, render_mode=0, border_width=1, expandtabs=8, align=TEXT_ALIGN_LEFT, rotate=0, lineheight=None, morph=None, stroke_opacity=1, fill_opacity=1, oc=0)
334+
.. method:: insert_textbox(rect, buffer, *, fontsize=11, fontname="helv", fontfile=None, set_simple=False, encoding=TEXT_ENCODING_LATIN, color=None, fill=None, render_mode=0, border_width=1, expandtabs=8, align=TEXT_ALIGN_LEFT, rotate=0, lineheight=None, morph=None, stroke_opacity=1, fill_opacity=1, oc=0)
335335

336336
PDF only: Insert text into the specified rectangle. The text will be split into lines and words and then filled into the available space, starting from one of the four rectangle corners, which depends on `rotate`. Line feeds and multiple space will be respected.
337337

src/utils.py

+4
Original file line numberDiff line numberDiff line change
@@ -1919,6 +1919,7 @@ def insert_textbox(
19191919
page: pymupdf.Page,
19201920
rect: rect_like,
19211921
buffer: typing.Union[str, list],
1922+
*,
19221923
fontname: str = "helv",
19231924
fontfile: OptStr = None,
19241925
set_simple: int = 0,
@@ -1989,6 +1990,7 @@ def insert_text(
19891990
page: pymupdf.Page,
19901991
point: point_like,
19911992
text: typing.Union[str, list],
1993+
*,
19921994
fontsize: float = 11,
19931995
lineheight: OptFloat = None,
19941996
fontname: str = "helv",
@@ -3761,6 +3763,7 @@ def insert_text(
37613763
self,
37623764
point: point_like,
37633765
buffer: typing.Union[str, list],
3766+
*,
37643767
fontsize: float = 11,
37653768
lineheight: OptFloat = None,
37663769
fontname: str = "helv",
@@ -3947,6 +3950,7 @@ def insert_textbox(
39473950
self,
39483951
rect: rect_like,
39493952
buffer: typing.Union[str, list],
3953+
*,
39503954
fontname: OptStr = "helv",
39513955
fontfile: OptStr = None,
39523956
fontsize: float = 11,

0 commit comments

Comments
 (0)