This API will create the multipage tif/pdf using “Image MagicK” or “IText” or “GhostScript”. This API works only for tif/tiff files. This API will have following parameters for configuration.

Request Method POST

Input Parameters

     Input Parameter Values Descriptions
imageProcessingAPI Either “IMAGE_MAGICK” /”GHOSTSCRIPT”/”ITEXT” This parameter is used for generating pdf using image_magick, itext and ghost script.
pdfOptimizationParams This value should not be empty. Reference for ghost script input parameter :

These are the ghost script output parameters used for optimizing the output file.
multipageTifSwitch Either “ON”/”OFF” This parameter is used for generating multipage tif along with multipage pdf.
pdfOptimizationSwitch Either “ON”/”OFF” This switch is used for generating optimized pdf.
ghostscriptPdfParameters This value should not be empty. Reference for ghost script input parameter :

This are the ghost script parameter used for creating multipage pdf.


Web Service URL: http://{serverName}:{port}/dcma/rest/createMultiPageFile



  1. Input only tiff file for processing and xml file for inputs.
  2. If “imageProcessingAPI” is “GHOSTSCRIPT”, than only ghostscriptPdfParameters will work.
  • If “pdfOptimizationSwitch” is “ON”, than pdfOptimizationParams will work.



Format for XML:

<Value>-q -dNODISPLAY -P- -dSAFER -dDELAYSAFER --</Value>
<Value>-dQUIET -dNOPAUSE -r300 -sDEVICE=pdfwrite -dBATCH</Value>

Sample client code using apache commons http client:-

private static void createMultiPage() {
		HttpClient client = new HttpClient();
		String url = "http://localhost:8080/dcma/rest/createMultiPageFile";
		PostMethod mPost = new PostMethod(url);
		// Adding XML file for parameters
		File file1 = new File("C:\\sample\\input.xml");
		// Adding tif file for processing
		File file2 = new File("C:\\sample\\Application.tif");
		File file3 = new File("C:\\sample\\US-Invoice.tif");
		Part[] parts = new Part[3];
		try {
			parts[0] = new FilePart(file1.getName(), file1);
			parts[1] = new FilePart(file2.getName(), file2);
			parts[2] = new FilePart(file3.getName(), file3);
			MultipartRequestEntity entity = new MultipartRequestEntity(parts, mPost.getParams());
			int statusCode = client.executeMethod(mPost);
			if (statusCode == 200) {
				InputStream inputStream = mPost.getResponseBodyAsStream();
				// Retrieving file from result
				File file = new File("C:\\sample\\");
				FileOutputStream fos = new FileOutputStream(file);
				try {
					byte[] buf = new byte[1024];
					int len =;
					while (len > 0) {
						fos.write(buf, 0, len);
						len =;
				} finally {
					if (fos != null) {
				System.out.println("Web service executed successfully..");
			} else if (statusCode == 403) {
				System.out.println("Invalid username/password..");
			} else {
				System.out.println(statusCode + " *** " + mPost.getResponseBodyAsString());
		} catch (FileNotFoundException e) {
			System.err.println("File not found for processing..");
		} catch (HttpException e) {
		} catch (IOException e) {
		} finally {
			if (mPost != null) {

Was this article helpful to you?