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:
- Create new instance of Signature class and pass source document path as a constructor parameter.
- Instantiate the TextSignOptions or ImageSignOptions object with all required additional options and setup Stretch property
- Call Sign method of Signature class instance and the instance of signature options (ImageSignOptions for example) to it.
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:
- GroupDocs.Signature for .NET examples, plugins, and showcase
- GroupDocs.Signature for Java examples, plugins, and showcase
- Document Signature for .NET MVC UI Example
- Document Signature for .NET App WebForms UI Example
- Document Signature for Java App Dropwizard UI Example
- Document Signature for Java Spring UI Example
Free Online App
Along with full-featured .NET library we provide simple, but powerful free Apps.
You are welcome to eSign PDF, Word, Excel, PowerPoint documents with free to use online GroupDocs Signature App.