Expand my Community achievements bar.

how to fetche given page before converting to pdf in live cycle

Avatar

Former Community Member

i want to covert 5 to 10 peeages of word document into pdf. we need to get  these pages from an document of 100 pages. so before converting into pdf is there anyway to ftch the specified pages from the document and then convert only those pages.

please share how to do that and share some code snippet or xml document to do that

8 Replies

Avatar

Level 1

You may use the LiveCycle Assembler Service  to achieve this use case.  Assembler Service requires a DDX document used to specify instructions for assembling the PDF document ( in this case it will be  the range of pages to be assembled into PDF ) . Since the input here is a native file format (e.g. word doc ) , LiveCycle Generate PDF service must be installed/configured to convert native formats to PDF as Assembler service can call only services installed with LiveCycle.

Find below a sample DDX(xml)  that fetches the page range  to assemble into resultant PDF.

<DDX xmlns="http://ns.adobe.com/DDX/1.0/">

    <PDF result="out.pdf">

        <PDF source="testdoc.docx" pages="5-10"/>

       

    </PDF>

</DDX>

The following  JAVA code (SOAP method ) uses the DDX doc to assembles  PDF. Please edit the below location as per your environment and run the JAVA code.

  • A Document Description XML (DDX) document : ( in this case  C://DDX.xml )
  • The input document  : ( in this case  C://testdoc.docx )
  • A location to store the resulting PDF document : ( in this case C:// AssemblerResult.pdf )

import com.adobe.livecycle.assembler.client.*;

import java.util.*;

import java.io.File;

import java.io.FileInputStream;

import com.adobe.idp.Document;

import com.adobe.idp.dsc.clientsdk.ServiceClientFactory;

import com.adobe.idp.dsc.clientsdk.ServiceClientFactoryProperties;

public class AssemblerPDF

{

    public static void main(String[] args) {

        try{

            //Set connection properties required to invoke LiveCycle ES2                               

Properties connectionProps = new Properties();

connectionProps.setProperty(ServiceClientFactoryProperties.DSC_DEFAULT_SOAP_ENDPOINT, "http://<servername>:<port>");

connectionProps.setProperty(ServiceClientFactoryProperties.DSC_TRANSPORT_PROTOCOL,ServiceClientFactoryProperties.DSC_SOAP_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 myFactory = ServiceClientFactory.createInstance(connectionProps);

           

            //Create an AssemblerServiceClient object

AssemblerServiceClient assemblerClient = new AssemblerServiceClient(myFactory);

            //Create a FileInputStream object based on an existing DDX file

FileInputStream myDDXFile = new FileInputStream("C:\\DDX.xml");

            //Create a Document object based on the DDX file

Document myDDX = new Document(myDDXFile);

            //Create a Map object to store PDF source documents

            Map inputs = new HashMap();

FileInputStream mySourceMap = new FileInputStream("C:\\testdoc.docx");

           

            //Create a Document object based on the map.pdf source file

Document myPDFMapSource = new Document(mySourceMap);

           

            //Place entries into the Map object

            inputs.put("testdoc.docx",myPDFMapSource);

          

            //Create an AssemblerOptionsSpec object

AssemblerOptionSpec assemblerSpec = new AssemblerOptionSpec();

assemblerSpec.setFailOnError(false);

            //Submit the job to Assembler service

AssemblerResult jobResult = assemblerClient.invokeDDX(myDDX,inputs,assemblerSpec);  

            java.util.Map allDocs = jobResult.getDocuments();

            //Retrieve the result PDF document from the Map object

Document outDoc = null;

            //Iterate through the map object to retrieve the result PDF document

            for (Iterator i = allDocs.entrySet().iterator(); i.hasNext();) {

                // Retrieve the Map objects value

                Map.Entry e = (Map.Entry)i.next();

               

                //Get the key name as specified in the

                //DDX document

String keyName = (String)e.getKey();

                if (keyName.equalsIgnoreCase("out.pdf"))

{

Object o = e.getValue();

outDoc = (Document)o;

                    //Save the result PDF file

File myOutFile = new File("C:\\AssemblerResult.pdf");

outDoc.copyToFile(myOutFile);

}

}

}catch (Exception e) {

e.printStackTrace();

}

}

}

For further details , please refer the ddx reference (http://help.adobe.com/en_US/livecycle/9.0/ddxRef.pdf) examples on "page ranges" .

Sample JAVA code for Assembler Service quick starts is available at link ( http://help.adobe.com/en_US/livecycle/9.0/programLC/help/index.htm?content=000014.html ).

Avatar

Former Community Member

Hi,

Thanks Aayush.

Is there any way we can combine files into single pdf and add reader extension to it in a single call to adibe live cycle?

Avatar

Employee

Advithiya,

YEs, that is possible

Create an orchestration with first task to combine files and then use task to reader extend the combined PDF file.

Though it internally goes through multiple LC services it could be achieved with a single call to this orchestration

--Santosh

Avatar

Former Community Member

any example or code snippet will be helpfull.

Avatar

Former Community Member

How we can call this orchestration from other java application deployed in another jboss server?

Avatar

Former Community Member

Thanks santhosh.

In DDX file only we can mention to add readed extension to result  pdf and encrypt that pdf also.

I have one more question regarding assemble service

I have a pdf which is like a form but not created using live cycle designer.

my scenarion is i have some doc file,some txt file etc and a form pdf. i call assemble service  to assemble all the file. now i create a xml file with same form field as mentioned in form.pdf. currently we are calling import api of form data integration service to megre xml with form pdf.

now i want to do this using assembly service mentioning the form pdf and xml to merge in ddx so thar assembly service will take care of merging.

will that possible?

sample ddx;

<DDX xmlns="http://ns.adobe.com/DDX/1.0/">

    <PDF result="out.pdf">

        <PDF source="CoverSheetForm.pdf"/>

        <PDF source="test1.docx"/>

                    <PDF source="test2.txt"/>

 

      

    </PDF>

</DDX>

i have xml to merge is formdata.xml which is created based on coversheetform.pdf.(field name etc) now i want to merge this.

Is there any way to do that?

Avatar

Level 1

Hi Advithiya,

You may try the below DDX. However the XFAData  element being used here allows to merge data into PDF , for an XFA based form.

<DDX xmlns="http://ns.adobe.com/DDX/1.0/">

<PDF result="output.pdf">

<PDF source="test1.txt" />

<PDF source="test2.docx" />

<PDF source="testform3.pdf"  baseDocument="true">

<XFAData source="testdata.xml"/>

</PDF>

</PDF>

</DDX>

Thanks,
Aayush