Sign Pdf documents with special appearance
GroupDocs.Signature contains classes that implements for Pdf document special signature appearances.
Base signature options SignOptions contains property SignOptions.Appearance that expects instance of the following classes
- PdfTextAnnotationAppearance class implements for Pdf documents signature as annotation area. Note that TextSignOptions.SignatureImplementation property must be set to TextSignatureImplementation.Annotation
- PdfTextStickerAppearance class implements for Pdf documents signature as small sticker. Note that TextSignOptions.SignatureImplementation property must be set to TextSignatureImplementation.Sticker
Here are the steps to setup special Pdf document Text signature appearance with GroupDocs.Signature:
- Create new instance of Signature class and pass source document path as a constructor parameter.
- Compose object of TextSignOptions object with all required additional options.
- Set TextSignOptions.Appearance property with PdfTextAnnotationAppearance object and set its properties
- Call Sign method of Signature class instance and pass TextSignOptions to it.
- Analyze SignResult result to check newly created signatures if needed.
Sign Pdf document with Text signature Annotation appearance
This example shows how to add Text signature to Pdf document with annotation look. See SignResult
using (Signature signature = new Signature("sample.pdf"))
{
TextSignOptions options = new TextSignOptions("John Smith")
{
// set signature position
Left = 100,
Top = 100,
// set signature rectangle
Width = 100,
Height = 30,
// setup proper signature implementation
SignatureImplementation = TextSignatureImplementation.Annotation,
Appearance = new PdfTextAnnotationAppearance()
{
Border = new Border()
{
Color = Color.Blue,
DashStyle = DashStyle.Dash,
Weight = 2,
},
BorderEffect = PdfTextAnnotationBorderEffect.Cloudy,
BorderEffectIntensity = 2,
HCornerRadius = 10,
// text content of an annotation
Contents = "Sample",
Subject = "Sample subject",
Title = "Sample Title",
},
// set signature alignment
VerticalAlignment = Domain.VerticalAlignment.Bottom,
HorizontalAlignment = Domain.HorizontalAlignment.Right,
Margin = new Padding() { Bottom = 20, Right = 20 },
// set text color and Font
ForeColor = Color.Red,
Font = new SignatureFont { Size = 12, FamilyName = "Comic Sans MS" },
};
// sign document to file
signature.Sign("signedAnnotation.pdf", options);
}
Sign Pdf document with Text signature Sticker appearance
This example shows how to add Text signature to Pdf document with sticker look. See SignResult
using (Signature signature = new Signature(filePath))
{
TextSignOptions options = new TextSignOptions("John Smith")
{
// set signature position
Left = 100,
Top = 100,
// set signature rectangle
Width = 100,
Height = 30,
// setup proper signature implementation
SignatureImplementation = TextSignatureImplementation.Sticker,
Appearance = new PdfTextStickerAppearance()
{
// select sticker icon
Icon = PdfTextStickerIcon.Star,
// setup if popup annotation will be opened by default
Opened = false,
// text content of an annotation
Contents = "Sample",
Subject = "Sample subject",
Title = "Sample Title"
},
// set signature alignment
VerticalAlignment = Domain.VerticalAlignment.Bottom,
HorizontalAlignment = Domain.HorizontalAlignment.Right,
Margin = new Padding() { Bottom = 20, Right = 20 },
// set text color and Font
ForeColor = Color.Red,
Font = new SignatureFont { Size = 12, FamilyName = "Comic Sans MS" },
};
// sign document to file
signature.Sign(outputFilePath, options);
}
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.