Sign document with ordering the signatures
Leave feedback
com.groupdocs.signature provides with SignOptions property ZOrder that expects integer values as Z-order position. The signatures with a higher number of this property will be displayed above the others.
Here are the steps to manually adjust the ordering of signatures on the document page with com.groupdocs.signature:
Create a new instance of Signature class and pass the source document path as a constructor parameter.
Instantiate the SignOptions object with the required options and set the ZOrder property.
This example adds a barcode and a QR code that overlap. The barcode has the higher ZOrder, so it is drawn on top.
Signaturesignature=newSignature("sample.pdf");try{// create several signatures that intersect
// #1 barcode options: this signature is placed on top
BarcodeSignOptionsoptions1=newBarcodeSignOptions("12345678");options1.setEncodeType(BarcodeTypes.Code128);options1.setLeft(100);options1.setTop(100);options1.setWidth(100);options1.setHeight(100);options1.setZOrder(2);// #2 QR code options: this signature is placed below
QrCodeSignOptionsoptions2=newQrCodeSignOptions("12345678");options2.setEncodeType(QrCodeTypes.QR);options2.setLeft(150);options2.setTop(150);options2.setZOrder(1);List<SignOptions>options=newArrayList<SignOptions>();options.add(options1);options.add(options2);// sign document to file
SignResultsignResult=signature.sign("signed.pdf",options);System.out.println("Source document signed successfully with "+signResult.getSucceeded().size()+" signature(s).");}finally{signature.dispose();}
More resources
GitHub Examples
You may easily run the code above and see the feature in action in our GitHub examples: