Sign a pdf using usb token

I am using below code to sign a pdf using itextsharp version 5.5.1.0 . It works fine. But itextsharp 5.5.1.0
is having AGPL and i think it cannot be used in my application freely. But by using version below 4.1.6 which has GPL licence the same code does not work. So is there any alternative?
using System;
using System.Windows.Forms;
using System.IO;
using System.Security;
using System.Security.Cryptography;
using System.Security.Cryptography.X509Certificates;
using iTextSharp.text.pdf;
using iTextSharp.text.pdf.security;
namespace SignPdf
public partial class Form1 : Form
public Form1()
InitializeComponent();
private SecureString GetSecurePin(string PinCode)
SecureString pwd = new SecureString();
foreach (var c in PinCode.ToCharArray()) pwd.AppendChar(c);
return pwd;
private void SignWithThisCert(X509Certificate2 cert)
string SourcePdfFileName = textBox1.Text;
string DestPdfFileName = textBox1.Text + "-Signed.pdf";
Org.BouncyCastle.X509.X509CertificateParser cp = new Org.BouncyCastle.X509.X509CertificateParser();
Org.BouncyCastle.X509.X509Certificate[] chain = new Org.BouncyCastle.X509.X509Certificate[] { cp.ReadCertificate(cert.RawData) };
IExternalSignature externalSignature = new X509Certificate2Signature(cert, "SHA-1");
PdfReader pdfReader = new PdfReader(SourcePdfFileName);
FileStream signedPdf = new FileStream(DestPdfFileName, FileMode.Create); //the output pdf file
PdfStamper pdfStamper = PdfStamper.CreateSignature(pdfReader, signedPdf, '\0');
PdfSignatureAppearance signatureAppearance = pdfStamper.SignatureAppearance;
//here set signatureAppearance at your will
signatureAppearance.Reason = "Because I can";
signatureAppearance.Location = "My location";
signatureAppearance.SignatureRenderingMode = PdfSignatureAppearance.RenderingMode.DESCRIPTION;
MakeSignature.SignDetached(signatureAppearance, externalSignature, chain, null, null, null, 0, CryptoStandard.CMS);
//MakeSignature.SignDetached(signatureAppearance, externalSignature, chain, null, null, null, 0, CryptoStandard.CADES);
MessageBox.Show("Done");
private void Form1_Load(object sender, EventArgs e)
private void button1_Click_1(object sender, EventArgs e)
//Sign with certificate selection in the windows certificate store
X509Store store = new X509Store(StoreLocation.CurrentUser);
store.Open(OpenFlags.ReadOnly);
X509Certificate2 cert = null;
//manually chose the certificate in the store
X509Certificate2Collection sel = X509Certificate2UI.SelectFromCollection(store.Certificates, null, null, X509SelectionFlag.SingleSelection);
if (sel.Count > 0)
cert = sel[0];
else
MessageBox.Show("Certificate not found");
return;
SignWithThisCert(cert);

hi.
you may return to the iTextshap version to 5.3.3, it works fine to sign a PDF using external USB token.
free C#
Excel  component being evaluated, any other recommendation is appreciated.
Thanks and Regards.
But version 5.3.3 is also having AGPL licence, As i said in question
version below 4.1.6 has GPL licence.

