GroupDocsGists
10/24/2017 - 1:10 PM

Examples-src-main-java-com-groupdocs-signature-examples-OtherOperations-alignSignatureOnDocPage.java

// 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 digital signature options
PdfSignDigitalOptions signOptions = new PdfSignDigitalOptions(new FileDescription(CommonUtilities.getCertificatePath("acer.pfx")), CommonUtilities.getImagesPath("sign.png"));
signOptions.setPassword("1234567890");
// image position to locate on right bottom corner with small margins
signOptions.setHorizontalAlignment(HorizontalAlignment.Right); // only Margin.Right value will be used to shift the Signature rectangle
signOptions.setVerticalAlignment(VerticalAlignment.Bottom); // only Margin.Bottom value will be used to shift the Signature rectangle
signOptions.getMargin().setRight(10);
signOptions.getMargin().setBottom(10);
// Page Number
signOptions.setDocumentPageNumber(1);
final SaveOptions saveOptions = new SaveOptions();
saveOptions.setOutputType(OutputType.String);
// sign document
String signedPath = handler.<String>sign(CommonUtilities.getStoragePath(fileName), signOptions, saveOptions);
System.out.println("Signed file path is: " + signedPath);