Content
Prerequisites .................................................................................................................. 3
How to Use the SDK ....................................................................................................... 3
Running Your Application ............................................................................................... 4
How to Build Your Application ....................................................................................... 5
Add Security Dynamic Watermark to the File Encrypted by RMS ............................... 14
How to Debug Applications that Use RMS PDF Protection Tool .................................. 17
How to Understand Common Error Conditions and Solutions .................................... 19
Quick Start for Using Windows Azure AD Right Management .................................... 20
Prerequisites
Step 1: Install the AD RMS Services Client
To run this SDK, you must have the latest version of the AD RMS client installed. If you have an
existing older version of the AD RMS client installed, you will need to uninstall the old version first
and then download and install the latest version of the AD RMS client from below:
For X86:
http://us-request.foxitservice.com/products/redirect.php?title=ad_rms_sdk_x86&language=en_
us
For X64:
http://us-request.foxitservice.com/products/redirect.php?title=ad_rms_sdk_x64&language=en_
us
As for using Windows Azure AD Right Management (AAD RM), please refer to the Quick Start
for Using Windows Azure AD Right Management.
Step 2: Install and configure RMS Server
About how to install and configure an RMS Server, please see AD RMS Step-by-Step Guide .
How to Use the SDK
i. Unzip the installation package to a directory, for example, D:\ Foxit RMS PDF Protection
Tool(SDK).
ii. Add the file frms.h under the directory "Foxit RMS PDF Protection Tool(SDK)\include" to your
project, so that you can check each interface conveniently.
iii. Add the file FPDFRMS.lib to the project, for example, add #pragma comment(lib,"D:\\ Foxit
RMS PDF Protection Tool(SDK)\\library\\FPDFRMS.lib") to the file stdafx.cpp (pre-compiled
file).
iv. Include the header file frms.h in the file which needs to use SDK interfaces, for example, add
include " D:\\ Foxit RMS PDF Protection Tool(SDK)\\library\\frms.h" to the file stdafx.h
(pre-compiled file).
v. Copy the file FPDFRMS.dll under “Foxit RMS PDF Protection Tool(SDK)\library” to the same
directory where your application program locates.
Running Your Application
In order to run your RMS application you need to generate a signed application manifest. This
guide shows how to generate a manifest
On your development machine:
1. Copy the following files to a single directory:
“Foxit RMS PDF Protection Tool(SDK)\tools\Genmanifest.exe”
“Foxit RMS PDF Protection Tool(SDK)\tools\ isvtier5appsigningprivkey.dat”
“Foxit RMS PDF Protection Tool(SDK)\tools\ isvtier5appsigningpubkey.dat”
“Foxit RMS PDF Protection Tool(SDK)\tools\ isvtier5appsignsdk_client.xml”
“Foxit RMS PDF Protection Tool(SDK)\tools\< YourAppName >.bat”
“Foxit RMS PDF Protection Tool(SDK)\tools\< YourAppName >.mcf”
< YourAppName >.exe
Note: If it's the pre-production environment, please copy the files “isvtier5appsigningprivkey.dat”,
“isvtier5appsigningpubkey.dat” and “isvtier5appsignsdk_client.xml” under the directory of
“FoxitPDF_ADRMS_SDK_10\tools\pre-production”.
2. In this same directory, use notepad.exe to open the file < YourAppName >.mcf. Modify
the option REQ HASH "YourAppName.exe", and fill in the name of your application
program. The file should have the following contents:
AUTO-GUID
"isvtier5appsigningprivkey.dat"
MODULELIST
REQ HASH "YourAppName.exe"
POLICYLIST
INCLUSION
PUBLICKEY "isvtier5appsigningpubkey.dat"
EXCLUSION
NOTE: Ensure that “YourAppName.exe” is consistent with the actual < YourAppName >.exe.
3. In this same directory, use notepad.exe to open the file < YourAppName >.bat. Modify the
option YourAppName.exe.man, and fill in the name of your application program. The file
should have the following contents:
cd %~dp0
genmanifest.exe -chain isvtier5appsignsdk_client.xml YourAppName.mcf
YourAppName.exe.man
NOTE: Ensure that the file YourAppName.mcf and the file “YourAppName” under
YourAppName.exe.man are consistent with the actual ones.
4. You will get a file “YourAppName.exe.man” by double-clicking the file YourAppName.bat.
Note: If the program YourAppName.exe has been modified, you should regenerate the file <
YourAppName >.exe.man.
5. Copy the following files to your RMS server:
< YourAppName >.exe
< YourAppName >.exe.man
FPDFRMS.dll
6. Run your application. You can run the application from any directory, but your generated
manifest (<YourAppName >.exe.man and FPDFRMS.dll) must be in the same directory as <
YourAppName >.exe
How to Build Your Application
1. Before you can call any functions, you need to first call FRMS_UnlockLibrary function to
unlock the library. If you are in free 30-day trial, don't pass any parameter to the function
FRMS_UnlockLibrary, for example, FRMSAPI FRMS_HRESULT FRMS_UnlockLibrary().
Example:
// Use the Key information to unlock the library
FRMS_HRESULT hr =
FRMS_UnlockLibrary("XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX");
if (FRMS_HRESULT_OK != hr)
{
DisplayFRMSError(hr);
goto Exit;
}
2. Initialize the SDK with FRMS_Initialize. Before the application exits, destroy the library to
release resources.
Example:
//Initalize the SDK with library
hr = FRMS_Initialize(FRMS_API_MODE_CLIENT);
if (FRMS_HRESULT_OK != hr)
{
DisplayFRMSError(hr);
goto Exit;
}
//Release all resources allocated by the SDK library
if(Null != hProtector)
{
FRMSProtector_Release(hProtector);
}
.
NOTE: If failing to call the function, 1. ensure you have called the function FRMS_UnlockLibrary
successfully. 2. check whether the AD RMS environment has been set up correctly if the function
FRMS_UnlockLibrary is returned successfully.
3. Sets the source to be protected. It can be a folder containing PDF files or can be a PDF file
path.
Example:
//Set the PDF file path
wchar_t wsSource[20] = L"C:\\test.pdf";
FRMS_HPROTECTOR hProtector = NULL;
Hr = FRMSProtector_Create(&hProtector);
if (NULL != hProtector)
{
hr = FRMSProtector_SetSource(hProtector,wsSource);
if(hr != FRMS_HRESULT_OK)
{
DisplayFRMSError(hr);
goto Exit;
}
}
4. Get all Issuers.
Example:
int nCount = 0;
// Gets the count of issuers
hr = FRMSProtector_GetIssuerCount(hProtector, this->GetSafeHwnd(), &nCount);
if(hr != FRMS_HRESULT_OK)
{
DisplayFRMSError(hr);
goto Exit;
}
for(int i=0; i<nCount; i++)
{
LPWSTR lpwsIssuer = NULL;
int nLen = 0;
// Gets the length of the issuer name
hr = FRMSProtector_GetIssuer(hProtector, i, this->GetSafeHwnd(), lpwsIssuer, &nLen);
if(hr != FRMS_HRESULT_OK)
{
DisplayFRMSError(hr);
goto Exit;
}
lpwsIssuer = new wchar_t[nLen];
memset(lpwsIssuer, 0, sizeof(wchar_t)*nLen);
//Gets the issuer name by index
hr = FRMSProtector_GetIssuer(hProtector, i, this->GetSafeHwnd(), lpwsIssuer, &nLen);
if(hr != FRMS_HRESULT_OK)
{
DisplayFRMSError(hr);
delete [] lpwsIssuer;
goto Exit;
}
}
5. Get the number of Rights Poilcy Template.
Example:
int nTemplateCount = 0;
//Gets the count of RMS rights policy templates of the specified issuer.
hr = FRMSProtector_GetTemplateCount(hProtector, lpwsIssuer, TRUE, this->GetSafeHwnd(),
&nTemplateCount);
if (hr != FRMS_HRESULT_OK)
{
DisplayFRMSError(hr);
delete [] lpwsIssuer;
goto Exit;
}
6. Get the names of all templates.
Example:
for(int j=0; j<nTemplateCount; j++)
{