/* * To change this template, choose Tools | Templates * and open the template in the editor. */ package com.fp.firma.applet; import java.io.FileInputStream; import java.io.FileNotFoundException; import java.io.FileOutputStream; import java.io.InputStream; import com.fp.firma.common.CertificateUtils; import com.itextpdf.text.Rectangle; /** * * @author dcruz */ public class PruebaFirma { // @Test public static void main(String[] args){ try { InputStream is = new FileInputStream("C:\\Users\\abenalcazar\\dwhelper\\Downloads\\Tutorial_de_Maven_3_Erick_Camacho.pdf"); String password = "Password#1"; byte[] array = CertificateUtils.sign(is, null, password, "Firmado digitalmente", "Por firmar", Boolean.FALSE, Boolean.FALSE, new Rectangle(50, 50, 200, 200), 1, "Firma 2", "2"); is.close(); System.out.println("Tam array "+ array != null ? array.length:0); FileOutputStream os = new FileOutputStream("C:\\Users\\abenalcazar\\dwhelper\\Downloads\\Tutorial_de_Maven_3_Erick_Camacho.pdf"); os.write(array); os.flush(); os.close(); } catch (FileNotFoundException e) { e.printStackTrace(); } catch (Throwable e){ e.printStackTrace(); } } }