Locating signature on page with different measure units

GroupDocs.Signature supports locating signature on document page with different measure units. Enumeration MeasureType handles following types

  • MeasureType.Pixels allows to locate signature position and size with pixels (default value)

  • MeasureType.Millimeters allows to locate signature on page and setup size by setting millimeters

  • MeasureType.Percents allows to locate signature position, size with percentage of page size
       Here are the steps to locate and size signature area with different measure unit types:

  • Set property LocationMeasureType with of one values above to specify how to implement values in properties LeftTop

  • Set property SizeMeasureType with of one values above to specify how to implement size of signature values in properties WidthHeight

  • Set property MarginMeasureType with of one values above to specify how to implement values in property Margin

Set signature positioning in millimeters

This example shows how to specify positioning in millimeters.

 using (Signature signature = new Signature("sample.docx"))
 {
     // create barcode option with predefined barcode text
     BarcodeSignOptions options = new BarcodeSignOptions("12345678")
     {
         // setup Barcode encoding type
         EncodeType = BarcodeTypes.Code128,
         // set signature position in absolute position
         LocationMeasureType = MeasureType.Millimeters,
         Left = 40,
         Top = 50,
         // set signature area in millimeters
         SizeMeasureType = MeasureType.Millimeters,
         Width = 20,
         Height = 10,
         // set margin in millimeters
         MarginMeasureType = MeasureType.Millimeters,
         Margin = new Padding() { Left =5, Top = 5, Right = 5 },
     };
     // sign document to file
     signature.Sign("signedSample.docx", options);
 }

Set signature positioning in percents

This example shows how to set different positioning properties in percentage.

 using (Signature signature = new Signature("sample.pdf"))
 {
     // create barcode option with predefined barcode text
     BarcodeSignOptions options = new BarcodeSignOptions("12345678")
     {
         // setup Barcode encoding type
         EncodeType = BarcodeTypes.Code128,
         // set signature position in absolute position
         LocationMeasureType = MeasureType.Percents,
         Left = 5,
         Top = 5,
         // set signature area in millimeters
         SizeMeasureType = MeasureType.Percents,
         Width = 10,
         Height = 5,
         // set margin in millimeters
         MarginMeasureType = MeasureType.Percents,
         Margin = new Padding() { Left = 1, Top = 1, Right = 1 },
     };
     // sign document to file
     signature.Sign("signed.docx", options);
 }

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.