|
|
The following code example certifies a PDF document that is based on a PDF file named Loan.pdf. The alias that is specified for the security credential is TonyB and revocation checking is not performed.using System;using System.Collections;using System.ComponentModel;using System.Data;using System.IO ;namespace SignDocument{class Class1{[STAThread]static void Main(string[] args){try{//Create a SignatureServiceService client objectSignatureServiceService signClient = new SignatureServiceService();signClient.Credentials = new System.Net.NetworkCredential("administrator", "password");//Create a BLOB to store a PDF document to signBLOB inDoc = new BLOB();//Specify a PDF document to signstring path = "C:\\Adobe\\Loan.pdf";FileStream fs = new FileStream(path, FileMode.Open);//Get the length of the file streamint len = (int)fs.Length;byte[] ByteArray=new byte[len];//Populate the byte array with the contents of the FileStream objectfs.Read(ByteArray, 0, len);inDoc.binaryData = ByteArray;//Specify the name of the signature fieldstring fieldName = "SignatureField1[0]";//Create a Credential objectCredential myCred = new Credential();myCred.alias="tonyb";//Specify the reason to sign the documentstring reason = "The document was reviewed";//Specify the location of the signerstring location = "New York HQ";//Specify contact informationstring contactInfo = "Tony Blue";//Create a PDFSignatureAppearanceOptions object//and show date informationPDFSignatureAppearanceOptionSpec appear = new PDFSignatureAppearanceOptionSpec();appear.showDate = true;//Specify a legalAttestation valuestring msg = "Any change to this document will invalidate the certificate";//Certify the PDF documentBLOB signedDoc = signClient.certify(inDoc,fieldName,myCred,HashAlgorithm.SHA1,true,reason,location,contactInfo,MDPPermissions.NoChanges,true,msg,appear,false,false,false,false,null,null,null);//Populate a byte array with a BLOB databyte[] outByteArray=signedDoc.binaryData;//Save the signed PDF documentstring fileName ="C:\\Adobe\\Loan55.pdf" ;FileStream fs2 = new FileStream(fileName, FileMode.OpenOrCreate);//Create a BinaryWriter objectBinaryWriter w = new BinaryWriter(fs2);w.Write(outByteArray);w.Close();fs2.Close();}catch (Exception ee){Console.WriteLine(ee.Message);}}}}
Send me an e-mail when comments are added to this page | Comment Report
Current page: http://livedocs.adobe.com/livecycle/es/sdkHelp/programmer/sdkHelp/quickStarts_Signatures.16.9.html