pdfbox-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "BOSCHAT, Thierry" <thierry.bosc...@capgemini.com>
Subject Digitally sign PDFs without file system access
Date Fri, 24 May 2013 14:58:18 GMT
Hi I'm using pdfbox-1.8.1 to digitally sign PDFs.

I find the sample below to handle it.

But in this example I have to use a FileInputStream however I want to do it only through streams
(without any file system access). I tried to extends FileInputStream to deal with it but I
failed. Any tips for me about that problem ?


File outputDocument = new File("resources/signed" + document.getName());
    FileInputStream fis = new FileInputStream(document);
    FileOutputStream fos = new FileOutputStream(outputDocument);

    int c;
    while ((c = fis.read(buffer)) != -1)
      fos.write(buffer, 0, c);
    fis = new FileInputStream(outputDocument);

    // load document
    PDDocument doc = PDDocument.load(document);

    // create signature dictionary
    PDSignature signature = new PDSignature();
    signature.setFilter(PDSignature.FILTER_ADOBE_PPKLITE); // default filter
    // subfilter for basic and PAdES Part 2 signatures
    signature.setName("signer name");
    signature.setLocation("signer location");
    signature.setReason("reason for signature");

    // the signing date, needed for valid signature

    // register signature dictionary and sign interface
    doc.addSignature(signature, this);

    // write incremental (only for signing purpose)

    doc.saveIncremental(fis, fos);

This message contains information that may be privileged or confidential and is the property
of the Capgemini Group. It is intended only for the person to whom it is addressed. If you
are not the intended recipient, you are not authorized to read, print, retain, copy, disseminate,
distribute, or use this message or any part thereof. If you receive this message in error,
please notify the sender immediately and delete all copies of this message.

  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message