Hi, Our mailing list doesn’t support attachments. Can you open a bug report on JIRA and attach your PDFs via “More > Attach Files”.
Please include copies of the PDF files from before and after signing. Thanks, -- John > On 9 Jan 2015, at 13:27, Ruben Lagar <[email protected]> wrote: > > Hello all, > > I have a piece of code doing visual signatures correctly on some documents. > But on some other documents the inserted signature is not valid. > > The code is exactly the same, the certificates used are the same, the only > thing that changes is the input file. > > Could somebody give me a hand figuring out what can cause this? I can > attach examples of the files. > > The code I´m using is > > * 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(signerName);* > > * // the signing date, needed for valid signature* > * signature.setSignDate(Calendar.getInstance());* > > * // load document* > * PDDocument doc = null;* > * SignatureOptions options = null;* > * try {* > * ByteArrayInputStream bais = null;* > * try {* > * bais = new ByteArrayInputStream(content);* > * doc = PDDocument.load(bais);* > * } finally {* > * IOUtils.closeQuietly(bais);* > * }* > > * FileInputStream image = new FileInputStream("stamp.jpg");* > > * PDVisibleSignDesigner visibleSig = new > PDVisibleSignDesigner(doc, image, 1);* > * > visibleSig.xAxis(50).yAxis(50).zoom(50).signatureFieldName("signature");* > * visibleSig.height(37);* > * visibleSig.width(70);* > > * PDVisibleSigProperties signatureProperties = new > PDVisibleSigProperties();* > > * > signatureProperties.signerName("name").signerLocation("location").signatureReason("Security").preferredSize(0)* > * > .page(1).visualSignEnabled(true).setPdVisibleSignature(visibleSig).buildSignature();* > > * options = new SignatureOptions();* > * options.setVisualSignature(signatureProperties);* > * options.setPage(signatureProperties.getPage());* > * > options.setPreferedSignatureSize(signatureProperties.getPreferredSize());* > > * // register signature dictionary and sign interface* > * doc.addSignature(signature, this, options);* > > * // write incremental (only for signing purpose)* > * ByteArrayOutputStream fos = null;* > * ByteArrayInputStream bais2 = null;* > * try {* > * // Write the array to a file* > * fos = new ByteArrayOutputStream();* > * bais2 = new ByteArrayInputStream(content);* > * doc.saveIncremental(bais2, fos);* > * } finally {* > * IOUtils.closeQuietly(bais2);* > * IOUtils.closeQuietly(fos);* > * }* > > * return fos.toByteArray();* > * } finally {* > * if (options != null) {* > * options.close();* > * }* > > * if (doc != null) {* > * doc.close();* > * }* > * }* > > The input file is passed in the byte array named "content". > > I would appreciate any help!

