save method

save

Saves the document data to the underlying stream.

Learn more about saving the documents: https://docs.groupdocs.com/display/watermarknet/Saving+documents.

def save(self):
    ...

Example

from groupdocs.watermark import Watermarker
from groupdocs.watermark.search.search_criteria import TextSearchCriteria

with Watermarker(r"D:\\test.msg") as watermarker:
    criteria = TextSearchCriteria("test", False)
    watermarks = watermarker.search(criteria)
    watermarker.remove(watermarks)
    watermarker.save()

save

Saves the document to the specified file location.

Learn more about saving the documents: https://docs.groupdocs.com/display/watermarknet/Saving+documents.

def save(self, file_path):
    ...
Parameter Type Description
file_path str The file path to save the document data to.

Example

from groupdocs.watermark import Watermarker
from groupdocs.watermark.watermarks import TextWatermark, Font

def add_and_save():
    with Watermarker("input.pdf") as watermarker:
        watermark = TextWatermark("top secret", Font("Arial", 36))
        watermarker.add(watermark)
        watermarker.save("output.pdf")

save

Saves the document to the specified stream.

Learn more about saving the documents at https://docs.groupdocs.com/display/watermarknet/Saving+documents.

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

Example

from io import BytesIO
from groupdocs.watermark import Watermarker
from groupdocs.watermark.watermarks import TextWatermark
from groupdocs.watermark.watermarks import Font

with Watermarker("input.pdf") as watermarker:
    watermark = TextWatermark("top secret", Font("Arial", 36))
    watermarker.add(watermark)
    stream = BytesIO()
    watermarker.save(stream)
    # `stream` now contains the saved PDF bytes

save

Saves the document data to the underlying stream using save options.

Learn more about saving the documents.

def save(self, options):
    ...
Parameter Type Description
options SaveOptions Additional options to use when saving a document.

Example

from groupdocs.watermark import Watermarker
from groupdocs.watermark.options import SaveOptions
from groupdocs.watermark.watermarks import TextWatermark
from groupdocs.watermark.watermarks import Font

with Watermarker("input.pdf") as watermarker:
    watermark = TextWatermark("top secret", Font("Arial", 36))
    watermarker.add(watermark)
    watermarker.save(SaveOptions())

save

Saves the document to the specified file location using save options.

Learn more about saving the documents: https://docs.groupdocs.com/display/watermarknet/Saving+documents.

def save(self, file_path, options):
    ...
Parameter Type Description
file_path str The file path to save the document data to.
options SaveOptions Additional options to use when saving a document.

Example

from groupdocs.watermark import Watermarker
from groupdocs.watermark.watermarks import TextWatermark
from groupdocs.watermark.watermarks import Font
from groupdocs.watermark.options import SaveOptions

with Watermarker("input.pdf") as watermarker:
    watermark = TextWatermark("top secret", Font("Arial", 36))
    watermarker.add(watermark)
    watermarker.save("output.pdf", SaveOptions())

save

Saves the document to the specified stream using save options.

Learn more about saving the documents at the GroupDocs documentation.

def save(self, document, options):
    ...
Parameter Type Description
document io.RawIOBase The stream to save the document data to.
options SaveOptions Additional options to use when saving a document.

Example

from io import BytesIO
from groupdocs.watermark import Watermarker
from groupdocs.watermark.options import SaveOptions
from groupdocs.watermark.watermarks import TextWatermark
from groupdocs.watermark.watermarks import Font

def add_watermark_and_save():
    with Watermarker("input.pdf") as watermarker:
        watermark = TextWatermark("top secret", Font("Arial", 36))
        watermarker.add(watermark)

        stream = BytesIO()
        watermarker.save(stream, SaveOptions())
        # stream now contains the saved PDF data
        # e.g., write to a file
        with open("output.pdf", "wb") as f:
            f.write(stream.getvalue())

if __name__ == "__main__":
    add_watermark_and_save()

See Also