Similar Messages

  • Digitally Signing a PDF using Adobe Reader

    Hi,
    I am trying to create a PDF with a digital signature form so that any of our users with Adobe Reader can digitally sign (to authorise) the document.
    I am using Acrobat 9 Standard, I have created the signature form and saved with "Extend Forms Fill-in & Save in Adobe Reader..." This works fine for other forms (tick box for example) but not the Signature field. The field is viewable but all options are greyed out.
    The security settings prior to saving "Extend Forms Fill-in & Save in Adobe Reader..." are all allowed, but after Changing the Document/Document Assembly/Commenting/Signing/Creation of Template Pages are all Not Allowed. I appreciatesome need to be restricted to allow for extended features to work in Adobe Reader but the link below implies (unless I am missing something) that signing should be possible in Adobe Reader:
    http://help.adobe.com/en_US/Reader/8.0/help.html?content=WS58a04a822e3e50102bd615109794195 ff-7d48.html
    Am I missing something, or does this just not work?
    Thanks in advance

    Thanks for the information. I am now trying using a trial of Acrobat X.
    However I am having the same issue now I can't even tick the checkbox. When the PDF is opened with Reader on the same PC it works as expected (both checkbox and signature field are available). Soon as it is emailed/moved somewhere else we can't even tick the checkbox with the message below coming up on opening:
    "This document enabled extended features in Adobe Reader. The document has been changed since it was created and use of extended features is no longer available. Please contrct the author of the orginal version of this document"
    I've also tried using Distribute through Acrobat but receive the same message.
    So I am struggling with creating a PDF on one PC that needs to be digitally authorised by someone else on a different PC, using Adobe Reader.
    I have been using Save as...>Reader Extended PDF as the Advanced menu is no longer there...
    Apologies if this something obvious and simple, this is the first time I have tried to do this.

  • I need to digital sign a document using Acrobat Reader. Is it possibile?

    I am an IT Manager for a little city in northern italy.
    I have almost 50 clients with smart cards enabled for what concerns digital signage.
    I use flawlessy the software of the firm who provides the smart card. (infocamere.it).
    This uses sha256 crypt, no problems about it.
    The problem I have is:
    The final file is a "p7m" envelope.
    I would prefer to use a "pdf" envelope. One only file.
    I tried to follow this video
    http://tv.adobe.com/watch/acrobat-x/how-to-digitally-sign-a-document-with-adobe-reader/
    Simply it doesn't work.
    I have also a couple of Acrobat Standard.
    I can "pdf-sign" with Acrobat Standard 9.
    I am not able to do the same with reader 9 or X.
    There is a way to do it?
    Thank You.

    You can sign a PDF using Adobe Reader 9 or X, but the document must be "Reader Extended" to enable this functionality, This can be done using ADEP\LiveCycle Reader Extensions (server product) or Acrobat Professional 9 (Advanced > Extend Features in Adobe Reader) or Acrobat X Professional (File > Save As > Reader extended PDF)
    For some more info...  http://www.adobe.com/eeurope/products/server/readerextensions/  or http://help.adobe.com/en_US/enterpriseplatform/10.0/Overview/WS92d06802c76abadb2c8525912dd cb9aad9-7ffa.html
    Regards
    Steve

  • How to sign  PDF with a smart card or USB token in C# through IAC ?

    Hi,
    My goal is to apply a certification signature (MDP) to a PDF document with a smart card (Belgium identity card) from a C# application.
    I start Acrobat through IAC.
    The JavaScript object apparently can only sign with PKCS12 file (.pfx)...
    To sign a PDF with a smart card I need to develop a plug-in if I am right?
    The samples in the SDK are to get a certificate from the windows certificate store or to write a Third party handler.
    I already get the certificate context (an HCRYPPROV object from windows certificate store)
    How can I create a signature field but mostly sign it? With DigSig I guess, but I’m lost in the API… does
    I have to use DigSigSignDoc ?
    Syntax : void DigSigSignDoc(PDDoc pdDoc, CosObj sigField, ASAtom filterKey)
    The filterKey value for the windows certificate store is “Adobe.PPKMS” but how can I choose my certificate?
    I also have to build a signature reference dictionary i guess?
    What does i have to do and in which order? I can't find any documentation on this.
    There is a more simple way?
    Thank you,
    Goffin
    Fabian

    Hi,
    -download the JDK sample "sdkAddSignature.js"
    -change the sign methode like this :
    Sign = app.trustedFunction (
        function( sigField, DigSigHandlerName )
       try {
       app.beginPriv();
       //the diSigHandler is "Adobe.PPKLite"
       var myEngine = security.getHandler(DigSigHandlerName);
       var ids = myEngine.digitalIDs;
       //choose an id which is installed in the microsoft store
      var oCert = ids.certs[3];
      // for (var i=0; i<ids.certs.length; i++)
      //  console.println("certificat n°"+ i + " " +ids.certs[i]);
      var oParams = {cPassword:"0000" , oEndUserSignCert:oCert }
      if(myEngine.login({cPassword:"0000",oParams:oParams,bUI:false}))
       console.println("OK");
      else
       console.println("Error");
      console.println("sigfield :" + sigField);
    sigField.signatureSign({oSig: myEngine,oInfo: { password: "0000",reason: ACROSDK.sigReason,location: ACROSDK.sigLocation,contactInfo: ACROSDK.sigContactInfo}}); 
    app.endPriv
       } catch (e) {
       console.println("An error occurred: " + e);
    -perform some test using the javascript debugger
    -and finally use IAC to execute the script

  • Can i use my iPhone as a wireless signature pad to sign a pdf thats on my imac5 or mac air

    can i use my iphone as a wireless signature pad for a imac5 or mac book air to sign a pdf?

    If you could get it to work the response lag between the iPhone and Mac mini would likely make the game play painful.

  • Digital Signature invalid when sign a PDF with instances

    Hi,
    I created a XDP document with LiveCycle Designer ES2.
    This document contains:
    - Some required fields (text fields, data fields ecc...)
    - A Subform that user can add more instance pressing a button, contains some fields
    - A Digital Signature (With a simple fields collection contains only the signature field)
    I render the XDP for get a PDF (using ReaderExtensions component) by LiveCycle Workbench ES3.
    Then I open the PDF with Adobe Reader X.
    I compile the form and don't press on button increase the instances of Subform.
    Sign the document and the signature is valid.
    Now, instead, if I make the same but increase the instance of Subform, then sign, the signature is invalid...
    Can the problem is the different versions of Designer and Workbench?
    In past I got some problems, and sometime I resolved creating a new document and copying all the object of old form in new one... It's an ugly solution but it worked.
    But in this case don't resolve nothing.
    Any help?
    Thank You!

    Hi,
    I created a XDP document with LiveCycle Designer ES2.
    This document contains:
    - Some required fields (text fields, data fields ecc...)
    - A Subform that user can add more instance pressing a button, contains some fields
    - A Digital Signature (With a simple fields collection contains only the signature field)
    I render the XDP for get a PDF (using ReaderExtensions component) by LiveCycle Workbench ES3.
    Then I open the PDF with Adobe Reader X.
    I compile the form and don't press on button increase the instances of Subform.
    Sign the document and the signature is valid.
    Now, instead, if I make the same but increase the instance of Subform, then sign, the signature is invalid...
    Can the problem is the different versions of Designer and Workbench?
    In past I got some problems, and sometime I resolved creating a new document and copying all the object of old form in new one... It's an ugly solution but it worked.
    But in this case don't resolve nothing.
    Any help?
    Thank You!

  • Signing a document using a plugin in different versions of Reader

    Hi,
    I am signing a pdf document with my own .cer file using a plugin. Everything works great in Reader 8, I've got a green check, it specifies that this is a valid signature and I can view the certificate. In Reader 9, however, I receive a huge question mark, but it still specifies that the signature is valid and I can view the certificate. In Reader X, the signature is "UNKOWN".
    How do I get rid of the question mark? Even if I delete the vector data for the drawing the question mark in the plugin, a big yellow question mark is still being displayed in Reader 9 and X.
    Thank you,
    Magda

    Again, I know NOTHING about your plugin, your code, the certificate in question, etc.
    The ONLY WAY to get you an answer is for you to provide our support staff with the PDF in question, at least as a starting point.  Please open a support contract.
    From: Adobe Forums <[email protected]<mailto:[email protected]>>
    Reply-To: "[email protected]<mailto:[email protected]>" <[email protected]<mailto:[email protected]>>
    Date: Fri, 4 Nov 2011 06:25:35 -0700
    To: Leonard Rosenthol <[email protected]<mailto:[email protected]>>
    Subject: Signing a document using a plugin in different versions of Reader
    Re: Signing a document using a plugin in different versions of Reader
    created by magdakuit<http://forums.adobe.com/people/magdakuit> in Acrobat SDK - View the full discussion<http://forums.adobe.com/message/4007539#4007539

  • Acrobat Pro 10.12 not possible to sign a pdf with a valid cert

    Hello,
    Under Windows 7 x64, it's not possible to sign a PDF with a valid certificate. Clicking the sign button gives no response and no message what so ever. When using a non valid certificate as in not certified to use for signing, it is accepted and the document is signed?!
    Cheers,
    Andre

    Hi, Daniel.  
    Thank you for visiting Apple Support Communities.  
    I would need a little more information on how you are adding a signature to provide a better answer.  However, here is an article that I would take a look at.  
    Mail (Yosemite): Mark up attachments
    http://support.apple.com/kb/PH19143
    Cheers, 
    Jason H.  

  • Converting a word 2000 file into pdf using Adobe Acrobat Standard X

    I reinstalled my Adobe Acrobat Standard X today, and tried to convert a *.doc word file into pdf, but the application could not open the word file and got stalled. I remembered that last time I installed the application the same probelm cropped up and I had to install a Microsoft patch that was required to do this, What is the patch file and how do I get it?

    I answer my question myself. I have solved it myself. The answer can be found by searching adobe website. But I give it here if it can be useful to others. Go to control panel. Go to Add or remove programs. Click on Modify in the listed Adobe program. Click Next in the box that appears. Select Modify. Click on + sign against pdF maker to expand. Click on X sign against 'this feature is not available' which shifts on to the little box on the left of Microsoft Office. Click on Apply. Quit. Once the Microsoft Office becomes disabled in Adobe, Word will open in all places.

  • It's possible to sign a PDF file with ABAP????

    Hi all.
    I'm trying to sign PDF file with SAPCRYPTOLIB. I'm 4.7 sap version.
    It's possible to do this?????....
    My question is because I've done all steps to sign a pdf, without errors, and the pdf generated is not signed.
    Can anybody to say me if it's possible to sign a pdf file with ABAP???
    thanks a lot.
    ISmael

    Here: [SAP Interactive Forms by Adobe|SAP Interactive Forms by Adobe;
    Also, please read the forum rules of engagement, it explains to use the forums.

  • How to sign a pdf with the correct content

    how do I sign a pdf?  It says that Im not using the correct content.  And that my certificate is not valid???

    Garciaasgina which Adobe software or service is your inquiry in reference too?

  • Signing a PDF not working

    Okay, this is NOT intuitive AT ALL. Just trying to add a darn signature to my PDF. And it says I need to "send for signature". When I "send for signature", the W9 that I downloaded from the IRS says that "you cannot edits this file as a form due to its security settings". As I have not touched the file at all when I do this, I should be able to turn off the security settings. But no. I cannot. Any ideas???????

    Which Acrobat/Reader version are you using on which platform/OS?
    From the description that you provided it looks like you are using Adobe Reader. The form that you are trying to sign is Reader-enabled with certain permissions. It seems that it was Reader-enabled with permissions that do not include what you are trying to do.
    It seems to me that you are using a wrong tool. Click on Fill&Sign, then expand "Fill&Sign Tools". Click on "Place Signature". The first time you do that you'll get a dialog which allows you to select signature type and look. The next time you sign it will use the signature you've already created. If you want to change your signature, click on a rectangle to the right of "Place Signature", select "Change Signature", and you'll get the same signature type selection dialog you got the first time you signed.

  • Signing a PDF file

    Hi all.
    I want to sign a pdf file.
    1.- u2019ve generated the PSE file in my system and Iu2019ve validated it. Iu2019ve inserted my certificate in the pse file.
    2.- Iu2019ve created a program how converts a spool to PDF format (FM CONVERT_OTFSPOOLJOB_2_PDF ).
    3- I use the FM SSF_GET_PARAMETER to get my pse parameters.
    4.- I use the FM SSF_KRN_SIGN_BY_AS to sign the pdf data. This FM generates a signed data in binary type.
    5.- I Verify the signed data with FM SSF_KRN_VERIFY. The validation is good.
    6.- I generate the pdf and download it with FM GUI_DOWNLOAD. I use the binary signed data ( Generated in FM    SSF_KRN_SIGN_BY_AS ) in this FM.
    The problem is with the pdf generated. I can open it and I can read it without problems but I donu2019t see the sign in this document.
    The pdf document signed is with un 1Kb more than the pdf not signed ( there are more information ) but the sign not appears .
    I'm using SAPCRYPTOLIB and my SAP version is 4.7
    Can you help me , please??? What is my error ??
    Thanks a lot.
    Ismael
    Edited by: Navarro Galindo on Jul 9, 2009 11:50 AM
    Edited by: Navarro Galindo on Jul 9, 2009 1:03 PM

    hi,
    Please go through thess snote  for 4.7
    SSF installation
    Note 86927 corresponds to 4.7 version .
    Please check the SAP Note-889361.
    It might help you
    http://threebit.net/mail-archive/itext-questions/msg07248.html
    Benakaraja
    ??P
    Edited by: benaka rajes on Jul 9, 2009 5:03 PM
    Edited by: benaka rajes on Jul 9, 2009 5:15 PM

  • Signing a PDF

    When I try to sign a PDF I get a message saying the security settings won't allow me to place a signature or add text from Adobe Reader. How do I change that?

    Hi jorms,
    Please check the document security properties to see if Signing is allowed on the pdf.
    You need to use Acrobat Pro to apply the "Sign in Reader" usage right.
    Regards,
    Rave

  • Signing a pdf pushes the text left

    When one of my fellow employees signs a .pdf the signature pushes all the text in the .pdf to the left.
    http://postimage.org/image/5om0p3hjb/    Unsigned
    http://postimage.org/image/x41xqe6iv/     Signed
    (These are examples without the reports they normally contain, when the document is full the text is illegible.)
    We recently upgraded the whole company to Adobe Reader 11.x from Reader 10.x this only happens to one user and only on Reader 11.x.  Other users are able to sign the same document in Reader 11.x without this problem occuring. 
    I have uninstalled and reinstalled Reader multiple times on the users computer.  I have also deleted and recreated the users signature. I checked the users settings against the settings of people who are able to sign the document and was unable to locate any differences.  I have also spent hours searching the net for others who are having similar problems but was unable to locate any information.
    I currently have the user running 10.x but soon I will be forced to install 11.x to keep in compliance with company policies.  Any help with this problem would be greatly appreciated.  I can also provide any more information that may be needed. 

    Ok, so the change is permanent. Perhaps in that case you could (if necessary) make a test file suitable for public consumption and share BOTH the original and signed/broken one - via acrobat.com, your own web site or a file sharing site. Someone might have the interest and tools to analyse and find something useful.

Maybe you are looking for

  • How to trigger pop-up window in report and update data base from report

    Hi All, I have a requirement, in a report output list to trigger a pop up window with some rejection codes corresponding to each sales order when i select from the output list. Also i need to update data base by selecting one of the rejection code in

  • Cancel PO Programatically

    Hello All, I need to cancel a Purchase Order Programatically. Can this be done? Thanks for any help, Bradley

  • TS2972 cannot get home sharing to work appletv

    I've completed all troubleshooting steps on apple support but still does not work. Just purchased and connected fine no issues. Then 2 days later just stopped. No workie!

  • Terminal Displays a Maximum 24 lines.

    I try to increase the number of rows in Terminal "Preferences/Settings" but the window will only display 24. I'm currently using Terminal Version 2.1.2 (273.1) in Snow Leopard, but it's been like this for years. Is this common experience, or an issue

  • Can I pass command line arguments to LV6 executables?

    Hi, in Document ID: 1CNFGHFI I read that "LabVIEW 5.x executables cannot take command line arguments. (...) Support for command line arguments may be available in the next major release of LabVIEW." Is that so in LV6? It would be a good reason to upd