private byte[] getContents(COSFilterInputStream fis) throws IOException { ByteArrayOutputStream byteOS = new ByteArrayOutputStream(1024); byte[] buffer = new byte[1024]; int c; while ((c = fis.read(buffer)) != -1) { // Filter < and ( if(buffer[0]==0x3C || buffer[0]==0x28) { byteOS.write(buffer, 1, c); } // Filter > and ) else if(buffer[c-1]==0x3E || buffer[c-1]==0x29) { byteOS.write(buffer, 0, c-1); } else { byteOS.write(buffer, 0, c); } } fis.close(); return COSString.parseHex(byteOS.toString("ISO-8859-1")).getBytes(); }
private byte[] getContents(COSFilterInputStream fis) throws IOException { ByteArrayOutputStream byteOS = new ByteArrayOutputStream(1024); byte[] buffer = new byte[1024]; int c; while ((c = fis.read(buffer)) != -1) { // Filter < and ( if(buffer[0]==0x3C || buffer[0]==0x28) { byteOS.write(buffer, 1, c); } // Filter > and ) else if(buffer[c-1]==0x3E || buffer[c-1]==0x29) { byteOS.write(buffer, 0, c-1); } else { byteOS.write(buffer, 0, c); } } fis.close(); return COSString.parseHex(byteOS.toString("ISO-8859-1")).getBytes(); }
private byte[] getContents(COSFilterInputStream fis) throws IOException { ByteArrayOutputStream byteOS = new ByteArrayOutputStream(1024); byte[] buffer = new byte[1024]; int c; while ((c = fis.read(buffer)) != -1) { // Filter < and ( if(buffer[0]==0x3C || buffer[0]==0x28) { byteOS.write(buffer, 1, c); } // Filter > and ) else if(buffer[c-1]==0x3E || buffer[c-1]==0x29) { byteOS.write(buffer, 0, c-1); } else { byteOS.write(buffer, 0, c); } } fis.close(); return COSString.parseHex(byteOS.toString("ISO-8859-1")).getBytes(); }
/** * Return the signed content of the document. This is not a PDF file, nor is it the PDF file * before signing, it is the byte sequence made of the input minus the area where the signature * bytes will be. See "The ByteRange and signature value" in the document * <a href="https://www.adobe.com/devnet-docs/acrobatetk/tools/DigSig/Acrobat_DigitalSignatures_in_PDF.pdf#page=5">Digital * Signatures in a PDF</a>. * * @param pdfFile The signed pdf file as InputStream * @return a byte array containing only the signed part of the content * @throws IOException if the pdfFile can't be read */ public byte[] getSignedContent(InputStream pdfFile) throws IOException { COSFilterInputStream fis=null; try { fis = new COSFilterInputStream(pdfFile,getByteRange()); return fis.toByteArray(); } finally { if (fis != null) { fis.close(); } } }
/** * Return the signed content of the document. This is not a PDF file, nor is it the PDF file * before signing, it is the byte sequence made of the input minus the area where the signature * bytes will be. See "The ByteRange and signature value" in the document * <a href="https://www.adobe.com/devnet-docs/acrobatetk/tools/DigSig/Acrobat_DigitalSignatures_in_PDF.pdf#page=5">Digital * Signatures in a PDF</a>. * * @param pdfFile The signed pdf file as byte array * @return a byte array containing only the signed part of the content * @throws IOException if the pdfFile can't be read */ public byte[] getSignedContent(byte[] pdfFile) throws IOException { COSFilterInputStream fis=null; try { fis = new COSFilterInputStream(pdfFile,getByteRange()); return fis.toByteArray(); } finally { if (fis != null) { fis.close(); } } }