View comments | RSS feed
API Quick Starts (Code Examples) > Rights Management Service API Quick Starts > Quick Start: Creating a new watermark using the Java API

Quick Start: Creating a new watermark using the Java API
The following code example creates a new watermark named Confidential. The custom text attribute is set to display Confidential.
/*
 * This Java Quick Start uses the following JAR files
 * 1. adobe-rightsmanagement-client.jar
 * 2. namespace.jar (if LiveCycle ES is deployed on JBoss)
 * 3. jaxb-api.jar (if LiveCycle ES is deployed on JBoss)
 * 4. jaxb-impl.jar (if LiveCycle ES is deployed on JBoss)
 * 5. jaxb-libs.jar (if LiveCycle ES is deployed on JBoss)
 * 6. jaxb-xjc.jar (if LiveCycle ES is deployed on JBoss)
 * 7. relaxngDatatype.jar (if LiveCycle ES is deployed on JBoss)
 * 8. xsdlib.jar (if LiveCycle ES is deployed on JBoss)
 * 2. adobe-livecycle-client.jar
 * 3. adobe-usermanager-client.jar
 * 4. adobe-utilities.jar
 * 5. jbossall-client.jar (use a different JAR file if LiveCycle ES is not deployed on JBoss)
 * 
 * These JAR files are located in the following path:
 * <install directory>/Adobe/LiveCycle8/LiveCycle_ES_SDK/client-libs
 * 
 * For complete details about the location of these JAR files, 
 * see "Including LiveCycle ES library files" in Programming
 * with LiveCycle ES
 */
import java.util.*;
 
import com.adobe.idp.dsc.clientsdk.ServiceClientFactory;
import com.adobe.idp.dsc.clientsdk.ServiceClientFactoryProperties;
import com.adobe.livecycle.rightsmanagement.client.*;
import com.adobe.livecycle.rightsmanagement.client.infomodel.*;
 
 
public class CreateWatermarks {
 
	public static void main(String[] args) {
		
		try
		{
		//Set connection properties required to invoke LiveCycle ES								
		Properties connectionProps = new Properties();
		connectionProps.setProperty(ServiceClientFactoryProperties.DSC_DEFAULT_EJB_ENDPOINT, "jnp://localhost:1099");
		connectionProps.setProperty(ServiceClientFactoryProperties.DSC_TRANSPORT_PROTOCOL,ServiceClientFactoryProperties.DSC_EJB_PROTOCOL);          
		connectionProps.setProperty(ServiceClientFactoryProperties.DSC_SERVER_TYPE, "JBoss");
		connectionProps.setProperty(ServiceClientFactoryProperties.DSC_CREDENTIAL_USERNAME, "administrator");
		connectionProps.setProperty(ServiceClientFactoryProperties.DSC_CREDENTIAL_PASSWORD, "password");
 
		//Create a ServiceClientFactory instance
		ServiceClientFactory factory = ServiceClientFactory.createInstance(connectionProps);
		
		//Create a RightsManagementClient object
		RightsManagementClient rightsClient = new RightsManagementClient(factory); 
		
			//Create a Watermark object
			Watermark myWatermark =  InfomodelObjectFactory.createWatermark();
			
			//Set the name attribute
			myWatermark.setName("Confidential");
			
			//Set the background attribute
		  	myWatermark.setBackground(true);
		  	
			//Set the setHorizontalAlignment attribute
			myWatermark.setHorizontalAlignment(Watermark.HORIZONTAL_ALIGNMENT_CENTER);
			
			//Set the custom text attribute
		  	myWatermark.setCustomText("Confidential");
					  				
			//Set the opacity attribute
		  	myWatermark.setOpacity(80);
			
			//Register the watermark
			WatermarkManager watermarkManager  = rightsClient.getWatermarkManager();
		  	String waterId = watermarkManager.registerWatermark(myWatermark);
		  	
		  	System.out.println("The identifier of the registered watermark is "+waterId);
			}
	
			catch (Exception ex)
			{
				ex.printStackTrace(); 
			}
		}
}
 

API Quick Starts (Code Examples) > Rights Management Service API Quick Starts > Quick Start: Creating a new watermark using the Java API

Programming with LiveCycle ES (LiveDocs)
Adobe LiveCycle ES Update 1

Comments


Yogesh Gandhi said on Sep 23, 2008 at 11:00 PM :
Hi,

This code is fine, it registers a watermark and gives back the watermark id.

Now I want to add this watermark while converting from doc to PDF.

Can anybody please share this information, about how to do it.

I have the code of converting from word to PDF at

http://livedocs.adobe.com/livecycle/8.2/programLC/programmer/help/wwhelp/wwhimpl/common/html/wwhelp.htm?context=sdkHelp&file=000089.html

My e-mail : yogesh249@gmail.com

Regards
Yogesh
smacdonald2008 said on Sep 24, 2008 at 7:31 AM :
You are close to what you want to do. You have created the watermark. Next you have to create a policy that uses the policy.

See the Creating a policy Quick Start. When setting policy attributes, set the watermark by calling:

myPolicy.setWatermarkId("Watermark ID")

Pass a string value that represents the watermark ID to setWatermarkId.

(instead of creating a new policy-- you can modify an existing one. See Quick Start: Modifying a policy using the Java API. But you still need to call serWatermarkId)

After that, all you to do is secure the PDF that you created with the policy associated with the watermark.

See the Applying a policy to a PDF document using the Java API Quick Start.

Thanks for your comment and hope this helps.

 

RSS feed | Send me an e-mail when comments are added to this page | Comment Report

Current page: http://livedocs.adobe.com/livecycle/8.2/programLC/programmer/help/000149.html