0
Add Digital Signature Using C# and Acrobat SDK
New Here
,
/t5/acrobat-sdk-discussions/add-digital-signature-using-c-and-acrobat-sdk/td-p/1132972
Feb 21, 2008
Feb 21, 2008
Copy link to clipboard
Copied
Hi everybody!
Please, how can I digitally sign PDF documents using Acrobat Professional 8 API and C# language?
I know that I need use JavaScript APIs (IAC) but I can't find anything really helpful in the Acrobat SDK Documentation. Could anyone post a sample of how use javascript manipulation inside C# (Framework 2.0), or give me a direction?
Thank in advance!
Please, how can I digitally sign PDF documents using Acrobat Professional 8 API and C# language?
I know that I need use JavaScript APIs (IAC) but I can't find anything really helpful in the Acrobat SDK Documentation. Could anyone post a sample of how use javascript manipulation inside C# (Framework 2.0), or give me a direction?
Thank in advance!
TOPICS
Acrobat SDK and JavaScript
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting.
Learn more
Enthusiast
,
/t5/acrobat-sdk-discussions/add-digital-signature-using-c-and-acrobat-sdk/m-p/1133021#M79344
Mar 15, 2008
Mar 15, 2008
Copy link to clipboard
Copied
If it's compatible with Acrobat, you'll need to research the crypto provider functions (they are all thoroughly documented in the JS API Reference). You are already using one of these methods in your current code, it is just referencing the default Adobe crypto provider.
If your hardware is not compatible with Acrobat (i.e. you can't manually use it within the Acrobat UI) then you will need to use it's own APIs, which has nothing to do with the Acrobat SDK and we would not be able to help you here.
If your hardware is not compatible with Acrobat (i.e. you can't manually use it within the Acrobat UI) then you will need to use it's own APIs, which has nothing to do with the Acrobat SDK and we would not be able to help you here.
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting.
Learn more
_Fornachari_
AUTHOR
New Here
,
/t5/acrobat-sdk-discussions/add-digital-signature-using-c-and-acrobat-sdk/m-p/1133022#M79346
Mar 25, 2008
Mar 25, 2008
Copy link to clipboard
Copied
PDL, I searched a lot in the internet and in the Acrobat Documentation to how use the acrobat sdk and javascript to sign a document using a certificate stored in a smartcard.
When I use a smart card (PKCS#11 Device) inside the Acrobat, it recognises the smart card and I can sign de document using the card (no PFX certificates are needed).
When I plug the card in my pc, appears in the "Windows Certificate Store" the certificate that are stored in the card. So, using Javascript I found the serial number of the certicate stored in the smart card (I'm sure that the serial number is correct), and I tried to use it and Javascript to sign a pdf document, like below:
var myEngine = security.getHandler("Adobe.PPKLite");
var oCerts = myEngine.digitalIDs.certs;
var serial = "XXXXXX"; //serial number of the certificat that I am looking for in the "Windows Cert Store"
var iSerial;
//search in the windows store certificate for a certificate with the serial number informed
for (var i=0; i < oCerts.length; i++)
{
if (oCerts.serialNumber == serial)
i = iSerial;
}
console.println("Signing using the certificate: "+oCerts[iSerial]);
myEngine.login( {oParams:{oEndUserSignCert: oCerts[iSerial] , cPassword: "MyPassword"}});
var f = this.getField("SignHere");
f.signatureSign( myEngine,
{password: "MyPassword",// provide password
location: "Local",
reason: "Any reason",
contactInfo: "555-5555",
appearance: "MyApperance"});
The code above can't loggin the certificate, the problem is that the password is ignored by the code, and I don't know why.
I did a test, if I pass a path of any other PFX certificate in my pc instead of the object certificate (oCerts[iSerial]) the code above works fine: read the password and can loggin the certificate.
Any idea, please??
Thanks all in advance!
When I use a smart card (PKCS#11 Device) inside the Acrobat, it recognises the smart card and I can sign de document using the card (no PFX certificates are needed).
When I plug the card in my pc, appears in the "Windows Certificate Store" the certificate that are stored in the card. So, using Javascript I found the serial number of the certicate stored in the smart card (I'm sure that the serial number is correct), and I tried to use it and Javascript to sign a pdf document, like below:
var myEngine = security.getHandler("Adobe.PPKLite");
var oCerts = myEngine.digitalIDs.certs;
var serial = "XXXXXX"; //serial number of the certificat that I am looking for in the "Windows Cert Store"
var iSerial;
//search in the windows store certificate for a certificate with the serial number informed
for (var i=0; i < oCerts.length; i++)
{
if (oCerts.serialNumber == serial)
i = iSerial;
}
console.println("Signing using the certificate: "+oCerts[iSerial]);
myEngine.login( {oParams:{oEndUserSignCert: oCerts[iSerial] , cPassword: "MyPassword"}});
var f = this.getField("SignHere");
f.signatureSign( myEngine,
{password: "MyPassword",// provide password
location: "Local",
reason: "Any reason",
contactInfo: "555-5555",
appearance: "MyApperance"});
The code above can't loggin the certificate, the problem is that the password is ignored by the code, and I don't know why.
I did a test, if I pass a path of any other PFX certificate in my pc instead of the object certificate (oCerts[iSerial]) the code above works fine: read the password and can loggin the certificate.
Any idea, please??
Thanks all in advance!
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting.
Learn more
Enthusiast
,
/t5/acrobat-sdk-discussions/add-digital-signature-using-c-and-acrobat-sdk/m-p/1133023#M79348
Mar 25, 2008
Mar 25, 2008
Copy link to clipboard
Copied
PKCS#11 (Cryptoki API) is just an abstract set of generic functions for (mostly) smart card certificates. In what format are your certificates on the smart card?
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting.
Learn more
_Fornachari_
AUTHOR
New Here
,
/t5/acrobat-sdk-discussions/add-digital-signature-using-c-and-acrobat-sdk/m-p/1133024#M79350
Mar 25, 2008
Mar 25, 2008
Copy link to clipboard
Copied
Hi PDL, thank you again.
I can't access the smart card directly, but, reading the documentation of the smart card, the format of the certificate is
PFX.
Any idea?
I can't access the smart card directly, but, reading the documentation of the smart card, the format of the certificate is
PFX.
Any idea?
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting.
Learn more
Enthusiast
,
/t5/acrobat-sdk-discussions/add-digital-signature-using-c-and-acrobat-sdk/m-p/1133025#M79352
Mar 25, 2008
Mar 25, 2008
Copy link to clipboard
Copied
PFX is usually PKCS#12. Strange, you should have the added password field (that field is only processed in a SignatureInfo variable on public-key certificates). Perhaps since it's coming from MSCAPI it is not seeing it as a public-key certificate.
If you just console.println(oCerts[iSerial]) what does it output?
If you just console.println(oCerts[iSerial]) what does it output?
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting.
Learn more
_Fornachari_
AUTHOR
New Here
,
/t5/acrobat-sdk-discussions/add-digital-signature-using-c-and-acrobat-sdk/m-p/1133026#M79354
Mar 25, 2008
Mar 25, 2008
Copy link to clipboard
Copied
[object Certificate = SubjectDN: cn=Felipe Fornachari, email=MyEmail, o=MyCompany, ou=MycompanyUnit, c=MyCountry]
I just change my personal informations, but the output is like above.
This is the right output, is'nt it?
I just change my personal informations, but the output is like above.
This is the right output, is'nt it?
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting.
Learn more
Enthusiast
,
/t5/acrobat-sdk-discussions/add-digital-signature-using-c-and-acrobat-sdk/m-p/1133027#M79356
Mar 25, 2008
Mar 25, 2008
Copy link to clipboard
Copied
I just noticed something. When you're performing your login you are using an optional LoginParameters object.
myEngine.login( {oParams:{oEndUserSignCert: oCerts[iSerial] , cPassword: "MyPassword"}});
You are not specifying the cDIPath parameter which must point to your smart cards PKCS#11 library.
myEngine.login( {oParams:{oEndUserSignCert: oCerts[iSerial] , cPassword: "MyPassword"}});
You are not specifying the cDIPath parameter which must point to your smart cards PKCS#11 library.
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting.
Learn more
_Fornachari_
AUTHOR
New Here
,
/t5/acrobat-sdk-discussions/add-digital-signature-using-c-and-acrobat-sdk/m-p/1133028#M79360
Mar 25, 2008
Mar 25, 2008
Copy link to clipboard
Copied
Thank you PDL, but It isn't the problem.
I tried now this:
myEngine.login( {oParams:{cPassword: "MyPassword", cDIPath: oCerts[iSerial]}});
But did not work. But, if I pass a valid PFX path instead of oCerts[iSerial], this code works, like the other.
I tried now this:
myEngine.login( {oParams:{cPassword: "MyPassword", cDIPath: oCerts[iSerial]}});
But did not work. But, if I pass a valid PFX path instead of oCerts[iSerial], this code works, like the other.
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting.
Learn more
Enthusiast
,
/t5/acrobat-sdk-discussions/add-digital-signature-using-c-and-acrobat-sdk/m-p/1133029#M79362
Mar 25, 2008
Mar 25, 2008
Copy link to clipboard
Copied
Yes, that is because your certificate is not a PKCS#11 Library. That is stored on the smart card. You may have to discuss with the manufacturer how to access it.
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting.
Learn more
_Fornachari_
AUTHOR
New Here
,
/t5/acrobat-sdk-discussions/add-digital-signature-using-c-and-acrobat-sdk/m-p/1133030#M79364
Mar 25, 2008
Mar 25, 2008
Copy link to clipboard
Copied
Ok, thank you!
I will search a little more.
I will search a little more.
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting.
Learn more
New Here
,
LATEST
/t5/acrobat-sdk-discussions/add-digital-signature-using-c-and-acrobat-sdk/m-p/1133035#M79374
Feb 16, 2010
Feb 16, 2010
Copy link to clipboard
Copied
Fornachari,
I am looking for a solution for a very similar problem - Signing a PDF with C# and Acrobat SDK using certificate stored in a USB Token.
Did you find a solution for this? Any help is really appreciated.
Thanks,
Paddy
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting.
Learn more
New Here
,
/t5/acrobat-sdk-discussions/add-digital-signature-using-c-and-acrobat-sdk/m-p/1133031#M79366
Jun 19, 2008
Jun 19, 2008
Copy link to clipboard
Copied
Hi PDL/Fornachari,
I am using VB.Net and i have to create .PostScript file using Adobe javascript.
I am able to create .ps in abode using javascript.
Now I want to call that Javascript in my VB.Net code using JSO object.
I copied the javascript in C:\Program Files\Adobe\Acrobat 8.0\Acrobat\Javascripts folder.
VB.NET Code:-
Dim gApp As Acrobat.CAcroApp
Dim gPDDoc As Acrobat.CAcroPDDoc
Dim jso As Object
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
gApp = CreateObject("AcroExch.App")
gPDDoc = CreateObject("AcroExch.PDDoc")
jso = gPDDoc.GetJSObject
End Sub
Adobe Javasccript:-
function JSPDFTOPS(theDoc)
{
var pp = theDoc.getPrintParams();
pp.interactive = pp.constants.interactionLevel.silent;
var fv = pp.constants.flagValues;
pp.flags |= fv.setPageSize;
theDoc.print(pp);
}
Now please guide how can i call this javascript into my VB.Net code.
Thanks in Advance
I am using VB.Net and i have to create .PostScript file using Adobe javascript.
I am able to create .ps in abode using javascript.
Now I want to call that Javascript in my VB.Net code using JSO object.
I copied the javascript in C:\Program Files\Adobe\Acrobat 8.0\Acrobat\Javascripts folder.
VB.NET Code:-
Dim gApp As Acrobat.CAcroApp
Dim gPDDoc As Acrobat.CAcroPDDoc
Dim jso As Object
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
gApp = CreateObject("AcroExch.App")
gPDDoc = CreateObject("AcroExch.PDDoc")
jso = gPDDoc.GetJSObject
End Sub
Adobe Javasccript:-
function JSPDFTOPS(theDoc)
{
var pp = theDoc.getPrintParams();
pp.interactive = pp.constants.interactionLevel.silent;
var fv = pp.constants.flagValues;
pp.flags |= fv.setPageSize;
theDoc.print(pp);
}
Now please guide how can i call this javascript into my VB.Net code.
Thanks in Advance
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting.
Learn more
Explorer
,
/t5/acrobat-sdk-discussions/add-digital-signature-using-c-and-acrobat-sdk/m-p/1133032#M79368
Jun 19, 2008
Jun 19, 2008
Copy link to clipboard
Copied
>I am using VB.Net and i have to create .PostScript file using Adobe javascript.
Are you trying to add a digital signature? Are you using C#?
If not, I recommend you start a new topic, because adding to an
unrelated topic will be less helpful to you.
Good luck,
Aandi Inston
Are you trying to add a digital signature? Are you using C#?
If not, I recommend you start a new topic, because adding to an
unrelated topic will be less helpful to you.
Good luck,
Aandi Inston
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting.
Learn more
New Here
,
/t5/acrobat-sdk-discussions/add-digital-signature-using-c-and-acrobat-sdk/m-p/1133033#M79370
Jun 19, 2008
Jun 19, 2008
Copy link to clipboard
Copied
Hi Aandi Inston,
I posted a new topic.
Thanks a lot for your response.
I posted a new topic.
Thanks a lot for your response.
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting.
Learn more

