Quick Start Guide

This guide gives a quick overview of how to set up and start using GroupDocs.Signature for Python via .NET. The library adds, finds, verifies, updates and removes electronic signatures in PDF, Word, Excel, PowerPoint, OpenDocument and image files with a few lines of code.

Prerequisites

To proceed, make sure you have:

  1. A configured environment as described in the System Requirements topic. On Linux and macOS this includes a few system packages.
  2. Optionally, a Temporary License to test all the product features. Without a license the library works in evaluation mode: it processes documents of up to two pages and adds an evaluation line to every page it signs. See Licensing.

Set Up Your Development Environment

For best practices, use a virtual environment to manage dependencies. Learn more in the Create and Use Virtual Environments guide.

Create and Activate a Virtual Environment

Create a virtual environment:

py -m venv .venv
python3 -m venv .venv
python3 -m venv .venv

Activate it:

.venv\Scripts\activate
source .venv/bin/activate
source .venv/bin/activate

Install the groupdocs-signature-net Package

py -m pip install groupdocs-signature-net
python3 -m pip install groupdocs-signature-net
python3 -m pip install groupdocs-signature-net

See Installation for pinning a version and for installing without access to PyPI.

Example 1: Sign a PDF with a Text Signature

Open a document, describe the signature with TextSignOptions, and save the signed copy.

from groupdocs.signature import Signature
from groupdocs.signature.options import TextSignOptions

def sign_pdf_with_text_signature():
    # Open the document; the with-block releases the file when it ends
    with Signature("sample.pdf") as signature:
        # A text signature 100 pixels from the left and top edges of the first page
        options = TextSignOptions("John Smith")
        options.left = 100
        options.top = 100

        # Sign and save the result to a new file; the source stays unchanged
        result = signature.sign("signed_sample.pdf", options)
        print(f"Signatures added: {len(result.succeeded)}")

if __name__ == "__main__":
    sign_pdf_with_text_signature()
sample.pdf is the sample file used in this example. Click here to download it.
Binary file (PDF, 125 KB)

Download full output

Example 2: Search a Document for Signatures

Find the signatures a document already carries. search takes a list of search options, one per signature type to look for, and returns them in result.signatures.

from groupdocs.signature import Signature
from groupdocs.signature.options import TextSearchOptions

def search_document_for_signatures():
    with Signature("signed.pdf") as signature:
        # Look for text signatures on every page
        result = signature.search([TextSearchOptions()])
        for found in result.signatures:
            print(f"Text signature '{found.text}' on page {found.page_number}")

if __name__ == "__main__":
    search_document_for_signatures()
signed.pdf is the sample file used in this example. Click here to download it.
Text signature 'John Smith' on page 1

Download full output

Example 3: Verify a Signature

Check that a document carries the signature you expect. Verification succeeds when a text signature with exactly this text is found.

from groupdocs.signature import Signature
from groupdocs.signature.options import TextVerifyOptions

def verify_text_signature():
    with Signature("signed.pdf") as signature:
        options = TextVerifyOptions("John Smith")
        result = signature.verify(options)
        print(f"Document is signed by John Smith: {result.is_valid}")

if __name__ == "__main__":
    verify_text_signature()
signed.pdf is the sample file used in this example. Click here to download it.
Document is signed by John Smith: True

Download full output

Run the Examples

Save each example to its own .py file next to the sample files. Your folder should look similar to this:

📂 demo-app
 ├──sign_pdf_with_text_signature.py
 ├──search_document_for_signatures.py
 ├──verify_text_signature.py
 ├──sample.pdf
 └──signed.pdf

Run an example from that folder:

py sign_pdf_with_text_signature.py
python3 sign_pdf_with_text_signature.py
python3 sign_pdf_with_text_signature.py

When you are done, deactivate the virtual environment by running deactivate or closing your shell.

Apply a License

Set the GROUPDOCS_LIC_PATH environment variable to the full path of your license file, and the license is applied automatically when groupdocs.signature is imported. No code is needed. Alternatively, apply it in code once, before any other call:

from groupdocs.signature import License

License().set_license("/path/to/GroupDocs.Signature.lic")

The Licensing topic covers both ways and the metered license.

Next Steps

After completing the basics, explore additional resources: