Sample code for 30+ languages & platforms
Java

PDF List Unsigned Signature Fields

See more PDF Signatures Examples

Demonstrates how to list the unsigned signature fields in a PDF.

Note: This example requires Chilkat v9.5.0.90 or greater.

Chilkat Java Downloads

Chilkat2 Java
import com.chilkatsoft.chilkat2.ChilkatException;
import com.chilkatsoft.chilkat2.JsonObject;
import com.chilkatsoft.chilkat2.Pdf;

public class ChilkatExample {

    public static void main(String[] args) {
        // This example requires the Chilkat API to have been previously unlocked.
        // See Global Unlock Sample for sample code.

        Pdf pdf = new Pdf();

        // Load a PDF containing 2 remaining unsigned signature fields:
        try {
            pdf.loadFile("qa_data/pdf/doctor_patient_parent.pdf");
        } catch (ChilkatException e) {
            System.out.println(e.getLastErrorText());
            return;
        }

        // Note: This example requires Chilkat v9.5.0.90 or greater.
        JsonObject json = new JsonObject();
        pdf.getUnsignedSigFields(json);

        json.setEmitCompact(false);
        System.out.println(json.emit());

        // Result:
        // {
        //   "unsignedSigField": [
        //     "doctor_signature",
        //     "parent_signature"
        //   ]
        // }

        // To iterate over the field names:
        String strVal = "";

        int i = 0;
        int count_i = json.sizeOfArray("unsignedSigField");
        while (i < count_i) {
            json.setI(i);
            strVal = json.stringOf("unsignedSigField[i]");
            System.out.println(strVal);
            i = i + 1;
        }
    }
}