Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save atirtahirgroupdocs/be1fa5228a2a3eb1f524827d78cb0eb5 to your computer and use it in GitHub Desktop.
Save atirtahirgroupdocs/be1fa5228a2a3eb1f524827d78cb0eb5 to your computer and use it in GitHub Desktop.
// For complete examples and data files, please go to https://github.com/groupdocs-signature/GroupDocs.Signature-for-Java
// setup Signature configuration
SignatureConfig signConfig = CommonUtilities.getConfiguration();
// instantiating the conversion handler
SignatureHandler<String> handler = new SignatureHandler<String>(signConfig);
// setup image signature options with relative path - image file stores in config.ImagesPath folder
PdfSignTextOptions signOptions = new PdfSignTextOptions("John Smith");
signOptions.setLeft(100);
signOptions.setTop(100);
signOptions.setHeight(200);
signOptions.setWidth(200);
// setup colors settings
signOptions.setBackgroundColor(Color.GRAY);
// setup text color
signOptions.setForeColor(Color.RED);
// setup Font options
signOptions.getFont().setBold(true);
signOptions.getFont().setItalic(true);
signOptions.getFont().setUnderline(true);
signOptions.getFont().setFontFamily("Arial");
signOptions.getFont().setFontSize(15);
//type of implementation
signOptions.setSignatureImplementation(PdfTextSignatureImplementation.Annotation);
// specify extended appearance options
PdfTextAnnotationAppearance appearance = new PdfTextAnnotationAppearance();
appearance.setBorderColor(Color.BLUE);
appearance.setBorderEffect(PdfTextAnnotationBorderEffect.Cloudy);
appearance.setBorderEffectIntensity(2);
appearance.setBorderStyle(PdfTextAnnotationBorderStyle.Dashed);
appearance.setHCornerRadius(10);
appearance.setBorderWidth(5);
appearance.setContents(signOptions.getText() + " content description");
appearance.setSubject("Appearance Subject");
appearance.setTitle("MrJohn Signature");
signOptions.setAppearance(appearance);
final SaveOptions saveOptions = new SaveOptions();
saveOptions.setOutputType(OutputType.String);
saveOptions.setOutputFileName("signed_output.pdf");
// sign document
String signedPath = handler.<String> sign(CommonUtilities.getStoragePath(fileName), signOptions,
saveOptions);
System.out.println("Signed file path is: " + signedPath);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment