Skip to Main Content

Java Security

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Sign PDF Document

Ghazi HakimSep 14 2017

Hello,

I found some code using oracle.xdo library to sign PDF documents and it's working :

    String inPDF = "/tmp/PDFDigitalSignatureTest_1.pdf";

    String outPDF = "/tmp/PDFDigitalSignatureTest_1_signed.pdf";

    String pkcs12File = "/tmp/sample.pfx";

    try

    {

      PDFSignature pdfSignature = new PDFSignature(inPDF, outPDF);

      Properties props = new Properties();

      // adds some properties to props

      pdfSignature.setConfig(props);

      pdfSignature.setLocale("en");

      pdfSignature.init("password4PKCS12", pkcs12File);

      // pdfSignature.addSignatureField(1, new float[]{550, 780, 620, 800}, "Signature1");

      pdfSignature.sign("Signature1", "I'm the author of this document");

      // Once it's signed, the cleanup() method must be called.

      // Otherwise, some resources will not be released.

      pdfSignature.cleanup();

    }

    catch(Throwable t)

    {

      t.printStackTrace();

    }

The PDF is well signed and the signature appears in the PDF, but I need to know if we can customise the skinning of the signature in the signed pdf, because it's bad looking how it appears now, just a simple box having the name of the pkcs12 file.

Ragards.

Comments

Locked Post
New comments cannot be posted to this locked post.

Post Details

Locked on Oct 12 2017
Added on Sep 14 2017
0 comments
193 views