Represents a collection of annotations on a PDF page. Provides methods to access, add, and remove annotations.

from nutrient import PdfAnnotationCollection

Methods

add_circle

def add_circle(self, x: float, y: float, width: float, height: float, author: str, contents: str) -> PdfCircleAnnotation

Adds a circle (ellipse) annotation to this page.

Parameters:

NameTypeDescription
xfloatThe x coordinate of the bounding rectangle in points.
yfloatThe y coordinate of the bounding rectangle in points.
widthfloatThe width of the bounding rectangle in points.
heightfloatThe height of the bounding rectangle in points.
authorstrThe author of the annotation.
contentsstrThe text contents/comment for the annotation.

Returns: PdfCircleAnnotation - The newly created . Raises:

  • InvalidStateException: Thrown when no page is loaded.
  • SdkException: Thrown when the operation fails.

add_free_text

def add_free_text(self, x: float, y: float, width: float, height: float, author: str, contents: str, font_name: str, font_size: float, font_color: Color) -> PdfFreeTextAnnotation

Adds a free text annotation (text box) to this page.

Parameters:

NameTypeDescription
xfloatThe x coordinate of the text box in points.
yfloatThe y coordinate of the text box in points.
widthfloatThe width of the text box in points.
heightfloatThe height of the text box in points.
authorstrThe author of the annotation.
contentsstrThe text contents to display.
font_namestrThe name of the font to use.
font_sizefloatThe size of the font in points.
font_colorColorThe color of the text.

Returns: PdfFreeTextAnnotation - The newly created . Raises:

  • InvalidStateException: Thrown when no page is loaded.
  • SdkException: Thrown when the operation fails.

add_highlight

def add_highlight(self, x: float, y: float, width: float, height: float, author: str, contents: str) -> PdfHighlightAnnotation

Adds a highlight annotation to this page.

Parameters:

NameTypeDescription
xfloatThe x coordinate of the highlight area in points.
yfloatThe y coordinate of the highlight area in points.
widthfloatThe width of the highlight area in points.
heightfloatThe height of the highlight area in points.
authorstrThe author of the annotation.
contentsstrThe text contents/comment for the annotation.

Returns: PdfHighlightAnnotation - The newly created . Raises:

  • InvalidStateException: Thrown when no page is loaded.
  • SdkException: Thrown when the operation fails.

add_line

def add_line(self, start_x: float, start_y: float, end_x: float, end_y: float, author: str, contents: str) -> PdfLineAnnotation

Adds a line annotation to this page.

Parameters:

NameTypeDescription
start_xfloatX coordinate of the line start point in points.
start_yfloatY coordinate of the line start point in points.
end_xfloatX coordinate of the line end point in points.
end_yfloatY coordinate of the line end point in points.
authorstrThe author of the annotation.
contentsstrThe text contents/comment for the annotation.

Returns: PdfLineAnnotation - The newly created . Raises:

  • InvalidStateException: Thrown when no page is loaded.
  • SdkException: Thrown when the operation fails.

def add_link(self, x: float, y: float, width: float, height: float) -> PdfLinkAnnotation

Adds an empty link annotation to this page. Use the returned annotation’s property or method to configure the link target.

Parameters:

NameTypeDescription
xfloatThe x coordinate of the link area in points.
yfloatThe y coordinate of the link area in points.
widthfloatThe width of the link area in points.
heightfloatThe height of the link area in points.

Returns: PdfLinkAnnotation - The newly created . Raises:

  • InvalidStateException: Thrown when no page is loaded.
  • SdkException: Thrown when the operation fails.

add_redact

def add_redact(self, x: float, y: float, width: float, height: float) -> PdfRedactAnnotation

Adds a redaction annotation to this page. The annotation marks content for redaction but does not apply the redaction until is called.

Parameters:

NameTypeDescription
xfloatThe x coordinate of the redaction area in points.
yfloatThe y coordinate of the redaction area in points.
widthfloatThe width of the redaction area in points.
heightfloatThe height of the redaction area in points.

Returns: PdfRedactAnnotation - The newly created . Raises:

  • InvalidStateException: Thrown when no page is loaded.
  • SdkException: Thrown when the operation fails.

add_square

def add_square(self, x: float, y: float, width: float, height: float, author: str, contents: str) -> PdfSquareAnnotation

Adds a square (rectangle) annotation to this page.

Parameters:

