Hi!

I´m new to pdfbox and I´m trying to add a visible Signature.
An invisible digital signature works fine, but to get an visible doesn´t work 
(I only get an rectangle on Mouse-Over).

Is there any simple way to add an visible Signature with the Default-Appearance 
(http://www.adobe.com/content/dam/Adobe/en/devnet/acrobat/pdfs/PPKAppearances.pdf)
 to a pdf-document?


I use the following code-part to create my

..

PDRectangle rect = rects.get(pageNo);

                    PDDocument documentSig = createPDocumentSignature(rect);
                    ByteArrayOutputStream outSig = new ByteArrayOutputStream();
                    documentSig.save(outSig);

                    SignatureOptions options = new SignatureOptions();
                    options.setPage(pageNo);
                    options.setVisualSignature(new 
ByteArrayInputStream(outSig.toByteArray()));

                    document.addSignature(pdsignature, signatureinterfaceimpl, 
options);

..


    private PDDocument createPDocumentSignature(PDRectangle rect) throws 
IOException {
        PDDocument documentSig = new PDDocument();
        PDPage pageSig = new PDPage();
        documentSig.addPage(pageSig);

        PDAnnotationText annot = new PDAnnotationText();
        annot.setRectangle(rect);
        pageSig.getAnnotations().add(annot);

        COSDictionary root = 
documentSig.getDocumentCatalog().getCOSDictionary();

        COSDictionary sig = new COSDictionary();
        root.setItem(COSName.SIG, sig);
        sig.setItem(COSName.FT, COSName.SIG);

        PDAppearanceDictionary ap = new PDAppearanceDictionary();
        sig.setItem(COSName.AP, ap.getDictionary());

        COSDictionary dr = new COSDictionary();
        dr.setItem(COSName.FONT, PDType1Font.HELVETICA);
        sig.setItem(COSName.DR, dr);

        return documentSig;
    }




-stefan

Reply via email to