{
File input = new File("/Users/nicola/Documents/rad-image/argo-installation-report.pdf");
File output = new File("/tmp/firmato.pdf");
File libSmartcard = new File("/opt/smartcard-aruba/libbit4xpki.dylib");
PadesSignatureEngine engine = new PadesSignatureEngine(libSmartcard);
// inserisci QUI il PIN della smartcard
engine.prepareSmartCardAndData("".toCharArray());
// CardReaders readers = new CardReaders();
// for(CardTerminal terminal : readers.getReaders())
// {
// System.out.println(terminal.getName());
// }
// for(CardTerminal terminal : readers.getReadersWithCard())
// {
// System.out.println(terminal.getName());
// SmartCard card = new SmartCard(terminal);
// IdentityPojo id = BeIDFileFactory.getIdentity(card);
// System.out.println(id.toString());
// AddressPojo address = BeIDFileFactory.getAddress(card);
// System.out.println(address);
// PhotoPojo photo = BeIDFileFactory.getPhoto(card);
// FileOutputStream fos = new FileOutputStream(PHOTO);
// fos.write(photo.getPhoto());
// fos.flush();
// fos.close();
// }
PadesSignatureEngine.PdfSignatureAppearanceInfo info = new PadesSignatureEngine.PdfSignatureAppearanceInfo();
info.location = "Luogo della firma.";
info.reason = "Motivo della firma.";
info.position = new Rectangle(36, 748, 144, 780);
info.page = 1;
engine.setAppearanceInfo(info);
// TSAClient tsa = engine.getTSAfromSmartcard();
// Usa Digistamp per ottenere un account di test per il rilascio di timestamp
TSAClient tsa = new TSAClientBouncyCastle("http://tsatest1.digistamp.com/tsa", "12345678", "12345678");
engine.setTsaClient(tsa);
engine.setUseInternetCrl(true);
engine.signDocument(input, output);
}