Example usage for com.itextpdf.text.pdf.security MakeSignature signDeferred

List of usage examples for com.itextpdf.text.pdf.security MakeSignature signDeferred

Introduction

In this page you can find the example usage for com.itextpdf.text.pdf.security MakeSignature signDeferred.

Prototype

public static void signDeferred(PdfReader reader, String fieldName, OutputStream outs,
        ExternalSignatureContainer externalSignatureContainer)
        throws DocumentException, IOException, GeneralSecurityException 

Source Link

Document

Signs a PDF where space was already reserved.

Usage

From source file:org.opencps.pki.PdfSigner.java

License:Open Source License

/**
 * Sign document with external signature container
 *///from w w w .  j a va 2s. c  om
protected Boolean signExternal(ExternalSignatureContainer container, String filePath)
        throws SignatureException {
    if (signatureFieldName == null || signatureFieldName.length() == 0) {
        throw new SignatureException("You must set signature field name before sign the document");
    }
    Boolean signed = false;
    try {
        OutputStream os = new FileOutputStream(getSignedFilePath());
        PdfReader reader = new PdfReader(filePath);
        if (!reader.isEncrypted()) {
            MakeSignature.signDeferred(reader, signatureFieldName, os, container);
            reader.close();
            os.close();
            signed = true;
        }
    } catch (Exception e) {
        throw new SignatureException(e.getMessage(), e);
    }
    return signed;
}