List of usage examples for com.lowagie.text.pdf PdfSignatureAppearance setReason
public void setReason(String reason)
From source file:sos.util.security.SOSPDFSignatur.java
License:Apache License
/** * PDF Signatur erzeugen/* w w w .j a va 2 s . c o m*/ * * @param privateKey Private Key * @param chain Certificate Chain * @param originalPdfName Original PDF Datei zur Signierung * @param outputPdfName Output (signierte) PDF Datei * @throws Exception */ public static void createSignatur(PrivateKey privateKey, Certificate[] chain, String originalPdfName, String outputPdfName) throws Exception { PdfReader reader = new PdfReader(originalPdfName); FileOutputStream fout = new FileOutputStream(outputPdfName); //createSignature(PdfReader reader, OutputStream os, char pdfVersion) //pdfVersion - the new pdf version or '\0' to keep the same version as // the original document PdfStamper stp = PdfStamper.createSignature(reader, fout, '\0'); PdfSignatureAppearance sap = stp.getSignatureAppearance(); //setCrypto(PrivateKey privKey, Certificate[] certChain, CRL[] crlList, PdfName filter) // CRL - certificate revocation lists (CRLs) that have different formats but important common uses. // For example, all CRLs share the functionality of listing revoked certificates, and can be queried on whether or not they list a given certificate. // PdfName // SELF_SIGNED - The self signed filter // VERISIGN_SIGNED - The VeriSign filter // WINCER_SIGNED - The Windows Certificate Security sap.setCrypto(privateKey, chain, null, PdfSignatureAppearance.SELF_SIGNED); //sap.setCrypto(privateKey, chain, null,PdfSignatureAppearance.WINCER_SIGNED); sap.setReason(SOSPDFSignatur.reason); sap.setContact(SOSPDFSignatur.contact); sap.setLocation(SOSPDFSignatur.location); //GregorianCalendar cal = new GregorianCalendar(); //sap.setSignDate(cal); // comment next line to have an invisible signature //setVisibleSignature(Rectangle pageRect, int page, String fieldName) //sap.setVisibleSignature(new Rectangle(100, 100, 200, 200), 1, null); //sap.setVisibleSignature(new Rectangle(100,100,200, 200), 1, null); if (SOSPDFSignatur.visible) {// todo //sap.setVisibleSignature(new Rectangle(200, 200, 400, 400), 1, null); } stp.close(); }