eSign Document with Image Signature

What is an Image Signature?

An image as a signature is an alternative way to put any presenting data in a visual form. This electronic signature type allows the creation of custom images with a company logo, sender’s initials, names and so forth.

Images

GroupDocs.Signature for Python via .NET provides the ImageSignOptions class to specify different settings for image signature such as image content by file or stream, location, colors and advanced effects.

Here are the steps to create an image signature on a document page:

  • Create a new instance of the Signature class and pass the source document path as a constructor parameter;
  • Instantiate the ImageSignOptions object according to your requirements and specify Image signature options;
  • Call the Sign method of the Signature class instance and pass the ImageSignOptions to it.

How to eSign Document with Image Signature

This example shows how to sign a PDF document with the image signature using Python:

from groupdocs.signature import Signature
from groupdocs.signature.options import ImageSignOptions

def sign_with_image_signature():
    with Signature("sample.pdf") as signature:
        # Create image signature options with the image file
        options = ImageSignOptions("signature.jpg")

        # Set signature position and size
        options.left = 100
        options.top = 400
        options.width = 120
        options.height = 100

        # Sign the document and save the result
        result = signature.sign("signed_image.pdf", options)
        print(f"Signed with {len(result.succeeded)} image signature(s)")

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

Download full output

Advanced Image Signature Options

You can customize the image signature further with additional options: alignment and margins, rotation, transparency and a border. When an alignment is set, it replaces the left or top coordinate, and the margin offsets the signature from the page edge.

from groupdocs.signature import Signature
from groupdocs.signature.options import ImageSignOptions
from groupdocs.signature.domain import (
    Border, DashStyle, HorizontalAlignment, Padding, VerticalAlignment)
from groupdocs.pydrawing import Color

def sign_with_image_signature_advanced():
    with Signature("sample.pdf") as signature:
        options = ImageSignOptions("signature.jpg")

        # Put the signature in the bottom right corner of the page
        options.width = 160
        options.height = 136
        options.horizontal_alignment = HorizontalAlignment.RIGHT
        options.vertical_alignment = VerticalAlignment.BOTTOM
        options.margin = Padding(right=40, bottom=60)

        # Rotate the image and make it 20% transparent
        options.rotation_angle = 10
        options.transparency = 0.2

        # Draw a dashed border around the image
        border = Border()
        border.color = Color.dark_green
        border.dash_style = DashStyle.DASH
        border.weight = 2
        border.visible = True
        options.border = border

        result = signature.sign("signed_image_advanced.pdf", options)
        print(f"Signed with {len(result.succeeded)} image signature(s)")

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

Download full output

Loading Image from Stream

You can also load the signature image from a stream. Keep the stream open until sign returns:

from groupdocs.signature import Signature
from groupdocs.signature.options import ImageSignOptions

def sign_with_image_from_stream():
    with Signature("sample.pdf") as signature:
        # Load the signature image from a stream
        with open("signature.jpg", "rb") as image_stream:
            options = ImageSignOptions(image_stream)
            options.left = 100
            options.top = 400
            options.width = 120
            options.height = 100

            result = signature.sign("signed_image_stream.pdf", options)
            print(f"Signed with {len(result.succeeded)} image signature(s)")

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

Download full output

Summary

This guide demonstrates how to use GroupDocs.Signature for Python via .NET to add image-based signatures to documents. It covers loading a document, configuring the image signature’s properties (such as size, position, and transparency), and saving the signed document. Advanced customization options, like adjusting image appearance and aligning the signature, are also discussed. For further insights, explore related document signing resources.

More Resources

GitHub Examples

You may easily run the code above and see the feature in action in our GitHub examples:

Free Online Apps

Along with the full-featured Python library, we provide simple but powerful free online apps.

To generate image signatures and/or sign your files with them for free, you can use the Generate Image online app.

To sign PDF, Word, Excel, PowerPoint, and other documents you can use the other online apps from the GroupDocs.Signature App Product Family.