|
|
The following C# code example applies a policy named Allow Copy to a PDF document named Loan.pdf. The policy set to which the policy is added is named Global Policy Set.using System;using System.Collections;using System.ComponentModel;using System.Data;using System.IO ;namespace ApplyPolicy{class Class1{[STAThread]static void Main(string[] args){try{//Create a RightsManagementServiceService objectRightsManagementServiceService rmClient = new RightsManagementServiceService();rmClient.Credentials = new System.Net.NetworkCredential("administrator", "password");//Create a BLOB that represents the PDF document//to which a policy is appliedBLOB inDoc = new BLOB();//Reference the PDF document to which a policy is appliedstring inputFileName = "C:\\Adobe\\Loan.pdf";FileStream fs = new FileStream(inputFileName, FileMode.Open);//Get the length of the file stream and create a byte arrayint len = (int)fs.Length;byte[] byteArray = new byte[len];//Populate the byte array with the contents of the file streamfs.Read(byteArray, 0, len);//Populate the BLOB objectinDoc.binaryData = byteArray;//Apply a policy to a PDF document named Loan.pdfBLOB outDoc = rmClient.applyPolicy(inDoc,"Loan.pdf","Global Policy Set","Allow Copy",null,null);//Populate a byte array with the contents of the BLOBbyte[] outByteArray = outDoc.binaryData;//Create a new file containing the policy-protected PDF documentstring FILE_NAME = "C:\\Adobe\\PolicyProtectedLoanDoc.pdf";FileStream fs2 = new FileStream(FILE_NAME, FileMode.OpenOrCreate);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_RightsManagement.15.9.html