Locating signature with different alignments

View as MarkdownMarkdown

Set up your AI agent

Give your coding agent live access to the GroupDocs documentation and API reference through the GroupDocs Docs MCP server — no install, no API key. Learn more

claude mcp add --transport http groupdocs-docs https://docs.groupdocs.com/mcp

Also process documents locally

The GroupDocs.Signature MCP server lets your agent work with files on your machine; they are never uploaded. It needs the .NET 10 SDK or Docker.

claude mcp add groupdocs-signature -- dnx GroupDocs.Signature.Mcp --yes
Folders, licensing and more →

GroupDocs.Signature provides ability to align signature on page with horizontal and vertical alignment settings. Signature options that implement interface IAlignment contain following properties:

Here are the steps to align signature on page with GroupDocs.Signature:

  • Create a new instance of Signature class and pass source document path or stream as a constructor parameter.
  • Instantiate signature options (ImageSignOptions for example) with all required properties.
  • Set  HorizontalAlignment with one of enumeration value to align signature along page width
  • Set  VerticalAlignment with one of enumeration value to align signature along page height
  • Set  Margin property with required offsetfrom page border
  • Set  MarginMeasureType property with non default value if there is need to specify offset from page border in another measure units like millimeters and page percents (from 100% width and 100% height)
  • Call Sign method of Signature class instance and pass the instance of signature options (ImageSignOptions for example) to it.

This example shows how to locate signature with different alignments.

using (Signature signature = new Signature("sample.pdf"))
{
    // define qr-code size
    int qrWidth = 100;
    int qrHeight = 100;
    // define list of options
    List<SignOptions> listOptions = new List<SignOptions>();
    // walk through all alignment values to locate signature at all page alignment areas
    foreach (HorizontalAlignment horizontalAlignment in Enum.GetValues(typeof(HorizontalAlignment)))
    {
        foreach (VerticalAlignment verticalAlignment in Enum.GetValues(typeof(VerticalAlignment)))
        {
            if (verticalAlignment != VerticalAlignment.None && horizontalAlignment != HorizontalAlignment.None)
            {
                listOptions.Add(
                    new QrCodeSignOptions("Left-Top")
                    {
                    // set signature rectangle
                    Width = qrWidth,
                        Height = qrHeight,
                    // set signature alignment
                    HorizontalAlignment = horizontalAlignment,
                        VerticalAlignment = verticalAlignment,
                        Margin = new Padding(5),
                    });
            }
        }
    }
    // sign document to file
    signature.Sign("signed.pdf", listOptions);
}

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 .NET library, we provide simple but powerful free online apps.

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