remove method

remove

Removes an annotation from the document by its identifier.

def remove(self, annotation_id):
    ...
Parameter Type Description
annotation_id int The annotation’s id that must be removed.

Example

from groupdocs.annotation import Annotator

def remove_annotation_by_id():
    # Open an annotated document and remove a single annotation by its id
    with Annotator("./annotated.pdf") as annotator:
        annotations = annotator.get()
        if annotations:
            annotator.remove(annotation_id=annotations[0].id)
        annotator.save("./output.pdf")

remove

Removes an annotation from the document.

def remove(self, annotation):
    ...
Parameter Type Description
annotation AnnotationBase Annotation that must be removed.

Returns: None.

Example

from groupdocs.annotation import Annotator

def remove_annotation_by_object():
    # Open an annotated document and remove a single annotation by its object
    with Annotator("./annotated.pdf") as annotator:
        annotations = annotator.get()
        if annotations:
            annotator.remove(annotation=annotations[0])
        annotator.save("./output.pdf")

remove

Removes a collection of annotations from the document using the provided annotation IDs.

More about how to remove document annotations:

def remove(self, annotation_ids):
    ...
Parameter Type Description
annotation_ids List[int] Iterable of annotation IDs (e.g., list of str) that should be removed.

Example

from groupdocs.annotation import Annotator

def remove_annotation_by_id():
    # Open an annotated document and remove a single annotation by its id
    with Annotator("./annotated.pdf") as annotator:
        annotations = annotator.get()
        if annotations:
            annotator.remove(annotation_id=annotations[0].id)
        annotator.save("./output.pdf")

remove

Removes collection of annotations from document.

def remove(self, annotations_to_delete):
    ...
Parameter Type Description
annotations_to_delete List[AnnotationBase] The annotations that must be removed.

Example

from groupdocs.annotation import Annotator

def remove_all_annotations():
    with Annotator("./annotated.pdf") as annotator:
        annotations = annotator.get()
        if annotations:
            annotator.remove(annotations_to_delete=annotations)
        annotator.save("./output.pdf")

See Also