pdftools_toolbox.pdf.annotations.free_text
Classes
|
An annotation that displays text |
- class pdftools_toolbox.pdf.annotations.free_text.FreeText(handle)[source]
Bases:
MarkupAnnotation
An annotation that displays text
For a free-text annotation, the annotation’s content is used as text to be displayed as the annotation’s visual manifestation on the page.
- static create(target_document: Document, bounding_box: Rectangle, content: str | None, paint: Paint | None, stroke: Stroke | None = None) FreeText [source]
Create a free-text annotation.
The returned free-text annotation is not yet part of any page. It can be added to a page’s list of annotations.
- Parameters:
targetDocument (pdftools_toolbox.pdf.document.Document) – The output document with which the returned object is associated.
boundingBox (pdftools_toolbox.geometry.real.rectangle.Rectangle) – The location on the page.
content (Optional[str]) – The text content.
paint (Optional[pdftools_toolbox.pdf.content.paint.Paint]) – This paint used for the background of the free text annotation. If None, the background is transparent.
stroke (Optional[pdftools_toolbox.pdf.content.stroke.Stroke]) – The stroking parameters used for stroking the rectangle. The stroking paint is used as the annotation’s main paint.
- Returns:
The newly created free text annotation.
- Return type:
- Raises:
ValueError – if the targetDocument has already been closed
ValueError – if the targetDocument is read-only
ValueError – if the paint has a
pdftools_toolbox.pdf.content.paint.Paint.color_space
other than a device color spaceValueError – if the paint has a non-None
pdftools_toolbox.pdf.content.paint.Paint.transparency
withpdftools_toolbox.pdf.content.transparency.Transparency.blend_mode
other thanpdftools_toolbox.pdf.content.blend_mode.BlendMode.NORMAL
ValueError – if the paint argument is not associated with the targetDocument
ValueError – if the stroke’s
pdftools_toolbox.pdf.content.stroke.Stroke.paint
has apdftools_toolbox.pdf.content.paint.Paint.color_space
other than a device color spaceValueError – if the stroke’s
pdftools_toolbox.pdf.content.stroke.Stroke.paint
has a non-Nonepdftools_toolbox.pdf.content.paint.Paint.transparency
withpdftools_toolbox.pdf.content.transparency.Transparency.blend_mode
other thanpdftools_toolbox.pdf.content.blend_mode.BlendMode.NORMAL
ValueError – if the stroke’s
pdftools_toolbox.pdf.content.stroke.Stroke.line_cap_style
is other thanpdftools_toolbox.pdf.content.line_cap_style.LineCapStyle.BUTT
ValueError – if the stroke’s
pdftools_toolbox.pdf.content.stroke.Stroke.line_join_style
is other thanpdftools_toolbox.pdf.content.line_join_style.LineJoinStyle.MITER
ValueError – if the stroke’s
pdftools_toolbox.pdf.content.stroke.Stroke.miter_limit
is other than 10ValueError – if the stroke’s
pdftools_toolbox.pdf.content.stroke.Stroke.dash_phase
is other than 0
- property font_size: float
The font size
Default value: 12.
Note: the font size has no effect when rich text is used
- Returns:
float
- Raises:
StateError – if the object has already been closed
- property alignment: HorizontalAlignment
The text alignment
- Returns:
pdftools_toolbox.geometry.horizontal_alignment.HorizontalAlignment
- Raises:
StateError – if the object has already been closed
- property paint: Paint
The paint for the text background and the popup
- Returns:
pdftools_toolbox.pdf.content.paint.Paint
- Raises:
StateError – if the object has already been closed
pdftools_toolbox.corrupt_error.CorruptError – if the PDF is corrupt and the annotation’s paint cannot be read