2012年6月30日星期六

adobe livecycle es3的PDF Generator

折腾了3天,写了个java通过ejb终于可以call到ES3上面的服务了,tmd,才发现ES3没有Acrobat 根本没法ps->pdf。而Acrobat只有windows和mac的版本,没有linux版本。白折腾了,太阳。
付上测试的java程序,算个终结。编译时,要用到很多jar,根据classnotfound,逐步排查添加。
我添加到jar主要在以下目录
/home/adobe/adobe_livecycle_es3/sdk/client-libs/common
/home/adobe/adobe_livecycle_es3/sdk/client-libs/jboss
/home/adobe/adobe_livecycle_es3/sdk/client-libs/thirdparty
/home/adobe/glassfish3/glassfish/modules目下的 javax.ejb.jar
/home/adobe/jboss-5.1.0.GA/client目录下的jbossall-client.jar

在线帮助文档
http://help.adobe.com/en_US/livecycle/10.0/documentation.html#task=0,1,2,3,4,5,6&module=-1
http://help.adobe.com/en_US/livecycle/10.0/ProgramLC/index.html
PDF Generator支持的文件格式
http://www.adobe.com/products/livecycle/pdfgenerator/formats.html
package testadobe;

import java.util.*;
import com.adobe.idp.Document;
import com.adobe.idp.dsc.clientsdk.ServiceClientFactory;
import com.adobe.idp.dsc.clientsdk.ServiceClientFactoryProperties;
import com.adobe.livecycle.generatepdf.client.*;
import java.io.File;
import java.io.FileInputStream;

/**
*
* @author Administrator
*/
public class Main {

    /**
     * @param args the command line arguments
     */
    public static void main(String[] args) {
            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");

            ServiceClientFactory factory = ServiceClientFactory.createInstance(ConnectionProps);

        try {
            String inputFilename = "/home/adobe/eps/A2_color/s.eps";
            FileInputStream fileInputStream = new FileInputStream(inputFilename);
            Document inDoc = new Document(fileInputStream);
            String adobePDFSettings = "Standard";
            String securitySettings = "No Security";
            String fileTypeSettings = "Standard_eps";

            CreatePDFResult result = new CreatePDFResult();
            result = new GeneratePdfServiceClient(factory).createPDF(inDoc, inputFilename, fileTypeSettings, adobePDFSettings, securitySettings, null, null);

            Document createdDocument = result.getCreatedDocument();
            createdDocument.copyToFile((new File("/home/adobe/eps/A2_color/s.pdf")));


        } catch (Exception e) {
           e.printStackTrace();
   
        }

    }
}

没有评论:

发表评论