Hello,

when creating a PDF document you can add a blank signature field explicitely 
simply doing this:

        writer.getAcroForm().addSignature("foobarsig", 73, 705, 149, 759);

When post-processing an existing PDF document using a PdfStamper, is there a 
comparably easy way? Simply trying 

        stamper.getWriter().getAcroForm().addSignature("foobarsig", 73, 705, 
149, 759);

results in a RuntimeException: Unsupported in this context. Use 
PdfStamper.addAnnotation()
        at com.lowagie.text.pdf.PdfStamperImp.addAnnotation(Unknown Source)
        at com.lowagie.text.pdf.PdfAcroForm.addFormField(Unknown Source)
        at com.lowagie.text.pdf.PdfAcroForm.addSignature(Unknown Source).

This actually makes sense as there is no current page in the PdfStamper while 
the the one parameter method PdfWriter.addAnnotation() is expected to add the 
annotation on the current page.

Borrowing from the existing iText routines but evading the PdfStamperImp 
override of that method, I came up with

        addSignature(stamper, signaturePage, "foobarsig", 73, 705, 149, 759);

using

    PdfFormField addSignature(PdfStamper pdfStamper, int page, String name, 
float llx, float lly, float urx, float ury)
    {
        PdfWriter pdfStamperImp = pdfStamper.getWriter();
        PdfAcroForm acroForm = pdfStamperImp.getAcroForm();

        PdfFormField signature = PdfFormField.createSignature(pdfStamperImp);
        acroForm.setSignatureParams(signature, name, llx, lly, urx, ury);
        acroForm.drawSignatureAppearences(signature, llx, lly, urx, ury);
        
        pdfStamper.addAnnotation(signature, page);
        return signature;
    }

This works fine but looks too fragile considering possible future changes in 
the iText routines called or replaced here.

Is there an explicite easy way for adding blank signature fields using the 
PdfStamper I simply missed? Or could it be considered to add such a 
functionality to iText in the near future?

Best regards,   Michael.
-- 
Ist Ihr Browser Vista-kompatibel? Jetzt die neuesten 
Browser-Versionen downloaden: http://www.gmx.net/de/go/browser

-------------------------------------------------------------------------
This SF.Net email is sponsored by the Moblin Your Move Developer's challenge
Build the coolest Linux based applications with Moblin SDK & win great prizes
Grand prize is a trip for two to an Open Source event anywhere in the world
http://moblin-contest.org/redirect.php?banner_id=100&url=/
_______________________________________________
iText-questions mailing list
iText-questions@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/itext-questions

Buy the iText book: http://www.1t3xt.com/docs/book.php

Reply via email to