Sign document with ordering the signatures

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.
  • Call sign method of  Signature class instance and pass SignOptions to it.

Sign document with ordered signatures

This example adds a barcode and a QR code that overlap. The barcode has the higher ZOrder, so it is drawn on top.

Signature signature = new Signature("sample.pdf");
try {
    // create several signatures that intersect

    // #1 barcode options: this signature is placed on top
    BarcodeSignOptions options1 = new BarcodeSignOptions("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
    QrCodeSignOptions options2 = new QrCodeSignOptions("12345678");
    options2.setEncodeType(QrCodeTypes.QR);
    options2.setLeft(150);
    options2.setTop(150);
    options2.setZOrder(1);

    List<SignOptions> options = new ArrayList<SignOptions>();
    options.add(options1);
    options.add(options2);

    // sign document to file
    SignResult signResult = 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:

Free Online App

Along with full-featured Java 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.

Close
Loading

Analyzing your prompt, please hold on...

An error occurred while retrieving the results. Please refresh the page and try again.