This API will generate the OCR result for the specified sample image file.  This API works for single page tif and png file. While processing the color image we accept the png/tif file as input and for black and white image we accept tif file as input.

Request Method POST

Input Parameters:

Input Parameter Values Descriptions
ocrEngine Either “recostar”/”tesseract”/”nuance” This parameter is used for configuring the ocrEngine  to be used
colorSwitch Either “ON”/”OFF” This parameter is used to define the input file is coloured or not
tesseractVersion Currently we are supporting “tesseract_version_3” This parameter is used for tesseract version to be used.
cmdLanguage Either “tha”/”eng” This parameter is used for configure the language that has been learnt by tessearact.
projectFile This will be empty in case of tesseract and nuance ocrEngine but mandatory for recostar This parameter is validating the RSP used for OCRing in case of recostar. For tesseract and nuance this wil remain empty


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


  1. In case ocrEngine is recostar, than colorSwitch and projectFile is mandatory parameters.
  2. In case ocrEngine is tesseract than colorSwitch, tesseractVersion and cmdLanguage is mandatory parameters.Files required as input will be image file and xml file.
  • In case ocrEngine is nuance, mandatory files to the web service would be image file and an xml file. No project processing file is required while ocring
  1. If colorSwitch is ON, input image can be tif/png.
  2. If colorSwitch is OFF than input image should be TIFF.

File format for XML file:


























Sample client code using apache commons http client:-

private static void createOCR() {
		HttpClient client = new HttpClient();
		String url = "http://localhost:8080/dcma/rest/createOCR";
		PostMethod mPost = new PostMethod(url);
		// adding image file for processing
		File file1 = new File("C:\\sample\\sample.xml");
		// adding xml file for taking input
		File file2 = new File("C:\\sample\\US-Invoice.tif");
		// adding rsp file used for creating OCR in case of recostar
		File file3 = new File("C:\\sample\\FPR.rsp");
		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) {
				System.out.println("Web service executed successfully.");
				InputStream in = mPost.getResponseBodyAsStream();
				// saving result generated.
				File outputFile = new File("F:\\sample\\");
				FileOutputStream fos = new FileOutputStream(outputFile);
				try {
					byte[] buf = new byte[1024];
					int len =;
					while (len > 0) {
						fos.write(buf, 0, len);
						len =;
				} finally {
					if (fos != null) {
			} else if (statusCode == 403) {
				System.out.println("Invalid username/password.");
			} else {
		} 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?