PdfAnnotationCollection
Represents a collection of annotations on a PDF page. Provides methods to access, add, and remove annotations.
from nutrient import PdfAnnotationCollectionMethods
add_circle
def add_circle(self, x: float, y: float, width: float, height: float, author: str, contents: str) -> PdfCircleAnnotationAdds a circle (ellipse) annotation to this page.
Parameters:
| Name | Type | Description |
|---|---|---|
x | float | The x coordinate of the bounding rectangle in points. |
y | float | The y coordinate of the bounding rectangle in points. |
width | float | The width of the bounding rectangle in points. |
height | float | The height of the bounding rectangle in points. |
author | str | The author of the annotation. |
contents | str | The 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) -> PdfFreeTextAnnotationAdds a free text annotation (text box) to this page.
Parameters:
| Name | Type | Description |
|---|---|---|
x | float | The x coordinate of the text box in points. |
y | float | The y coordinate of the text box in points. |
width | float | The width of the text box in points. |
height | float | The height of the text box in points. |
author | str | The author of the annotation. |
contents | str | The text contents to display. |
font_name | str | The name of the font to use. |
font_size | float | The size of the font in points. |
font_color | Color | The 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) -> PdfHighlightAnnotationAdds a highlight annotation to this page.
Parameters:
| Name | Type | Description |
|---|---|---|
x | float | The x coordinate of the highlight area in points. |
y | float | The y coordinate of the highlight area in points. |
width | float | The width of the highlight area in points. |
height | float | The height of the highlight area in points. |
author | str | The author of the annotation. |
contents | str | The 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) -> PdfLineAnnotationAdds a line annotation to this page.
Parameters:
| Name | Type | Description |
|---|---|---|
start_x | float | X coordinate of the line start point in points. |
start_y | float | Y coordinate of the line start point in points. |
end_x | float | X coordinate of the line end point in points. |
end_y | float | Y coordinate of the line end point in points. |
author | str | The author of the annotation. |
contents | str | The 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.
add_link
def add_link(self, x: float, y: float, width: float, height: float) -> PdfLinkAnnotationAdds an empty link annotation to this page. Use the returned annotation’s property or method to configure the link target.
Parameters:
| Name | Type | Description |
|---|---|---|
x | float | The x coordinate of the link area in points. |
y | float | The y coordinate of the link area in points. |
width | float | The width of the link area in points. |
height | float | The 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) -> PdfRedactAnnotationAdds a redaction annotation to this page. The annotation marks content for redaction but does not apply the redaction until is called.
Parameters:
| Name | Type | Description |
|---|---|---|
x | float | The x coordinate of the redaction area in points. |
y | float | The y coordinate of the redaction area in points. |
width | float | The width of the redaction area in points. |
height | float | The 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) -> PdfSquareAnnotationAdds a square (rectangle) annotation to this page.
Parameters:
| Name | Type | Description |
|---|---|---|
x | float | The x coordinate of the rectangle in points. |
y | float | The y coordinate of the rectangle in points. |
width | float | The width of the rectangle in points. |
height | float | The height of the rectangle in points. |
author | str | The author of the annotation. |
contents | str | The 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) -> PdfSquigglyAnnotationAdds a squiggly underline annotation to this page.
Parameters:
| Name | Type | Description |
|---|---|---|
x | float | The x coordinate of the squiggly area in points. |
y | float | The y coordinate of the squiggly area in points. |
width | float | The width of the squiggly area in points. |
height | float | The height of the squiggly area in points. |
author | str | The author of the annotation. |
contents | str | The 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) -> PdfStampAnnotationAdds a rubber stamp annotation to this page.
Parameters:
| Name | Type | Description |
|---|---|---|
x | float | The x coordinate of the stamp in points. |
y | float | The y coordinate of the stamp in points. |
width | float | The width of the stamp in points. |
height | float | The height of the stamp in points. |
title | str | The title of the annotation. |
contents | str | The 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) -> PdfTextAnnotationAdds a sticky note (text) annotation to this page.
Parameters:
| Name | Type | Description |
|---|---|---|
x | float | The x coordinate of the annotation in points. |
y | float | The y coordinate of the annotation in points. |
author | str | The author of the annotation. |
subject | str | The subject of the annotation. |
contents | str | The 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) -> PdfStrikeOutAnnotationAdds a strikeout annotation to this page.
Parameters:
| Name | Type | Description |
|---|---|---|
x | float | The x coordinate of the strikeout area in points. |
y | float | The y coordinate of the strikeout area in points. |
width | float | The width of the strikeout area in points. |
height | float | The height of the strikeout area in points. |
author | str | The author of the annotation. |
contents | str | The 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) -> PdfUnderlineAnnotationAdds an underline annotation to this page.
Parameters:
| Name | Type | Description |
|---|---|---|
x | float | The x coordinate of the underline area in points. |
y | float | The y coordinate of the underline area in points. |
width | float | The width of the underline area in points. |
height | float | The height of the underline area in points. |
author | str | The author of the annotation. |
contents | str | The 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) -> PdfAnnotationReturns the element at the specified index.
Parameters:
| Name | Type | Description |
|---|---|---|
index | int | The zero-based index of the element to get. |
Returns: PdfAnnotation - The element at the specified index.
remove_at
def remove_at(self, index: int) -> NoneRemoves the annotation at the specified index.
Parameters:
| Name | Type | Description |
|---|---|---|
index | int | The 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
@propertydef count(self) -> intGets the number of annotations in the collection.
Type: int
Read-only property.
enumerator
@propertydef enumerator(self) -> IEnumerator`1Returns an enumerator that iterates through the annotation’s collection.
Type: IEnumerator1`
Read-only property.