This API generates the pdf for the input tiff files. If 5 input tiff files are provided then 5 pdf files will be returned by this API. The API has following parameters for configuration as depicted below.

Request Method POST

Input Parameters

Input Parameter Values Descriptions
inputParams This value can be empty.  Reference for image magick parameter. http://www.imagemagick.org/script/command-line-options.php

 

This are the image magick input parameters used for processing the input and output file.
outputParams This value can be empty.  Reference for image magick parameter. http://www.imagemagick.org/script/command-line-options.php

 

This are the image magick output parameters used for optimizing the output file.

 

 

 

pdfGeneratorEngine Either “IMAGE_MAGICK”/”ITEXT” This will used for pdf generator engine.

 

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

 

Checklist:

  1. Input only tiff/tif files for generating pdf.
  2. If pdfGeneratorEngine is “IMAGE_MAGICK”, than only input params and output params works.
  • If Input tiff is multipage then single multipage pdf is generated as output.

 

Sample client code using apache commons http client:-

private static void convertTiffToPdf() {
		HttpClient client = new HttpClient();
		String url = "http://localhost:8080/dcma/rest/convertTiffToPdf";
		PostMethod mPost = new PostMethod(url);
		File file1 = new File("C:\\sample\\US-Invoice.tif");
		Part[] parts = new Part[4];
		try {
			parts[0] = new FilePart(file1.getName(), file1);
			parts[1] = new StringPart("inputParams", "");
			parts[2] = new StringPart("outputParams", "");
			parts[3] = new StringPart("pdfGeneratorEngine", "IMAGE_MAGICK");
			MultipartRequestEntity entity = new MultipartRequestEntity(parts, mPost.getParams());
			mPost.setRequestEntity(entity);
			int statusCode = client.executeMethod(mPost);
			if (statusCode == 200) {
				System.out.println("Web service executed successfully..");
				InputStream in = mPost.getResponseBodyAsStream();
				String outputFilePath = "C:\\sample\\serverOutput.zip";
				File f = new File(outputFilePath);
				FileOutputStream fos = new FileOutputStream(f);
				try {
					byte[] buf = new byte[1024];
					int len = in.read(buf);
					while (len > 0) {
						fos.write(buf, 0, len);
						len = in.read(buf);
					}
				} finally {
					if (fos != null) {
						fos.close();
					}
				}
			} else if (statusCode == 403) {
				System.out.println("Invalid username/password..");
			} else {
				System.out.println(mPost.getResponseBodyAsString());
			}
		} catch (FileNotFoundException e) {
			System.err.println("File not found for processing.");
		} catch (HttpException e) {
			e.printStackTrace();
		} catch (IOException e) {
			e.printStackTrace();
		} finally {
			if (mPost != null) {
				mPost.releaseConnection();
			}
		}
	}

Was this article helpful to you?

Engineering

Comments are closed.