![]() ![]() ![]() Here starts where I tried to make a second stamp to show in the page 2įileOutputStream fos2 = new FileOutputStream(path + parator + src) įile f2 = new File(path + parator + src) įileInputStream in2 = new FileInputStream(f2) įileOutputStream os2 = new FileOutputStream(path + parator + dest) ansform(new AffineTransform(0, 1, -1, 0, rectangle.getWidth(), 0)) Ĭt2.setRunDirection(PdfWriter.RUN_DIRECTION_NO_BIDI) Ĭt2.setSimpleColumn(new Phrase(stampMessage.toString(), font), 0, 0, rectangle.getHeight(), rectangle.getWidth(), 15, Element.ALIGN_LEFT) ![]() PdfTemplate layer2 = appearance.getLayer(2) customize appearance layer 2 to display text vertically StringBuilder stampMessage = new StringBuilder() Here I build a custom message.nothing relevant Rectangle rectangle = new Rectangle(550, 50, 610, 500) // funciona verticalĪtVisibleSignature(rectangle, 1, "SIGNATURE") PdfSignatureAppearance appearance = stamper.getSignatureAppearance() PdfStamper stamper = PdfStamper.createSignature(reader, os, '\0') Int qtypages = reader.getNumberOfPages() įileOutputStream os = new FileOutputStream(path + parator + dest) Here it goes the whole thing: public String signPdfFirstTime(String src, String dest, PrivateKey pk, Certificate chain, String providerName, String conteudoBase64, X509Certificate cert, String alias) throws IOException, DocumentException, GeneralSecurityExceptionīyte conteudoBinario = code(conteudoBase64) įileOutputStream fos = new FileOutputStream(path + parator + src) įile f = new File(path + parator + src) įileInputStream in = new FileInputStream(f) The stamp will be showed on the first page only. MakeSignature.signDetached(appearance, digest, pks, chain, null, null, null, 0, CryptoStandard.CMS) If it had worked I would have put it within a loop and keep changing the page parameter.īut why didn't it work? Well, near the end I call a method of MakeSignature and among the parameters I have to pass one of the appearences I created, if I call it more than once the signature appears only on the page related to the last appearence I pass to it.įor example: MakeSignature.signDetached(appearance2, digest, pks, chain, null, null, null, 0, CryptoStandard.CMS) The second parameter "1" above is the page number that I want to show the stamp, it is okay to be 1 by now, as I tried to do in order to show stamp in other page was creating other instances of PdfStamper, PdfSignatureAppearance and a Rectangle but set it to page 2. Trying to give a quick resume, to show the stamp what I do is creating PdfStamper, PdfSignatureAppearance and a Rectangle, then call the tVisibleSignature(rectangle, 1, "SIGNATURE") I've been working on a digital signature function for some days, now that I have everything working it is time to try to print the stamp in all pages but I'm not doing great… ![]()
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |