List of usage examples for com.lowagie.text.pdf PdfReader PdfReader
public PdfReader(PdfReader reader)
From source file:util.PdfUtil.java
License:Open Source License
public String processText(byte[] pdfBytes) throws RedbasinException { try {/*from w w w . j ava 2 s. co m*/ PdfReader reader = new PdfReader(pdfBytes); return processText(reader); } catch (Exception e) { throw new RedbasinException("Come PdfReader bytes error", e); } }
From source file:vn.vfossa.signature.PdfContent.java
License:Open Source License
public PdfContent(String path) throws Exception { this.path = path; content = new PdfReader(path); }
From source file:vn.vfossa.signature.PdfContent.java
License:Open Source License
public PdfContent(String path, byte[] byteArrOfFile) throws IOException { this.path = path; File file = new File(path); FileOutputStream fos = new FileOutputStream(file); fos.write(byteArrOfFile);/*from www . ja v a 2 s . c om*/ fos.close(); content = new PdfReader(path); }
From source file:vn.vfossa.signature.PdfContent.java
License:Open Source License
@Override public void addSignature(X509Certificate certificate, PrivateKey key) throws Exception { // TODO Auto-generated method stub Certificate cer[] = { certificate }; for (int index = path.length() - 1; index >= 0; index--) if (path.charAt(index) == '.') { signedPath = path.substring(0, index) + "_signed" + path.substring(index); break; }//from ww w . j av a2 s. co m File file = new File(signedPath); FileOutputStream out = new FileOutputStream(file); int numOfPages = content.getNumberOfPages(); int numOfSignatures = content.getAcroFields().getSignatureNames().size() + 1; PdfStamper stp = PdfStamper.createSignature(content, out, '\0', null, true); PdfSignatureAppearance sap = stp.getSignatureAppearance(); int m = (numOfPages - 1) * 5 + (numOfSignatures - 1) * 200; try { Calendar ca = Calendar.getInstance(); ca.setTime(new Date()); sap.setSignDate(ca); } catch (Exception ex) { ex.printStackTrace(); } sap.setCrypto(key, cer, null, PdfSignatureAppearance.WINCER_SIGNED); sap.setVisibleSignature(new com.lowagie.text.Rectangle(m, 0, m + 200, 30), 1, null); stp.close(); //Files.delete(Paths.get(path)); content = new PdfReader(signedPath); }