0 Replies Latest reply on Aug 6, 2009 3:35 AM by vajralavenkat

    Problem with converting html to pdf using LiveCycle ES Java API

    vajralavenkat

      I am using this code to convert html to pdf.

       

      /*

       

      * 1. adobe-generatepdf-client.jar

       

      * 2. adobe-livecycle-client.jar

       

      * 3. adobe-usermanager-client.jar

       

      * 4. adobe-utilities.jar

       

      * 5. wlclient.jar

       

      */

       

      import java.io.File;

       

      import java.util.Properties;

       

      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.GeneratePdfServiceClient;

       

      import com.adobe.livecycle.generatepdf.client.HtmlToPdfResult;

       

      public class ConvertHTML {

       

         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, "t3://localhost:7001");

       

              connectionProps.setProperty(ServiceClientFactoryProperties.DSC_TRANSPORT_PROTOCOL,Service ClientFactoryProperties.DSC_EJB_PROTOCOL);       

       

              connectionProps.setProperty(ServiceClientFactoryProperties.DSC_SERVER_TYPE, "WebLogic");

       

              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 GeneratePdfServiceClient object

       

              GeneratePdfServiceClient pdfGenClient = new GeneratePdfServiceClient(factory);

       

             //Get an HTML document to convert to a PDF document a

       

              String inputFileName = "http://www.adobe.com";
              //String inputFileName = "C:\\Documents and Settings\\venkat\\Desktop\\Adobe.htm";

       

              String securitySettings = "No Security";

       

              String fileTypeSettings = "Standard";

       

      System.out.println("one");

       

              //Convert HTML content to a PDF document

       

              HtmlToPdfResult result = pdfGenClient.htmlToPDF2(inputFileName, fileTypeSettings, securitySettings, null, null);
      System.out.println("two");         

       

              //Get the newly created document

       

              Document createdDocument = result.getCreatedDocument();

       

              //Save the PDF document as a PDF file

       

              createdDocument.copyToFile(new File("C:\\test.pdf"));

       

          }

       

          catch (Exception e) {

       

              System.out.println("Error OCCURRED: " + e.getMessage());
              e.printStackTrace();

       

          }

       

      }

       

      }

       

       

       

      I can able to compile this class but while running i am getting error like below.

      Error OCCURRED: Internal error.
      ALC-DSC-000-000: com.adobe.idp.dsc.DSCRuntimeException: Internal error.
              at com.adobe.idp.dsc.provider.impl.ejb.EjbMessageDispatcher.doSend(EjbMessageDispatcher.java
      :160)
              at com.adobe.idp.dsc.provider.impl.base.AbstractMessageDispatcher.send(AbstractMessageDispat
      cher.java:57)
              at com.adobe.idp.dsc.clientsdk.ServiceClient.invoke(ServiceClient.java:208)
              at com.adobe.livecycle.generatepdf.client.GeneratePdfServiceClient.htmlToPDF2(GeneratePdfSer
      viceClient.java:666)
              at ConvertHTML.main(ConvertHTML.java:84)
      Caused by: java.rmi.RemoteException: Remote EJBObject lookup failed for 'ejb/Invocation'; nested exc
      eption is:
              org.omg.CORBA.COMM_FAILURE:   vmcid: SUN  minor code: 203  completed: No
              at com.adobe.idp.dsc.provider.impl.ejb.EjbMessageDispatcher.initialise(EjbMessageDispatcher.
      java:101)
              at com.adobe.idp.dsc.provider.impl.ejb.EjbMessageDispatcher.doSend(EjbMessageDispatcher.java
      :130)
              ... 4 more
      Caused by: org.omg.CORBA.COMM_FAILURE:   vmcid: SUN  minor code: 203  completed: No
              at com.sun.corba.se.impl.logging.ORBUtilSystemException.writeErrorSend(Unknown Source)
              at com.sun.corba.se.impl.logging.ORBUtilSystemException.writeErrorSend(Unknown Source)
              at com.sun.corba.se.impl.transport.SocketOrChannelConnectionImpl.writeLock(Unknown Source)
              at com.sun.corba.se.impl.encoding.BufferManagerWriteStream.sendFragment(Unknown Source)
              at com.sun.corba.se.impl.encoding.BufferManagerWriteStream.sendMessage(Unknown Source)
              at com.sun.corba.se.impl.encoding.CDROutputObject.finishSendingMessage(Unknown Source)
              at com.sun.corba.se.impl.protocol.CorbaMessageMediatorImpl.finishSendingRequest(Unknown Sour
      ce)
              at com.sun.corba.se.impl.protocol.CorbaClientRequestDispatcherImpl.marshalingComplete1(Unkno
      wn Source)
              at com.sun.corba.se.impl.protocol.CorbaClientRequestDispatcherImpl.marshalingComplete(Unknow
      n Source)
              at com.sun.corba.se.impl.protocol.CorbaClientDelegateImpl.invoke(Unknown Source)
              at com.sun.corba.se.impl.protocol.CorbaClientDelegateImpl.is_a(Unknown Source)
              at org.omg.CORBA.portable.ObjectImpl._is_a(Unknown Source)
              at weblogic.corba.j2ee.naming.Utils.narrowContext(Utils.java:126)
              at weblogic.corba.j2ee.naming.InitialContextFactoryImpl.getInitialContext(InitialContextFact
      oryImpl.java:94)
              at weblogic.corba.j2ee.naming.InitialContextFactoryImpl.getInitialContext(InitialContextFact
      oryImpl.java:31)
              at weblogic.jndi.WLInitialContextFactory.getInitialContext(WLInitialContextFactory.java:41)
              at javax.naming.spi.NamingManager.getInitialContext(Unknown Source)
              at javax.naming.InitialContext.getDefaultInitCtx(Unknown Source)
              at javax.naming.InitialContext.init(Unknown Source)
              at javax.naming.InitialContext.<init>(Unknown Source)
              at com.adobe.idp.dsc.provider.impl.ejb.EjbMessageDispatcher.initJndiContext(EjbMessageDispat
      cher.java:213)
              at com.adobe.idp.dsc.provider.impl.ejb.EjbMessageDispatcher.getJndiContext(EjbMessageDispatc
      her.java:226)
              at com.adobe.idp.dsc.provider.impl.ejb.EjbMessageDispatcher.initialise(EjbMessageDispatcher.
      java:87)
              ... 5 more

       

       

       

       

      can u plz give me some way to do the convertion.