[jira] [Commented] (PDFBOX-1614) Digitally sign PDFs without file system access
[ https://issues.apache.org/jira/browse/PDFBOX-1614?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=14129782#comment-14129782 ] Andrei Solntsev commented on PDFBOX-1614: - Hi! Can you say when PDFBOX 2.0 will be released? We are waiting for this feature to be available. > Digitally sign PDFs without file system access > -- > > Key: PDFBOX-1614 > URL: https://issues.apache.org/jira/browse/PDFBOX-1614 > Project: PDFBox > Issue Type: Improvement > Components: Signing >Affects Versions: 1.8.1 >Reporter: Thierry Boschat >Assignee: Thomas Chojecki > Fix For: 2.0.0 > > > Hi I'm using pdfbox-1.8.1 to digitally sign PDFs. > I find the sample below to handle it. > But in this example I have to use a FileInputStream however I want to do it > only through streams (without any file system access). I tried to extends > FileInputStream to deal with it but I failed. Any tips for me about that > problem ? > Thanks. > File outputDocument = new File("resources/signed" + document.getName()); > FileInputStream fis = new FileInputStream(document); > FileOutputStream fos = new FileOutputStream(outputDocument); > int c; > while ((c = fis.read(buffer)) != -1) > { > fos.write(buffer, 0, c); > } > fis.close(); > fis = new FileInputStream(outputDocument); > // load document > PDDocument doc = PDDocument.load(document); > // create signature dictionary > PDSignature signature = new PDSignature(); > signature.setFilter(PDSignature.FILTER_ADOBE_PPKLITE); // default filter > // subfilter for basic and PAdES Part 2 signatures > signature.setSubFilter(PDSignature.SUBFILTER_ADBE_PKCS7_DETACHED); > signature.setName("signer name"); > signature.setLocation("signer location"); > signature.setReason("reason for signature"); > // the signing date, needed for valid signature > signature.setSignDate(Calendar.getInstance()); > // register signature dictionary and sign interface > doc.addSignature(signature, this); > // write incremental (only for signing purpose) > doc.saveIncremental(fis, fos); -- This message was sent by Atlassian JIRA (v6.3.4#6332)
[jira] [Commented] (PDFBOX-2039) Class PDDocument should implement java.io.Closeable
[ https://issues.apache.org/jira/browse/PDFBOX-2039?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13977879#comment-13977879 ] Andrei Solntsev commented on PDFBOX-2039: - No problems, the interface java.io.Closeable is available since Java 1.5 > Class PDDocument should implement java.io.Closeable > --- > > Key: PDFBOX-2039 > URL: https://issues.apache.org/jira/browse/PDFBOX-2039 > Project: PDFBox > Issue Type: Improvement >Affects Versions: 2.0.0 >Reporter: Andrei Solntsev >Priority: Minor > Original Estimate: 1h > Remaining Estimate: 1h > > It would make it possible to use Java 7 try-with-resources feature: > try (PDDocument doc = PDDocument.load(outputFile)) { > // bla-bla > // no need to call doc.close(); explicitly > } > P.S. Actually all org.apache.pdfbox.* classes with method close() could > implement java.io.Closeable -- This message was sent by Atlassian JIRA (v6.2#6252)
[jira] [Updated] (PDFBOX-2039) Class PDDocument should implement java.io.Closeable
[ https://issues.apache.org/jira/browse/PDFBOX-2039?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ] Andrei Solntsev updated PDFBOX-2039: Issue Type: Improvement (was: Bug) > Class PDDocument should implement java.io.Closeable > --- > > Key: PDFBOX-2039 > URL: https://issues.apache.org/jira/browse/PDFBOX-2039 > Project: PDFBox > Issue Type: Improvement >Reporter: Andrei Solntsev > Original Estimate: 1h > Remaining Estimate: 1h > > It would make it possible to use Java 7 try-with-resources feature: > try (PDDocument doc = PDDocument.load(outputFile)) { > // bla-bla > // no need to call doc.close(); explicitly > } > P.S. Actually all org.apache.pdfbox.* classes with method close() could > implement java.io.Closeable -- This message was sent by Atlassian JIRA (v6.2#6252)
[jira] [Updated] (PDFBOX-2039) Class PDDocument should implement java.io.Closeable
[ https://issues.apache.org/jira/browse/PDFBOX-2039?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ] Andrei Solntsev updated PDFBOX-2039: Priority: Minor (was: Major) > Class PDDocument should implement java.io.Closeable > --- > > Key: PDFBOX-2039 > URL: https://issues.apache.org/jira/browse/PDFBOX-2039 > Project: PDFBox > Issue Type: Improvement >Reporter: Andrei Solntsev >Priority: Minor > Original Estimate: 1h > Remaining Estimate: 1h > > It would make it possible to use Java 7 try-with-resources feature: > try (PDDocument doc = PDDocument.load(outputFile)) { > // bla-bla > // no need to call doc.close(); explicitly > } > P.S. Actually all org.apache.pdfbox.* classes with method close() could > implement java.io.Closeable -- This message was sent by Atlassian JIRA (v6.2#6252)
[jira] [Created] (PDFBOX-2040) Method PDDocument#save does not sign the document
Andrei Solntsev created PDFBOX-2040: --- Summary: Method PDDocument#save does not sign the document Key: PDFBOX-2040 URL: https://issues.apache.org/jira/browse/PDFBOX-2040 Project: PDFBox Issue Type: Bug Reporter: Andrei Solntsev Method PDDocument.saveIncrementally() DOES sign the document, while method PDDocument.save() does NOT sign. It's not clear from javadoc if it's ok. At least I was frustrated. I want to sign my PDF, and it's convenient for me to use method PDDocument.save(). Could it sign the document? -- This message was sent by Atlassian JIRA (v6.2#6252)
[jira] [Created] (PDFBOX-2039) Class PDDocument should implement java.io.Closeable
Andrei Solntsev created PDFBOX-2039: --- Summary: Class PDDocument should implement java.io.Closeable Key: PDFBOX-2039 URL: https://issues.apache.org/jira/browse/PDFBOX-2039 Project: PDFBox Issue Type: Bug Reporter: Andrei Solntsev It would make it possible to use Java 7 try-with-resources feature: try (PDDocument doc = PDDocument.load(outputFile)) { // bla-bla // no need to call doc.close(); explicitly } P.S. Actually all org.apache.pdfbox.* classes with method close() could implement java.io.Closeable -- This message was sent by Atlassian JIRA (v6.2#6252)
[jira] [Created] (PDFBOX-2038) Method VisualSignatureParser#parse does not close COSDocument
Andrei Solntsev created PDFBOX-2038: --- Summary: Method VisualSignatureParser#parse does not close COSDocument Key: PDFBOX-2038 URL: https://issues.apache.org/jira/browse/PDFBOX-2038 Project: PDFBox Issue Type: Bug Affects Versions: 1.8.4 Reporter: Andrei Solntsev Priority: Minor I am adding a visual signature to my PDF. SignatureOptions options = new SignatureOptions(); options.setVisualSignature( new FileInputStream("my.jpg") ); After a while I am getting the following warning in logs: Warning: COSDocument: You did not close a PDF Document The problem cause is probably the method org.apache.pdfbox.pdfparser.VisualSignatureParser#parse which creates instance of COSDocument, but does not close it. -- This message was sent by Atlassian JIRA (v6.2#6252)