Handling returned documents

Service operations that return a PDF document (or other data types such as XML data) as an output value return a com.adobe.idp.Document object. After you receive a com.adobe.idp.Document object, you can convert it to the following formats:

  • A java.io.File object

  • A java.io.InputStream object

  • A byte array

The following line of code converts a com.adobe.idp.Document object to a java.io.InputStream object. Assume that myPDFDocument represents a com.adobe.idp.Document object:

    java.io.InputStream resultStream = myDocument.getInputStream();

Likewise, you can copy the contents of a com.adobe.idp.Document to a local file by performing the following tasks:

  1. Create a java.io.File object.

  2. Invoke the com.adobe.idp.Document object’s copyToFile method and pass the java.io.File object.

The following code example copies the contents of a com.adobe.idp.Document object to a file named AnotherMap.pdf.

Copying the contents of a document object to a file

File outFile = new File("C:\\AnotherMap.pdf"); 
myDocument.copyToFile (outFile);

// Ethnio survey code removed