Take a survey

API Quick Starts (Code Examples) > Signature Service API Quick Starts > Quick Start: Certifying a PDF document using the web service API

Quick Start: Certifying a PDF document using the web service API
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 object
				SignatureServiceService  signClient = new SignatureServiceService(); 
				signClient.Credentials = new System.Net.NetworkCredential("administrator", "password");
       
				//Create a BLOB to store a PDF document to sign
				BLOB inDoc = new BLOB();
 
				//Specify a PDF document to sign
				string path = "C:\\Adobe\\Loan.pdf";
				FileStream fs = new FileStream(path, FileMode.Open);
 
				//Get the length of the file stream 
				int len = (int)fs.Length; 
				byte[] ByteArray=new byte[len];
 
				//Populate the byte array with the contents of the FileStream object
				fs.Read(ByteArray, 0, len);
				inDoc.binaryData = ByteArray; 
 
				//Specify the name of the signature field
				string fieldName = "SignatureField1[0]";
 
				//Create a Credential object
				Credential myCred = new Credential(); 
				myCred.alias="tonyb"; 
					
				//Specify the reason to sign the document
				string reason = "The document was reviewed";
 
				//Specify the location of the signer
				string location  = "New York HQ"; 
 
				//Specify contact information
				string contactInfo = "Tony Blue";
			
				//Create a PDFSignatureAppearanceOptions object 
				//and show date information
				PDFSignatureAppearanceOptionSpec appear = new PDFSignatureAppearanceOptionSpec();
				appear.showDate = true;
			
				//Specify a legalAttestation value
				string msg = "Any change to this document will invalidate the certificate";	
 
				//Certify the PDF document
				BLOB 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 data
				byte[] outByteArray=signedDoc.binaryData; 
 
				//Save the signed PDF document
				string fileName ="C:\\Adobe\\Loan55.pdf" ; 
				FileStream fs2 = new FileStream(fileName, FileMode.OpenOrCreate);
 
				//Create a BinaryWriter object
				BinaryWriter 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