Sign document with Stamp signature - advanced
Leave feedback
GroupDocs.Signature provides StampSignOptions class with additional properties to specify different options for Stamp Signature. This signature type implements stamps with different implementation, forms, lines etc. Each Stamp option contains inner and outer lines. Inner lines represent vertical lines inside the stamp, when outer lines represent circles (or rectangles based on stamp type) around stamp with own text, border settings, background etc
Here are the steps to add Stamp signature into document with GroupDocs.Signature:
Create new instance of Signature class and pass source document path as a constructor parameter.
Instantiate the StampSignOptions object according to your requirements and specify Text Signature options.
Analyze SignResult result to check newly created signatures if needed.
This example shows how to add Stamp signature to document.
Signaturesignature=newSignature("sample.pdf");// setup options with text of signature
StampSignOptionssignOptions=newStampSignOptions();signOptions.setHeight(300);signOptions.setWidth(300);signOptions.setVerticalAlignment(VerticalAlignment.Bottom);signOptions.setHorizontalAlignment(HorizontalAlignment.Right);Paddingpadding=newPadding();padding.setRight(10);padding.setBottom(10);signOptions.setMargin(padding);Backgroundbackground=newBackground();background.setColor(Color.ORANGE);signOptions.setBackground(background);signOptions.setBackgroundColorCropType(StampBackgroundCropType.OuterArea);signOptions.setImageFilePath(Constants.ImageStamp);signOptions.setBackgroundImageCropType(StampBackgroundCropType.InnerArea);signOptions.setAllPages(true);//add few outer round lines
StampLineouterLine1=newStampLine();outerLine1.setText("* European Union *");outerLine1.setTextRepeatType(StampTextRepeatType.FullTextRepeat);SignatureFontsignatureFont1=newSignatureFont();signatureFont1.setSize(12);signatureFont1.setFamilyName("Arial");outerLine1.setFont(signatureFont1);outerLine1.setHeight(30);outerLine1.setTextBottomIntent(6);outerLine1.setTextColor(Color.WHITE);outerLine1.setBackgroundColor(Color.BLUE);signOptions.getOuterLines().add(outerLine1);StampLineouterLine2=newStampLine();outerLine2.setHeight(2);outerLine2.setBackgroundColor(Color.WHITE);signOptions.getOuterLines().add(outerLine2);StampLineouterLine3=newStampLine();outerLine3.setText("* Entrepreneur *");outerLine3.setTextColor(Color.BLUE);outerLine3.setTextRepeatType(StampTextRepeatType.FullTextRepeat);SignatureFontsignatureFont3=newSignatureFont();signatureFont3.setSize(15);outerLine3.setFont(signatureFont3);outerLine3.setHeight(30);outerLine3.setTextBottomIntent(8);BorderinnerBorder3=newBorder();innerBorder3.setColor(Color.DARK_GRAY);innerBorder3.setDashStyle(DashStyle.Dot);outerLine3.setInnerBorder(innerBorder3);BorderouterBorder3=newBorder();outerBorder3.setColor(Color.BLUE);outerLine3.setOuterBorder(outerBorder3);signOptions.getOuterLines().add(outerLine3);//Inner square lines
StampLineinnerLine1=newStampLine();innerLine1.setText("John");innerLine1.setTextColor(Color.RED);SignatureFontsignFont1=newSignatureFont();signFont1.setSize(20);signFont1.setBold(true);innerLine1.setFont(signFont1);innerLine1.setHeight(40);signOptions.getInnerLines().add(innerLine1);StampLineinnerLine2=newStampLine();innerLine2.setText("Smith");innerLine2.setTextColor(Color.RED);SignatureFontsignFont2=newSignatureFont();signFont2.setSize(20);signFont2.setBold(true);innerLine2.setFont(signFont2);innerLine2.setHeight(40);signOptions.getInnerLines().add(innerLine2);StampLineinnerLine3=newStampLine();innerLine3.setText("SSN 1230242424");innerLine3.setTextColor(Color.MAGENTA);SignatureFontsignFont3=newSignatureFont();signFont3.setSize(12);signFont3.setBold(true);innerLine3.setFont(signFont3);innerLine3.setHeight(40);signOptions.getInnerLines().add(innerLine3);// sign document
SignResultsignResult=signature.sign("signed.pdf",signOptions);// analyzing result
System.out.print("List of newly created signatures:");intnumber=1;for(BaseSignaturetemp:signResult.getSucceeded()){System.out.print("Signature #"+number+++": Type: "+temp.getSignatureType()+" Id:"+temp.getSignatureId()+",Location: "+temp.getLeft()+"x"+temp.getTop()+". Size: "+temp.getWidth()+"x"+temp.getHeight());}
More resources
GitHub Examples
You may easily run the code above and see the feature in action in our GitHub examples:
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.
Was this page helpful?
Any additional feedback you'd like to share with us?
Please tell us how we can improve this page.
Thank you for your feedback!
We value your opinion. Your feedback will help us improve our documentation.