Expand my Community achievements bar.

Conversion of Word Document into PDF

Avatar

Level 1

I was trying out the code sample provided in the sdk help on converting the word document into pdf. I could not get the code to work and was prompted with the following exception:

java.lang.IllegalStateException
        at com.adobe.idp.dsc.clientsdk.ServiceClientFactory$1.handleThrowable(ServiceClientFactory.java:67)
        at com.adobe.idp.dsc.clientsdk.ServiceClient.invoke(ServiceClient.java:220)
        at com.adobe.livecycle.generatepdf.client.GeneratePdfServiceClient.createPDF(GeneratePdfServiceClient.java:172)
        at testadobeapp.Main.main(Main.java:49)
Caused by: java.lang.NoClassDefFoundError: javax/ejb/EJBException
        at com.adobe.idp.dsc.clientsdk.ServiceClientFactory.evaluateMessageDispatcher(ServiceClientFactory.java:558)
        at com.adobe.idp.dsc.clientsdk.ServiceClient.invoke(ServiceClient.java:215)
        ... 2 more

My code is as follows:


package testadobeapp;

import java.util.*;
import com.adobe.idp.Document;
import com.adobe.idp.dsc.clientsdk.ServiceClientFactory;
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("DSC_DEFAULT_EJB_ENDPOINT", "t3://20.2.150.64:8001");
            ConnectionProps.setProperty("DSC_TRANSPORT_PROTOCOL", "EJB");
            ConnectionProps.setProperty("DSC_SERVER_TYPE", "Weblogic");
            ConnectionProps.setProperty("DSC_CREDENTIAL_USERNAME", "username");
            ConnectionProps.setProperty("DSC_CREDENTIAL_PASSWORD", "password");

            ServiceClientFactory factory = ServiceClientFactory.createInstance(ConnectionProps);

        try {
            String inputFilename = "c:\\test.docx";
            FileInputStream fileInputStream = new FileInputStream(inputFilename);
            Document inDoc = new Document(fileInputStream);
            String adobePDFSettings = "Standard";
            String securitySettings = "No Security";
            String fileTypeSettings = "Standard";

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

            Document createdDocument = result.getCreatedDocument();
            createdDocument.copyToFile((new File("C:\\test.pdf")));


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

    }
}

Am I missing something here? Thanks in advance.

2 Replies

Avatar

Level 10

Based on your exception:

used by: java.lang.NoClassDefFoundError: javax/ejb/EJBException
        at com.adobe.idp.dsc.clientsdk.ServiceClientFactory.evaluateMessageDispa tcher(ServiceClientFactory.java:558)
        at com.adobe.idp.dsc.clientsdk.ServiceClient.invoke(ServiceClient.java:2 1

Looks like the ServiceClient cannot locate your instnace of LC ES. This exception is not related to a PDFG operation -- if it was - you would have an exception something like:

ALC-PDG-80023-000: com.adobe.livecycle.generatepdf.client.ConversionException:

Error message from the primary converter:
ALC-PDG-080-023-Acrobat_PATH environment variable either not set or is invalid. Please set this variable to point to Acrobat.exe in Acrobat version 9 with update 1. Acrobat_PATH should be set to <Acrobat_Home>\Acrobat 9.0\Acrobat\Acrobat.exe. Here <Acrobat_Home> is the parent folder where the Acrobat is installed.

Error message from the fallback converter:
ALC-PDG-011-030-Submitted OpenOffice Document could not be converted to PDF. Either OpenOffice is not installed on this system or environment variable OpenOffice_PATH is not set

I would try another service like the Encryption service and see if you can encrypt a PDF with a password. This will rule out a problem with your client being able to invoke your instance of the server.