save method

save

Saves document after adding, updating or removing annotations.

Learn more about saving annotated documents

def save(self):
    ...

Example

import io
from groupdocs.annotation import Annotator

with Annotator("document.pdf") as annotator:
    # add annotations here, e.g., annotator.add(area)
    buf = io.BytesIO()
    annotator.save(buf)  # BytesIO is updated after save
    data = buf.getvalue()

save

Saves the document after adding, updating, or removing annotations.

def save(self, save_options):
    ...
Parameter Type Description
save_options SaveOptions The save options.

Returns: None.

Example

import io
from groupdocs.annotation import Annotator
from groupdocs.annotation.options import SaveOptions, AnnotationType

with Annotator("document.pdf") as annotator:
    # add annotations here, e.g., annotator.add(area)

    # Save to a memory stream
    stream = io.BytesIO()
    annotator.save(stream)
    data = stream.getvalue()

    # Save with specific options
    options = SaveOptions()
    options.annotation_types = AnnotationType.AREA
    annotator.save("filtered.pdf", save_options=options)

save

Saves document after adding, updating or removing annotations.

Learn more about saving annotated documents.

def save(self, document):
    ...
Parameter Type Description
document io.RawIOBase The output stream.

Example

import io
from groupdocs.annotation import Annotator

with Annotator("document.pdf") as annotator:
    # add annotations as needed, e.g., annotator.add(area)
    buf = io.BytesIO()
    annotator.save(buf)  # BytesIO is updated after save
    data = buf.getvalue()

save

Saves the document after adding, updating, or removing annotations.

Learn more about saving annotated documents.

def save(self, file_path):
    ...
Parameter Type Description
file_path str The output file path.

Example

import io
from groupdocs.annotation import Annotator

with Annotator("document.pdf") as annotator:
    # add annotations here, e.g., annotator.add(area)
    buf = io.BytesIO()
    annotator.save(buf)  # BytesIO is updated after save
    data = buf.getvalue()

save

Saves document after adding, updating or removing annotations.

Learn more about saving annotated documents

def save(self, document, save_options):
    ...
Parameter Type Description
document io.RawIOBase The output stream or file path where the annotated document will be saved.
save_options SaveOptions The save options that control which pages or annotation types are saved.

Example

import io
from groupdocs.annotation import Annotator
from groupdocs.annotation.options import SaveOptions, AnnotationType

# Save to a stream
with Annotator("document.pdf") as annotator:
    # add annotations here
    buf = io.BytesIO()
    annotator.save(buf)                # BytesIO is updated after save
    data = buf.getvalue()

# Save to a file with filtering options
options = SaveOptions()
options.annotation_types = AnnotationType.AREA   # render only area annotations
options.first_page = 1                           # 1‑based page index
options.last_page = 2
with Annotator("document.pdf") as annotator:
    # add annotations here
    annotator.save("filtered.pdf", saveOptions=options)

save

Saves document after adding, updating or removing annotations.

def save(self, file_path, save_options):
    ...
Parameter Type Description
file_path str The output file path.
save_options SaveOptions The save options.

Example

import io
from groupdocs.annotation import Annotator
from groupdocs.annotation.options import SaveOptions, AnnotationType

# Save to a stream
with Annotator("document.pdf") as annotator:
    # add annotations here
    buffer = io.BytesIO()
    annotator.save(buffer)  # buffer now contains the PDF bytes
    data = buffer.getvalue()

# Save with options (filter by type and page range)
with Annotator("document.pdf") as annotator:
    # add annotations here
    options = SaveOptions()
    options.annotation_types = AnnotationType.AREA  # render only area annotations
    options.first_page = 1  # 1‑based page numbers
    options.last_page = 2
    annotator.save("filtered.pdf", save_options=options)

See Also