[jira] [Comment Edited] (PDFBOX-4312) Signature is not getting inserted into 00000 area
[ https://issues.apache.org/jira/browse/PDFBOX-4312?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16662581#comment-16662581 ] Tilman Hausherr edited comment on PDFBOX-4312 at 10/24/18 5:26 PM: --- It's what I explained in September, that signing will only work if you calculate the signature from the input stream at the time sign() is called. What you are doing is to calculate the signature at an earlier time, when the PDF doesn't exist in its signed form. The signature covers both the original PDF and the incremental save part, except the signature itself. To insert the signature and the byterange at the proper place you need to write some code yourself, as explained by me on October 22 in the long comment. was (Author: tilman): It's what I explained in September, that it will only work if you calculate the signature from the input stream at the time sign() is called. What you are doing is to calculate the signature at an earlier time, when the PDF doesn't exist in its signed form. The signature covers both the original PDF and the incremental save part, except the signature itself. To insert the signature and the byterange at the proper place you need to write some code yourself, as explained by me on October 22 in the long comment. > Signature is not getting inserted into 0 area > - > > Key: PDFBOX-4312 > URL: https://issues.apache.org/jira/browse/PDFBOX-4312 > Project: PDFBox > Issue Type: Bug > Components: .NET, PDModel, Signing >Affects Versions: 1.8.9, 1.8.15 >Reporter: bal >Priority: Major > Fix For: 1.8.17 > > > Hi , > I want to sign pdf using signature in pkcs 7 format . I am converting pkcs 7 > signature to byte array using Convert.FromBase64String method in .net . I am > passing this byte array to sign method in signature interface which gets > called after calling saveincremental. My byte array is inserting proper but > the name of which signature is not shown when i open pdf. May be my byte > conversion may not proper or something else i am doing wrong. please let me > know. -- This message was sent by Atlassian JIRA (v7.6.3#76005) - To unsubscribe, e-mail: dev-unsubscr...@pdfbox.apache.org For additional commands, e-mail: dev-h...@pdfbox.apache.org
[jira] [Comment Edited] (PDFBOX-4312) Signature is not getting inserted into 00000 area
[ https://issues.apache.org/jira/browse/PDFBOX-4312?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16620995#comment-16620995 ] Tilman Hausherr edited comment on PDFBOX-4312 at 9/20/18 4:05 AM: -- So I was able to reproduce the effect, see attached files. This 1.8 source code {code:java} public void saveIncremental( String fileName ) throws IOException, COSVisitorException { saveIncremental(new BufferedInputStream(new FileInputStream(fileName)), new BufferedOutputStream(new FileOutputStream(fileName, true))); } {code} is suspicious, because one is writing on the same file than the one where one is writing, but I'm not sure if the writing start offset is really correct. was (Author: tilman): So I was able to reproduce the effect, see attached files. This code {code:java} public void saveIncremental( String fileName ) throws IOException, COSVisitorException { saveIncremental(new BufferedInputStream(new FileInputStream(fileName)), new BufferedOutputStream(new FileOutputStream(fileName, true))); } {code} is suspicious, because one is writing on the same file than the one where one is writing, but I'm not sure if the writing start offset is really correct. > Signature is not getting inserted into 0 area > - > > Key: PDFBOX-4312 > URL: https://issues.apache.org/jira/browse/PDFBOX-4312 > Project: PDFBox > Issue Type: Bug > Components: .NET, PDModel, Signing >Affects Versions: 1.8.9 >Reporter: bal >Priority: Major > Attachments: Screenshot (30).png, Screenshot (31).png, Screenshot > (31).png, testingSignature-signed-SaveIncremental-1param-bad-cutoff.pdf, > testingSignature-signed-SaveIncremental-2param-good.pdf, > testingSignature.pdf, testingSignature.pdf > > > Hi , > I want to sign pdf using signature in pkcs 7 format . I am converting pkcs 7 > signature to byte array using Convert.FromBase64String method in .net . I am > passing this byte array to sign method in signature interface which gets > called after calling saveincremental. My byte array is inserting proper but > the name of which signature is not shown when i open pdf. May be my byte > conversion may not proper or something else i am doing wrong. please let me > know. -- This message was sent by Atlassian JIRA (v7.6.3#76005) - To unsubscribe, e-mail: dev-unsubscr...@pdfbox.apache.org For additional commands, e-mail: dev-h...@pdfbox.apache.org
[jira] [Comment Edited] (PDFBOX-4312) Signature is not getting inserted into 00000 area
[ https://issues.apache.org/jira/browse/PDFBOX-4312?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16620963#comment-16620963 ] Tilman Hausherr edited comment on PDFBOX-4312 at 9/20/18 4:06 AM: -- {quote}{color:#33}yet my signature in not inserting in the blankbox please guide me it's very important to me to solve this issue .{color} {quote} {color:#33}indeed. It is still 0.{color} {color:#33}1) Your file looks as if you called save(). I wonder if saveIncremental(filename) works at all (your file is also cut off at the end), our examples use the two parameter method. Make sure that the output file name is not identical to the input file name. See this excerpt of the example source code:{color} {code:java} public File signPDF(File document) throws IOException, COSVisitorException, SignatureException { byte[] buffer = new byte[8 * 1024]; if (document == null || !document.exists()) { new RuntimeException("Document for signing does not exist"); } // creating output document and prepare the IO streams. String name = document.getName(); String substring = name.substring(0, name.lastIndexOf(".")); File outputDocument = new File(document.getParent(), substring+"_signed.pdf"); 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); … … PDDocument doc = PDDocument.loadNonSeq(document, randomAccessFile); // 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 if (options==null) { doc.addSignature(signature, this); } else { doc.addSignature(signature, this, options); } // write incremental (only for signing purpose) doc.saveIncremental(fis, fos); {code} {color:#33}2) Your image is a png image. Please pass a jpeg image. This is not documented, sadly.{color} was (Author: tilman): {quote}{color:#33}yet my signature in not inserting in the blankbox please guide me it's very important to me to solve this issue .{color} {quote} {color:#33}indeed. It is still 0.{color} {color:#33}1) Your file looks as if you called save(). I wonder if saveIncremental(filename) works at all (your file is also cut off at the end), our examples use the two parameter method. Make sure that the output file name is not identical to the input file name.{color} {code:java} public File signPDF(File document) throws IOException, COSVisitorException, SignatureException { byte[] buffer = new byte[8 * 1024]; if (document == null || !document.exists()) { new RuntimeException("Document for signing does not exist"); } // creating output document and prepare the IO streams. String name = document.getName(); String substring = name.substring(0, name.lastIndexOf(".")); File outputDocument = new File(document.getParent(), substring+"_signed.pdf"); 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); … … PDDocument doc = PDDocument.loadNonSeq(document, randomAccessFile); // 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 if (options==null) { doc.addSignature(signature, this); } else { doc.addSignature(signature, this, options); } // write incremental (only for signing purpose) doc.saveIncrementa
[jira] [Comment Edited] (PDFBOX-4312) Signature is not getting inserted into 00000 area
[ https://issues.apache.org/jira/browse/PDFBOX-4312?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16621003#comment-16621003 ] Tilman Hausherr edited comment on PDFBOX-4312 at 9/20/18 6:36 AM: -- Note that even after the bug has been fixed, you'll still have the problem I mentioned several days ago, i.e. you can only pass your file to the external service in {{sign()}}, not before. was (Author: tilman): Note that even if I fix the (probable) bug, you'll still have the problem I mentioned several days ago, i.e. you can only pass your file to the external service in {{sign()}}, not before. > Signature is not getting inserted into 0 area > - > > Key: PDFBOX-4312 > URL: https://issues.apache.org/jira/browse/PDFBOX-4312 > Project: PDFBox > Issue Type: Bug > Components: .NET, PDModel, Signing >Affects Versions: 1.8.9, 1.8.15 >Reporter: bal >Priority: Major > Fix For: 1.8.16 > > Attachments: Screenshot (30).png, Screenshot (31).png, Screenshot > (31).png, testingSignature-signed-SaveIncremental-1param-bad-cutoff.pdf, > testingSignature-signed-SaveIncremental-2param-good.pdf, > testingSignature.pdf, testingSignature.pdf > > > Hi , > I want to sign pdf using signature in pkcs 7 format . I am converting pkcs 7 > signature to byte array using Convert.FromBase64String method in .net . I am > passing this byte array to sign method in signature interface which gets > called after calling saveincremental. My byte array is inserting proper but > the name of which signature is not shown when i open pdf. May be my byte > conversion may not proper or something else i am doing wrong. please let me > know. -- This message was sent by Atlassian JIRA (v7.6.3#76005) - To unsubscribe, e-mail: dev-unsubscr...@pdfbox.apache.org For additional commands, e-mail: dev-h...@pdfbox.apache.org
[jira] [Comment Edited] (PDFBOX-4312) Signature is not getting inserted into 00000 area
[ https://issues.apache.org/jira/browse/PDFBOX-4312?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16652921#comment-16652921 ] bal edited comment on PDFBOX-4312 at 10/17/18 4:17 AM: --- The same error i am seeing after the improved code . signed by unknown please see the attached file. was (Author: bal@123): The same error i am seeing after the improved code . signed by unknown please see the attached file. > Signature is not getting inserted into 0 area > - > > Key: PDFBOX-4312 > URL: https://issues.apache.org/jira/browse/PDFBOX-4312 > Project: PDFBox > Issue Type: Bug > Components: .NET, PDModel, Signing >Affects Versions: 1.8.9, 1.8.15 >Reporter: bal >Priority: Major > Fix For: 1.8.17 > > Attachments: Screenshot (30).png, Screenshot (31).png, Screenshot > (31).png, testingSignature-signed-SaveIncremental-1param-bad-cutoff.pdf, > testingSignature-signed-SaveIncremental-2param-good.pdf, > testingSignature.pdf, testingSignature.pdf > > > Hi , > I want to sign pdf using signature in pkcs 7 format . I am converting pkcs 7 > signature to byte array using Convert.FromBase64String method in .net . I am > passing this byte array to sign method in signature interface which gets > called after calling saveincremental. My byte array is inserting proper but > the name of which signature is not shown when i open pdf. May be my byte > conversion may not proper or something else i am doing wrong. please let me > know. -- This message was sent by Atlassian JIRA (v7.6.3#76005) - To unsubscribe, e-mail: dev-unsubscr...@pdfbox.apache.org For additional commands, e-mail: dev-h...@pdfbox.apache.org
[jira] [Comment Edited] (PDFBOX-4312) Signature is not getting inserted into 00000 area
[ https://issues.apache.org/jira/browse/PDFBOX-4312?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16653075#comment-16653075 ] Tilman Hausherr edited comment on PDFBOX-4312 at 10/17/18 6:53 AM: --- There is nothing attached. Maybe a JIRA problem? All attachments are from September 19. was (Author: tilman): There is nothing attached. Maybe a JIRA problem? > Signature is not getting inserted into 0 area > - > > Key: PDFBOX-4312 > URL: https://issues.apache.org/jira/browse/PDFBOX-4312 > Project: PDFBox > Issue Type: Bug > Components: .NET, PDModel, Signing >Affects Versions: 1.8.9, 1.8.15 >Reporter: bal >Priority: Major > Fix For: 1.8.17 > > Attachments: Screenshot (30).png, Screenshot (31).png, Screenshot > (31).png, testingSignature-signed-SaveIncremental-1param-bad-cutoff.pdf, > testingSignature-signed-SaveIncremental-2param-good.pdf, > testingSignature.pdf, testingSignature.pdf > > > Hi , > I want to sign pdf using signature in pkcs 7 format . I am converting pkcs 7 > signature to byte array using Convert.FromBase64String method in .net . I am > passing this byte array to sign method in signature interface which gets > called after calling saveincremental. My byte array is inserting proper but > the name of which signature is not shown when i open pdf. May be my byte > conversion may not proper or something else i am doing wrong. please let me > know. -- This message was sent by Atlassian JIRA (v7.6.3#76005) - To unsubscribe, e-mail: dev-unsubscr...@pdfbox.apache.org For additional commands, e-mail: dev-h...@pdfbox.apache.org