Locating signature with stretch mode

GroupDocs.Signature provides ability to stretch signature area along page width or height. Use enumeration StretchMode contains following values

  • None - no stretch will be applied
  • PageWidth -  to stretch signature area along page width
  • PageHeight - to stretch signature area along page height
  • PageArea - to stretch signature area along page width and height

Here are the steps to use stretch mode with adding text or images signatures into document with GroupDocs.Signature:

Locate Signature Area with Stretch Mode

This example shows how to locate signature with stretch mode.

using (Signature signature = new Signature("sample.pdf"))
{
    // define several signature options of different types and settings
    TextSignOptions textOptions = new TextSignOptions("This is test message")
    {
        AllPages = true,
        VerticalAlignment = VerticalAlignment.Top,
        Margin = new Padding(50),
        Stretch = StretchMode.PageWidth
    };
    BarcodeSignOptions barcodeOptions = new BarcodeSignOptions("123456")
    {
        AllPages = true,
        EncodeType = BarcodeTypes.Code128,
        VerticalAlignment = VerticalAlignment.Bottom,
        Margin = new Padding(50),
        Stretch = StretchMode.PageWidth
    };
    ImageSignOptions imageOptions = new ImageSignOptions()
    {
        AllPages = true,
        Stretch = StretchMode.PageHeight,
        HorizontalAlignment = HorizontalAlignment.Right,
        ImageFilePath = Constants.ImageHandwrite
    };

    // define list of signature options
    List<SignOptions> listOptions = new List<SignOptions>();
    listOptions.Add(textOptions);
    listOptions.Add(barcodeOptions);
    listOptions.Add(imageOptions);
    // 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.