How to digitally sign pdf file

Hi,
I am working on Java and Digital Signature and new to this field. I want to sign a pdf file using smart card. I have tried signing xml files and it's now running fine. The signature is attached with the xml file. Similarly I want to sign a pdf file and the signature should be attached with it.
Please help me to do that.
Thanks in advance.

Thnx.
Any way I could manage the matter.
I hope my code may help people working on same.
So the code is here
static String fname = "D:\\file.pdf";
static String fnameS = "D:\\file_signed.pdf";
//The main method
public static void main(String[] args) {
        try {
            this.signPdf() ;           
        } catch (Exception e) {
            System.out.println(e);
//The signer method
public static final boolean signPdf()
            throws IOException, DocumentException, Exception {
        String fileKey = "D:\\MyCertificate.pfx";
        String fileKeyPassword = "password";
        try {
            KeyStore ks = KeyStore.getInstance("pkcs12");
            ks.load(new FileInputStream(fileKey), fileKeyPassword.toCharArray());
            String alias = (String) ks.aliases().nextElement();
            PrivateKey key = (PrivateKey) ks.getKey(alias, fileKeyPassword.toCharArray());
            Certificate[] chain = ks.getCertificateChain(alias);
            PdfReader pdfReader = new PdfReader((new File(fname)).getAbsolutePath());
            File outputFile = new File(fnameS);
            PdfStamper pdfStamper;
            pdfStamper = PdfStamper.createSignature(pdfReader, null, '\0', outputFile);
            PdfSignatureAppearance sap = pdfStamper.getSignatureAppearance();
            //sap.setCrypto(key, chain, null, PdfSignatureAppearance.SELF_SIGNED);
            sap.setCrypto(key, chain, null, PdfSignatureAppearance.VERISIGN_SIGNED);
            sap.setReason("Security");
            sap.setLocation("Kolkata, India");
            sap.setSignDate(Calendar.getInstance());
            sap.setVisibleSignature(new Rectangle(10, 10, 50, 30), pdfReader.getNumberOfPages(), "Subhadip Pramanik");
            pdfStamper.setFormFlattening(true);
            pdfStamper.close();
            return true;
        } catch (Exception key) {
            throw new Exception(key);
    }

Similar Messages

  • How to automate digital signing PDF Files in batch

    I am trying to find a way to automate as much as possible the placing of a digital signature on a set of PDF documents.  We have Adobe Acrobat Pro 8.1 and the machine has MS Office 2003 with Vista Business.  Here's a scenario:  A set of documents exist in a TO-BE-SIGNED folder, each unsigned.  The user uses MS Access 2003 form with a button with VBA code to open and show the first document in the folder.  The AcroExch.App, AcroExch.AVDoc, and AcroApp.Show APIs are used to do this.  I found code on the internet to do that.  Rather than having my client now have to go through all the manual steps to place a digital signature on the document, I want to streamline it to a single click if possible.  Right now he has to click Advanced > Sign and Certify > Place Signature > then click and drag > then enter his password > then click sign > then save and close the doc.  Can all this be automated?  An added bonus would be automatically saving or moving the signed doc to a different folder when it is signed.
    I have created a stamp that allows me to add a stamp with just two clicks.  Can such be done to add a digital signature?  Is it possible to add a button to the toolbar to do this?  Can it be done in Access VBA using some Acrobat API calls?  Another feature I want to include is moving quickly from one document to the next in the TO-BE-SIGNED folder.  Like the arrow buttons take you from page to page, can a button be added to the Acrobat toolbar to take you from doc to doc in a particular folder?  Or can that be done using VBA and some Acrobat API calls?  To maintain the security of the password protection and yet cut down on clicks and keystrokes, I would like to input the password just once at the beginning of the session and have it remembered or applied to all the docs that get signed as long as that session is open.
    I've found some software that purports to do much of the above, but they are all very expensive and assume a big business with big bucks.  If anyone knows of inexpensive software that will REALLY do this, I'm open to that as well, though I'd like to control the process myself if possible.  I consider myself a beginner with Acrobat and using API calls and would appreciate any help anyone can give.  Is the above clear and even possible?
    PS:  I'm new to this site and using SDK.  I posted this under Security (thinking digital signatures) and was asked to post it here, which I'm glad to do.
    Thanks much!

    Our workflow is such that on infrequent occasions, we have a digitally signed PDF file and the doctor wants to append a scanned note to it.  In the past, we could do this, but not now.  In the past, when we added the scanned doc, we received a message saying that the doc is already signed and asking if we want to overrwrite the doc.  If we respond Yes, then Acrobat would allow it and the signature would indicate that the original part of the document was not modified, but that something had been changed--namely, a doc had been appended.  The signature indicated that something had changed since it was added, but it still allowed the append.  The signature would have an exclamation point in a yellow triangle indicating the doc had been updated since signed.  For our purposes, that was okay because we know what the change is based on the original doc and we know what is appended.  Now, however, we cannot append at all.  The only thing that is different that I know of is that the doc was signed with software that is not Adobe Acrobat, even though the other software uses an Adobe Acrobat self-created digital signature.
        I hope I've explained that clearly enough.
    Thanks for your help.

  • Where should the Green Tick get displayed in digitally signed pdf files in whom the Signature has been validated ?

    I have Windows 7 & Adobe 11 installed on my P.C (Apart from other Software) . Recently I downloaded Digitally Signed .pdf files & validated the Signature with Trust Certificates . However , the Green Tick Mark is coming on the left-hand side of a blue panel situated in-between the menu bar & the document . Shouldn't it be coming at the bottom right side of the document (Just above the name of the signatory) ? Is there anyway I can get the green tick to display at the bottom right side of the document or is this just the way the green tick gets displayed in current versions of adobe reader ?
    This is the way it gets displayed on the top - left portion of the screen :
    However , it does not get displayed in the below manner :

    First of all, you need an app on the iPad that can read those files that you want to transfer. Adobe Reader and iBooks are two free apps that will read PDF files. Adobe Reader is much more robust than iBooks as it offers so many more features like renaming files, creating folders, annotating, highlights, etc.
    Download Adobe Reader in the App Store. Then read this about file sharing with iTunes.
    iOS: About File Sharing - Support - Apple
    There are other ways to get files to the iPad, like email, DropBox and some other apps that let you mount your iPad like a flash drive.
    This should be helpful as well.
    iTunes 11 for Mac: Set up syncing for iPod, iPhone, or iPad

  • How to digitally sign PDF document in VC?

    Hi all,
    i want know how to open a PDF file and digitally sign the document programatically in vc?
    Thanks

    Do you mean a tool other than Adobe Acrobat or Reader?  Since this is the Acrobat SDK, your users would already have Acrobat installed and can sign PDFs just fine.
    What would you be adding to that?

  • How to digitally sign PDF document in VB?

    Hi,
    I was wondering if there was a way to open a PDF file and digitally sign the document (with the electronic signature info showing on the bottom of the last page) programatically?
    Thanks
    K

    > (1) When I download the SDK, it only has a setup file which I launch - I don't see any documentation in there and no menu item is created.
    Where did you download the SDK?
    > (2) When I go to the livedocs.abobe.com link and look how to use Javascript to digitally sign documents, the link is blank and is waiting for someone to post a comment.
    May be a problem of your browser.
    > Does someone know of a VB code that allows you to digitally sign the PDF documents via Javascript?
    Look at the JavaScript sample AddSignature in the SDK.

  • How to remove password-encryption in a signed PDF file?

    I can open a password-encryption and digitally signed PDF file using Acrobat X Standard but cannot remove the password protection.
    Can anyone help me remove the password encryption?  The Acrobat only allows to set passsord encryption before adding digital signature to a PDF file.  Can I sign a PDF file and then encrypt it with password?  Thanks.

    Removing the security, if it is possible, would destroy the signature.
    Encrypting a signed PDF would destroy the signature.
    This is because signatures validate the file exactly as it is, and changes to the file break the signature by design. Setting security is a change to the PDF (a big change).

  • Digitally Signed PDF crashes Mail and Preview

    I've run into an odd situation - if I try to send a digitally signed PDF file using the Mail app or even view that file in the Preview app, those apps crash. The PDF files are created in Adobe Acrobat Pro version 9.1.0 (for the Mac). My Mail and Preview apps are right up to date.
    The same PDF file still opens just fine in Adobe Acrobat. If I create exactly the same file, but don't go through the digital signature step, the files open (in Preview) and send (in Mail) just fine.
    Anyone else run into this problem and/or have a suggestion on how to avoid it?
    (P.S. By "create", I mean I have printed to the "Adobe PDF 9.0" print driver, which creates the base PDF file. Then I have also "secured" the file by requiring a password be entered to change anything. The final step, which seems to be causing the problem, is digitally signing the file.)

    The problem may be related to asking Acrobat 9 to output a file format "compatible" with older versions -- along with adding security.
    If you check the Console log, I think you will find that the "mdworker" task is also crashing -- even when you open the file successfully with Adobe Reader. I presume this is Spotlight trying to index the file.
    Safari will also crash when attempting to view such a PDF. It puts out a Console message indicating invalid AES block size or some such. Presumably this is related to the 128 bit AES security in the PDF file. Using 128 bit RC4 results in a file that doesn't crash Preview, but the document content is garbled by Preview so it's just as bad.
    --Bob

  • Can I open reader and digitally sign pdf in flash?

    First off let me say, I have 0 experience with Adobe Flash or Adobe Air, so this may be a dumb question or I may not even be asking in the right place.  I currently have an application which uses Adobe Reader to digitally sign PDF files.  The PDFs are displayed inline within a webpage.  The user must use Adobe Reader because it needs to be FIPS 140 certified.  The issue we are running into is with browsers like Chrome and Firefox bunding their own PDF reader, it brakes our application.  I am looking for a way to force users to use Adobe Reader.  From reading on the web, it looks like this isn't really possible and we are at the mercy of the PDF plugin the user has installed.  The idea I thought of, though, would be to write an Adobe Flash application which would display the PDF.  I am hoping doing it this way, I could force the use of Adobe Reader and not the PDF plugin of the browser.  Does anyone know if this will work?  And if it does, will I have all functions of Adobe Reader available (specifically digitally signing)?

    for a web based app, you can't easily display a pdf in flash.  even for an air app (or any other platform), you can't force anyone to use adobe reader (especially, because not everyone has adobe reader).

  • How to append to a signed PDF file

    We have Adobe Acrobat 8.1 Professional on PCs running Vista.
    In the past, we could append a scanned document to a PDF document that has already been signed using a self-created Adobe digital signature.  Now we have docs with a digital signature from a Certificate Authority.  I can no longer append a scanned doc to the signed PDF file.  Is there a way to do this?  Previously, we selected Create PDF > From Scanner > selected Append > and clicked Scan.  The scanned paper file would be added to the existing signed PDF document.  Now, however, we get the message "File can't be appended" when we select Append and navigate to the file signed with a digital signature from a Certificate Authority.  One more factor, the documents we get are now signed with PDF signing software other than Adobe Acrobat.  I tried scanning the doc to a file and then combining and Adobe Acrobat would not allow that either because of the digital signature.  Does anyone know how to do the append procedure now?
    Thanks!

    Click on the "arrow out of box" icon on the menu when you're viewing your PDF document (2nd button from right). then click "E-mail document".

  • How to edit digitally signed pdfs

    How to edit signed pdf ? am getting the message that you are currently viewing a signed version. All editing and interactive features are disabled. Save a copy and reopen to edit this document , please help how can I remove this signature or disable it ? The file was created using my use ..  The error message: this document has been signed and cant be edited

    Save a copy before signing - important. Think of signing as final.

  • How can I convert .pdf file to .doc using the free adobe reader app? when I try to convert the .pdf file it asks me to sign in. when I click on "sign in", I am taken to a service subscription page. So, no free conversions using free adobe reader app?

    how can I convert .pdf file to .doc using the free adobe reader app? when I try to convert the .pdf file it asks me to sign in. when I click on "sign in", I am taken to a service subscription page. So, no free conversions using free adobe reader app?

    As has been mentioned Adobe Reader cannot export PDF page content. Nor can it create PDF or manipulate PDF page content.
    What you can do is use one of Adobe's online subscription services. Two provide for PDF  to Word export.
    There's ExportPDF and PDF Pack.
    Be well...

  • How can I convert digitally signed PDF's so I can combine them into a single multi-page PDF?

    We are an architectural firm and we receive drawings from consultants as PDF's that are digitally signed.  In order to combine all of our drawings into a single PDF, we currently send the PDF's to a printer, have them printed, and scan them as new PDF's.  This process reduces the clarity of the PDF and re-printing the scanned PDF's reduces the clarity even further.  Is there a way to "flatten" or otherwise convert the digitally signed PDF's so we can combine them into a single multi-page PDF?  Making a portfolio is not an option.  We need an actual multi-page PDF for a variety of reasons.  This problem is actually preventing our office from using digital signatures so any help would be greatly appreciated.

    You can't. There was a discussion on this Forum a few months ago on this subject. Look it up for more info.

  • How to open a pdf file only in one computer

    I would like to sell pdf publications by allowing  the user to open them only in one computer. I learnt that this has been done  the past when I bought  some publications but I don't know the way to do it. Could you help me?
    thank you
    Marco

    thank you for your support
    Best Regards
    Marco
    Da:     Mylenium <[email protected]>
    Per:    MARCO1 <[email protected]>,
    Data:   09/10/2013 11:09
    Oggetto:        How to open a pdf
    file only in one computer
    Re: How to open a pdf file only in one computer
    created by Mylenium in Downloading, Installing, Setting Up - View the full
    discussion
    You will havwe to sign up for some service that supports rights
    management, use protected PDFs via LiveCyle/ Acrobat Connect or learn how
    to create your own ePub stuff using Digital Publishing Suite. In any case,
    it will probably cost you money upfront before you make any revenue.
    Mylenium
    Please note that the Adobe Forums do not accept email attachments. If you
    want to embed a screen image in your message please visit the thread in
    the forum to embed the image at
    http://forums.adobe.com/message/5746873#5746873
    Replies to this message go to everyone subscribed to this thread, not
    directly to the person who posted the message. To post a reply, either
    reply to this email or visit the message page: [
    http://forums.adobe.com/message/5746873#5746873]
    To unsubscribe from this thread, please visit the message page at [
    http://forums.adobe.com/message/5746873#5746873]. In the Actions box on
    the right, click the Stop Email Notifications link.
    Start a new discussion in Downloading, Installing, Setting Up at Adobe
    Community
    For more information about maintaining your forum email notifications
    please go to http://forums.adobe.com/message/2936746#2936746.
    Il messaggio trasmesso può contenere informazioni di carattere
    confidenziale rivolte esclusivamente al destinatario. Ne è vietato l'uso,
    la diffusione, la distribuzione o la riproduzione da parte di altre
    persone e/o entità diverse da quelle specificate. Nel caso aveste ricevuto
    questo messaggio per errore, siete pregati di segnalarlo immediatamente al
    mittente e cancellare quanto ricevuto.
    This electronic mail transmission may contain confidential information
    addressed only to the person(s) named. Any use, distribution, copying or
    disclosure by any other person and/or entities other than the intended
    recipient is prohibited. If you received this transmission in error,
    please inform the sender immediately and delete the material

  • Enable Adobe Reader to Digitally Sign PDF created with Acrobat Pro 9

    Hi All,
    I am trying to figure out how to enable adobe readers to digitally sign PDFs I create. I currently have Acrobat Pro 9.
    Customer Support said that I need to save it as a "Reader Extended" format, but I cant find this option anywhere.
    Any help would be appreciated.
    Thanks
    Matt

    Thanks Ben,
    Unfortunately, that video is for acrobat X or above and I cant find the "save as reader extended" option in Acrobat Pro 9.
    Can this be done from this version?
    Thanks again
    Matt

  • How to convert a pdf file with hand-written signature?

    How to convert a pdf file with hand-written signature?

    Hi Lotus1215,
    Once the document is signed we cannot edit that document, hence convertion is not possible
    Please see the article mentioned below
    http://forums.adobe.com/docs/DOC-1515
    Let me know if you have any other question.
    Regards,
    ~Pranav

Maybe you are looking for