Generate signature preview
Leave feedback
On this page
GroupDocs.Signature PreviewSignatureOptionsΒ classΒ to specify different options to manage signatures preview generation process.
Here are the steps how to generate signature preview with GroupDocs.Signature:
- Instantiate the required SignOptionsΒ object with the settings you want to generate the preview
- Instantiate the PreviewSignatureOptionsΒ object with:
- delegate forΒ signatureΒ stream creation (see event handlerΒ CreateSignatureStream);
- image preview format - PNG / JPG / BMP,
- unique signature identifier.
NoteStream that were created byΒ CreateSignatureStream delegate will be disposed automatically once after generation of preview image. If you need to implement custom image preview stream disposing you have to pass additional argumentΒ ReleaseSignatureStreamΒ to clean up resources.
- Call the static methodΒ GenerateSignaturePreview method ofΒ SignatureΒ and passΒ PreviewSignatureOptionsΒ to it.
public static void GetPreview()
{
// Create QR code sign options
QrCodeSignOptions signOptions = new QrCodeSignOptions
{
EncodeType = QrCodeTypes.QR,
Data = new GroupDocs.Signature.Domain.Extensions.Address
{
Street = "221B Baker Street",
City = "London",
State = "NW",
ZIP = "NW16XE",
Country = "England"
},
HorizontalAlignment = HorizontalAlignment.Left,
VerticalAlignment = VerticalAlignment.Center,
Width = 100,
Height = 100,
Margin = new Padding(10)
};
// Create signature preview options
PreviewSignatureOptions previewOption = new PreviewSignatureOptions(
signOptions,
CreateSignatureStream,
ReleaseSignatureStream
)
{
SignatureId = Guid.NewGuid().ToString(),
PreviewFormat = PreviewSignatureOptions.PreviewFormats.JPEG
};
// Generate signature preview
Signature.GenerateSignaturePreview(previewOption);
}
private static Stream CreateSignatureStream(PreviewSignatureOptions previewOptions)
{
string imageFilePath =
$"signature-{previewOptions.SignatureId}-" +
$"{previewOptions.SignOptions.GetType().Name}.jpg";
return new FileStream(imageFilePath, FileMode.Create);
}
private static void ReleaseSignatureStream(PreviewSignatureOptions previewOptions,
Stream signatureStream)
{
signatureStream.Dispose();
Console.WriteLine(
$"Signature {previewOptions.SignatureId}-" +
$"{previewOptions.SignOptions.GetType().Name} is ready for preview"
);
}
To learn more about document eSign features, please refer to theΒ advanced usage section.
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
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.
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.