NameTypeDescription
xfloatThe x coordinate of the rectangle in points.
yfloatThe y coordinate of the rectangle in points.
widthfloatThe width of the rectangle in points.
heightfloatThe height of the rectangle in points.
authorstrThe author of the annotation.
contentsstrThe text contents/comment for the annotation.

Returns: PdfSquareAnnotation - The newly created . Raises:

  • InvalidStateException: Thrown when no page is loaded.
  • SdkException: Thrown when the operation fails.

add_squiggly

def add_squiggly(self, x: float, y: float, width: float, height: float, author: str, contents: str) -> PdfSquigglyAnnotation

Adds a squiggly underline annotation to this page.

Parameters:

NameTypeDescription
xfloatThe x coordinate of the squiggly area in points.
yfloatThe y coordinate of the squiggly area in points.
widthfloatThe width of the squiggly area in points.
heightfloatThe height of the squiggly area in points.
authorstrThe author of the annotation.
contentsstrThe text contents/comment for the annotation.

Returns: PdfSquigglyAnnotation - The newly created . Raises:

  • InvalidStateException: Thrown when no page is loaded.
  • SdkException: Thrown when the operation fails.

add_stamp

def add_stamp(self, x: float, y: float, width: float, height: float, title: str, contents: str) -> PdfStampAnnotation

Adds a rubber stamp annotation to this page.

Parameters:

NameTypeDescription
xfloatThe x coordinate of the stamp in points.
yfloatThe y coordinate of the stamp in points.
widthfloatThe width of the stamp in points.
heightfloatThe height of the stamp in points.
titlestrThe title of the annotation.
contentsstrThe text contents of the annotation.

Returns: PdfStampAnnotation - The newly created . Raises:

  • InvalidStateException: Thrown when no page is loaded.
  • SdkException: Thrown when the operation fails.

add_sticky_note

def add_sticky_note(self, x: float, y: float, author: str, subject: str, contents: str) -> PdfTextAnnotation

Adds a sticky note (text) annotation to this page.

Parameters:

NameTypeDescription
xfloatThe x coordinate of the annotation in points.
yfloatThe y coordinate of the annotation in points.
authorstrThe author of the annotation.
subjectstrThe subject of the annotation.
contentsstrThe text contents of the annotation.

Returns: PdfTextAnnotation - The newly created . Raises:

  • InvalidStateException: Thrown when no page is loaded.
  • SdkException: Thrown when the operation fails.

add_strike_out

def add_strike_out(self, x: float, y: float, width: float, height: float, author: str, contents: str) -> PdfStrikeOutAnnotation

Adds a strikeout annotation to this page.

Parameters:

NameTypeDescription
xfloatThe x coordinate of the strikeout area in points.
yfloatThe y coordinate of the strikeout area in points.
widthfloatThe width of the strikeout area in points.
heightfloatThe height of the strikeout area in points.
authorstrThe author of the annotation.
contentsstrThe text contents/comment for the annotation.

Returns: PdfStrikeOutAnnotation - The newly created . Raises:

  • InvalidStateException: Thrown when no page is loaded.
  • SdkException: Thrown when the operation fails.

add_underline

def add_underline(self, x: float, y: float, width: float, height: float, author: str, contents: str) -> PdfUnderlineAnnotation

Adds an underline annotation to this page.

Parameters:

NameTypeDescription
xfloatThe x coordinate of the underline area in points.
yfloatThe y coordinate of the underline area in points.
widthfloatThe width of the underline area in points.
heightfloatThe height of the underline area in points.
authorstrThe author of the annotation.
contentsstrThe text contents/comment for the annotation.

Returns: PdfUnderlineAnnotation - The newly created . Raises:

  • InvalidStateException: Thrown when no page is loaded.
  • SdkException: Thrown when the operation fails.

get_item

def get_item(self, index: int) -> PdfAnnotation

Returns the element at the specified index.

Parameters:

NameTypeDescription
indexintThe zero-based index of the element to get.

Returns: PdfAnnotation - The element at the specified index.


remove_at

def remove_at(self, index: int) -> None

Removes the annotation at the specified index.

Parameters:

NameTypeDescription
indexintThe 0-based index of the annotation to remove.

Raises:

  • InvalidStateException: Thrown when no page is loaded.
  • IndexOutOfBoundsException: Thrown when the index is out of range.
  • SdkException: Thrown when the operation fails.

Properties

count

@property
def count(self) -> int

Gets the number of annotations in the collection.

Type: int

Read-only property.


enumerator

@property
def enumerator(self) -> IEnumerator`1

Returns an enumerator that iterates through the annotation’s collection.

Type: IEnumerator1`

Read-only property.