Skip to content

Commit

Permalink
Reflect changes to method parameters
Browse files Browse the repository at this point in the history
  • Loading branch information
JorjMcKie committed Dec 14, 2023
1 parent 5f97191 commit c7f7298
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 8 deletions.
11 changes: 5 additions & 6 deletions docs/page.rst
Original file line number Diff line number Diff line change
Expand Up @@ -637,7 +637,7 @@ In a nutshell, this is what you can do with PyMuPDF:
pair: oc; insert_htmlbox
pair: morph; insert_htmlbox

.. method:: insert_htmlbox(rect, text, *, css=None, scale=True, archive=None, rotate=0, morph=None, oc=0, overlay=True)
.. method:: insert_htmlbox(rect, text, *, css=None, scale_low=0, archive=None, rotate=0, oc=0, overlay=True)

* New in v1.23.8

Expand All @@ -664,7 +664,7 @@ In a nutshell, this is what you can do with PyMuPDF:
:arg rect_like rect: rectangle on page to receive the text.
:arg str,Story text: the text to be written. Can contain plain text and HTML tags with styling instructions. Alternatively, a :ref:`Story` object may be specified (in which case the internal Story generation step will be omitted). A Story must have been generated with all required styling and Archive information.
:arg str css: optional string containing additional CSS instructions. Ignored if "text" is a Story.
:arg bool scale: if necessary scale down the content until it fits in the target rectangle.
:arg float scale_low: if necessary scale down the content until it fits in the target rectangle. This sets the down scaling limit. Detault is 0, no limit. A value of 1 means no down-scaling. A value of e.g. 0.2 means maximum down-scaling by 80%.
:arg Archive archive: an Archive object that points to locations where to find images or non-standard fonts. If "text" refers to images, this parameter is always reqired. Ignored if "text" is a Story.
:arg int rotate: one of the values 0, 90, 180, 270. Depending on this, text will be filled:

Expand All @@ -678,12 +678,11 @@ In a nutshell, this is what you can do with PyMuPDF:

:arg int oc: the xref of an :data:`OCG` / :data:`OCMD` or 0. Please refer to :meth:`Page.show_pdf_page` for details.
:arg bool overlay: put the text in front of other content. Please refer to :meth:`Page.show_pdf_page` for details.
:arg tuple morph: a sequence of (point, Matrix). Please refer to :meth:`Page.show_pdf_page` for details.

:returns: A tuple of floats (delta, factor).
:returns: A tuple of floats (spare_height, scale).

- **delta**: -1 if content did not fit, else >= 0. It is the height of the unused (still available) rectangle stripe. Positive only if factor = 1 (no down scaling happened).
- **factor**: downscaling factor, 0 < factor <= 1. Will be 0 if delta = -1.
- **spare_height**: -1 if content did not fit, else >= 0. It is the height of the unused (still available) rectangle stripe. Positive only if scale = 1 (no down-scaling happened).
- **scale**: down-scaling factor, 0 < scale <= 1.

Please refer to examples in this section of the recipes: :ref:`RecipesText_I_c`.

Expand Down
4 changes: 2 additions & 2 deletions docs/recipes-text.rst
Original file line number Diff line number Diff line change
Expand Up @@ -425,9 +425,9 @@ Some default values were used above: font size 11 and text alignment "left". The

How to Fill a Box with HTML Text
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Method :meth:`Page.insert_htmlbox` offers a **much more powerful** way to insert text in a rectangle. Instead of simple plain text, this method accepts HTML source, which may not only contain HTML tags but also styling instructions to influence things like font, font weight (bold) and style (italic), color and much more. It is also possible to mix multiple fonts and languages, output HTML tables and insert images. Any URI links are also supported.
Method :meth:`Page.insert_htmlbox` offers a **much more powerful** way to insert text in a rectangle. Instead of simple, plain text, this method accepts HTML source, which may not only contain HTML tags but also styling instructions to influence things like font, font weight (bold) and style (italic), color and much more. It is also possible to mix multiple fonts and languages, output HTML tables and insert images. Any URI links are also supported.

To extend the possibilities even more, an additional CSS source may also be given.
For even more styling flexibility, an additional CSS source may also be given.

The method is based on the :ref:`Story` class. Therefore, complex script systems like Devanagari, Nepali, Tamil and many are supported and written correctly thanks to using the HarfBuzz library - which provides this feature, called *"text shaping"*.

Expand Down

0 comments on commit c7f7298

Please sign in to comment.