[jira] [Commented] (PDFBOX-4312) byte array format to pass to sign method
[ https://issues.apache.org/jira/browse/PDFBOX-4312?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=16621136#comment-16621136 ] Tilman Hausherr commented on PDFBOX-4312: - This code seems to work... the problem is something with the append mode of FileOutputStream. So use the code below, or the long code I posted earlier today. {code:java} public void saveIncrementalNEW( String fileName ) throws IOException, COSVisitorException { FileInputStream fis = new FileInputStream(fileName); byte[] ba = IOUtils.toByteArray(fis); fis.close(); FileOutputStream fos = new FileOutputStream(fileName); fos.write(ba); fis = new FileInputStream(fileName); saveIncremental(fis, fos); }{code} > byte array format to pass to sign method > > > Key: PDFBOX-4312 > URL: https://issues.apache.org/jira/browse/PDFBOX-4312 > Project: PDFBox > Issue Type: Wish > 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] [Commented] (PDFBOX-4312) byte array format to pass to sign method
[ https://issues.apache.org/jira/browse/PDFBOX-4312?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=16621003#comment-16621003 ] Tilman Hausherr commented on PDFBOX-4312: - 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. > byte array format to pass to sign method > > > Key: PDFBOX-4312 > URL: https://issues.apache.org/jira/browse/PDFBOX-4312 > Project: PDFBox > Issue Type: Wish > 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] [Commented] (PDFBOX-4312) byte array format to pass to sign method
[ https://issues.apache.org/jira/browse/PDFBOX-4312?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=16620995#comment-16620995 ] Tilman Hausherr commented on PDFBOX-4312: - So I was able to reproduce the effect. 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 is the writing start offset is really correct. Likely the solution would be to read the input into a buffer first and to pass that one. > byte array format to pass to sign method > > > Key: PDFBOX-4312 > URL: https://issues.apache.org/jira/browse/PDFBOX-4312 > Project: PDFBox > Issue Type: Wish > 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] [Commented] (PDFBOX-4312) byte array format to pass to sign method
[ https://issues.apache.org/jira/browse/PDFBOX-4312?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=16620970#comment-16620970 ] Tilman Hausherr commented on PDFBOX-4312: - TODO for me: * check whether saveIncrementtal (filename) works at all, it seems that it doesn't * document stream type in 1.8 (jpeg only) > byte array format to pass to sign method > > > Key: PDFBOX-4312 > URL: https://issues.apache.org/jira/browse/PDFBOX-4312 > Project: PDFBox > Issue Type: Wish > Components: .NET, PDModel, Signing >Affects Versions: 1.8.9 >Reporter: bal >Priority: Major > Attachments: Screenshot (30).png, Screenshot (31).png, Screenshot > (31).png, 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] [Commented] (PDFBOX-4312) byte array format to pass to sign method
[ https://issues.apache.org/jira/browse/PDFBOX-4312?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=16620963#comment-16620963 ] Tilman Hausherr commented on PDFBOX-4312: - {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.saveIncremental(fis, fos); {code} {color:#33}2) Your image is a png image. Please pass a jpeg image. This is not documented, sadly.{color} > byte array format to pass to sign method > > > Key: PDFBOX-4312 > URL: https://issues.apache.org/jira/browse/PDFBOX-4312 > Project: PDFBox > Issue Type: Wish > Components: .NET, PDModel, Signing >Affects Versions: 1.8.9 >Reporter: bal >Priority: Major > Attachments: Screenshot (30).png, Screenshot (31).png, Screenshot > (31).png, 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] [Commented] (PDFBOX-4312) byte array format to pass to sign method
[ https://issues.apache.org/jira/browse/PDFBOX-4312?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=16620504#comment-16620504 ] bal commented on PDFBOX-4312: - please see the attached signed pdf i want to show only one name please suggest some solution on priority !Screenshot (31).png! > byte array format to pass to sign method > > > Key: PDFBOX-4312 > URL: https://issues.apache.org/jira/browse/PDFBOX-4312 > Project: PDFBox > Issue Type: Wish > Components: .NET, PDModel, Signing >Affects Versions: 1.8.9 >Reporter: bal >Priority: Major > Attachments: Screenshot (30).png, Screenshot (31).png, Screenshot > (31).png, 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] [Commented] (PDFBOX-4312) byte array format to pass to sign method
[ https://issues.apache.org/jira/browse/PDFBOX-4312?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=16620500#comment-16620500 ] bal commented on PDFBOX-4312: - please find attached PDF for reference. instead of signed by unknown i want to show signed by name of the person signing that document. !Screenshot (30).png! > byte array format to pass to sign method > > > Key: PDFBOX-4312 > URL: https://issues.apache.org/jira/browse/PDFBOX-4312 > Project: PDFBox > Issue Type: Wish > Components: .NET, PDModel, Signing >Affects Versions: 1.8.9 >Reporter: bal >Priority: Major > Attachments: Screenshot (30).png, 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] [Commented] (PDFBOX-4312) byte array format to pass to sign method
[ https://issues.apache.org/jira/browse/PDFBOX-4312?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=16619407#comment-16619407 ] Tilman Hausherr commented on PDFBOX-4312: - Please sign something and attach the unsigned and the signed PDF to this issue. Just drag 'n drop them on the browser. > byte array format to pass to sign method > > > Key: PDFBOX-4312 > URL: https://issues.apache.org/jira/browse/PDFBOX-4312 > Project: PDFBox > Issue Type: Wish > Components: .NET, PDModel, Signing >Affects Versions: 1.8.9 >Reporter: bal >Priority: Major > > 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] [Commented] (PDFBOX-4312) byte array format to pass to sign method
[ https://issues.apache.org/jira/browse/PDFBOX-4312?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=16618991#comment-16618991 ] bal commented on PDFBOX-4312: - Actually i am getting response from uidai which contains user information.This response is in xml format. please see attached xml for ref. I am fetching docsignature containing user data from aadhar.This is base 64 encoded data i am converting this data to byte array .As you mentioned i am returning this byte array from sign method. But my signature is not inserting in blank signature field.please reply.
[jira] [Commented] (PDFBOX-4312) byte array format to pass to sign method
[ https://issues.apache.org/jira/browse/PDFBOX-4312?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=16617967#comment-16617967 ] Tilman Hausherr commented on PDFBOX-4312: - I'm afraid you haven't understood me. You cannot calculate the signature of the PDF before calling {{sign()}}. The input in {{sign()}} contains the signed PDF except the signature space. This signed PDF is more than the original PDF, some data (more than just the signature) is appended to the PDF. So if you are using an external service to calculate the signature, {{sign()}} must look somewhat like this: {code:java} public byte[] sign(inputStream is) { - pack the bytes from is (or a digest, don't know) into XML - send XML to external service - wait for response - check for error - receive XML response - extract signature bytes from XML response - return bytes } {code} If the point of you using an external service is to authenticate once, and then sign several files in one bug batch, then this isn't possible in 1.8. It is possible in 2.0.11, see the source code of CreateVisibleSignature in the 2.0.11 source code download and the discussion in PDFBOX-3065. > byte array format to pass to sign method > > > Key: PDFBOX-4312 > URL: https://issues.apache.org/jira/browse/PDFBOX-4312 > Project: PDFBox > Issue Type: Wish > Components: .NET, PDModel, Signing >Affects Versions: 1.8.9 >Reporter: bal >Priority: Major > > 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] [Commented] (PDFBOX-4312) byte array format to pass to sign method
[ https://issues.apache.org/jira/browse/PDFBOX-4312?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=16617107#comment-16617107 ] bal commented on PDFBOX-4312: - I have generated byte array by deserializing the xml to object. The size of byte array for docsignature element i am getting is 2911 belowis the code for that.I am storing this byte array to docSigDict dictionary and retriving this value to assign to byte array in sign method. yet my signature in not inserting in the blankbox please guide me it's very important to me to solve this issue . public class XmlObjectConverter { //fields private XmlSerializer Serializer; private XmlSerializer Deserializer; string XmlString = ""; //methods public XmlSerializer getSerializer() { return Serializer; } public void setSerializer(XmlSerializer serializer) { this.Serializer = serializer; } public XmlSerializer getDeserializer() { return Deserializer; } public void setDeserializer(XmlSerializer deserializer) { this.Deserializer = deserializer; } public String ObjectToXml(EsignResponse obj) { XmlSerializer serializer = new XmlSerializer(typeof(EsignResponse)); using (System.IO.StringWriter textWriter = new System.IO.StringWriter()) { serializer.Serialize(textWriter, obj); return XmlString.ToString(); } } public object XmlToObject(object obj, string XmlString) { XmlDocument xDoc = new XmlDocument(); xDoc.LoadXml(XmlString); XmlSerializer serializer = new XmlSerializer(typeof(EsignResponse), new XmlRootAttribute("EsignResp")); MemoryStream stream = new MemoryStream(); System.IO.StringWriter sw = new System.IO.StringWriter(); sw.Write(XmlString); byte[] bytes = Encoding.UTF8.GetBytes(XmlString); //MemoryStream xmlStream = new MemoryStream(bytes); MemoryStream output = new MemoryStream(bytes); obj = serializer.Deserialize(output); return obj; } > byte array format to pass to sign method > > > Key: PDFBOX-4312 > URL: https://issues.apache.org/jira/browse/PDFBOX-4312 > Project: PDFBox > Issue Type: Wish > Components: .NET, PDModel, Signing >Affects Versions: 1.8.9 >Reporter: bal >Priority: Major > > 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] [Commented] (PDFBOX-4312) byte array format to pass to sign method
[ https://issues.apache.org/jira/browse/PDFBOX-4312?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=16615100#comment-16615100 ] Tilman Hausherr commented on PDFBOX-4312: - Your sign() method looks suspicious. The input of this is the data to be signed. This is NOT identical to the PDF, it is "everything except the signature area". This data doesn't exist before calling {{saveIncremental}}. Yet you are passing {{docSigDict["doc"]}} from earlier. Please try to follow the signature example (see 1.8 source code download) as much as possible. > byte array format to pass to sign method > > > Key: PDFBOX-4312 > URL: https://issues.apache.org/jira/browse/PDFBOX-4312 > Project: PDFBox > Issue Type: Wish > Components: .NET, PDModel, Signing >Affects Versions: 1.8.9 >Reporter: bal >Priority: Major > > 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] [Commented] (PDFBOX-4312) byte array format to pass to sign method
[ https://issues.apache.org/jira/browse/PDFBOX-4312?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=16606055#comment-16606055 ] Tilman Hausherr commented on PDFBOX-4312: - The .net version(s) are not supported by the Apache PDFBox team. The PDFBox source download has examples in Java on how to sign, please try implementing that in .net first. If that works, then try your own changes. I have not understood the problem, please attach your target PDF, and the code you are using, maybe I'll understand something then. "but the name of which signature is not shown" - does this mean the signature is invisible? Or that the name is missing? Or that you'd like to see text? > byte array format to pass to sign method > > > Key: PDFBOX-4312 > URL: https://issues.apache.org/jira/browse/PDFBOX-4312 > Project: PDFBox > Issue Type: Wish > Components: .NET, PDModel, Signing >Affects Versions: 1.8.9 >Reporter: bal >Priority: Critical > > 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