List of usage examples for com.lowagie.text.pdf PdfSignature put
public void put(PdfName key, PdfObject object)
PdfObject as value with the specified PdfName as key in this map. From source file:eu.europa.ec.markt.dss.signature.pdf.itext.ITextPDFDocTimeSampService.java
License:Open Source License
@SuppressWarnings({ "unchecked", "rawtypes" })
private PdfStamper prepareStamper(InputStream pdfData, OutputStream output, SignatureParameters parameters)
throws IOException {
try {// www. ja va 2s. c om
PdfReader reader = new PdfReader(pdfData);
PdfStamper stamper = PdfStamper.createSignature(reader, output, '\0', null, true);
PdfSignatureAppearance appearance = stamper.getSignatureAppearance();
appearance.setAcro6Layers(true);
appearance.setRender(PdfSignatureAppearance.SignatureRenderDescription);
PdfSignature dic = new PdfSignature(PdfName.ADOBE_PPKLITE, new PdfName("ETSI.RFC3161"));
// defined in ETSI TS 102 778-4 A.2
dic.put(PdfName.TYPE, new PdfName("DocTimeStamp"));
Calendar cal = Calendar.getInstance();
if (parameters.getSigningDate() != null) {
cal.setTime(parameters.getSigningDate());
appearance.setSignDate(cal);
}
dic.setDate(new PdfDate(cal));
appearance.setCryptoDictionary(dic);
int csize = getSignatureSize();
HashMap exc = new HashMap();
exc.put(PdfName.CONTENTS, new Integer(csize * 2 + 2));
appearance.preClose(exc);
return stamper;
} catch (DocumentException e) {
throw new IOException(e);
}
}
From source file:eu.europa.ec.markt.dss.signature.pdf.ITextPDFDocTimeSampService.java
License:Open Source License
@SuppressWarnings({ "unchecked", "rawtypes" })
private PdfStamper prepareStamper(InputStream pdfData, OutputStream output, SignatureParameters parameters)
throws IOException, DocumentException {
PdfReader reader = new PdfReader(pdfData);
PdfStamper stp = PdfStamper.createSignature(reader, output, '\0', null, true);
PdfSignatureAppearance sap = stp.getSignatureAppearance();
sap.setAcro6Layers(true);// ww w .j av a 2s.com
sap.setRender(PdfSignatureAppearance.SignatureRenderDescription);
PdfSignature dic = new PdfSignature(PdfName.ADOBE_PPKLITE, new PdfName("ETSI.RFC3161"));
// defined in ETSI TS 102 778-4 A.2
dic.put(PdfName.TYPE, new PdfName("DocTimeStamp"));
Calendar cal = Calendar.getInstance();
if (parameters.getSigningDate() != null) {
cal.setTime(parameters.getSigningDate());
sap.setSignDate(cal);
}
dic.setDate(new PdfDate(cal));
sap.setCryptoDictionary(dic);
int csize = getSignatureSize();
HashMap exc = new HashMap();
exc.put(PdfName.CONTENTS, new Integer(csize * 2 + 2));
sap.preClose(exc);
return stp;
}