This Web Service API is used to create HOCR XML forsingle page/multipage tiff/tif or zip containg tiff or pdf passed as input for a particular batch class. This Web Service API requires two Inputs i.e. Input xml and image file to create HOCR_xml.

On the basis of Batch Class Identifier provided as an input, this API will Extract plugin configuration settings of RECOSTAR_HOCR/TESSERACT_HOCR/NUANCE_HOCR plugin in Page Process module, if property named “Recostar Switch” value is turned ON then process of OCRing will be done for Recostar and its corresponding plugin configurations will be used else Tesseract will be used to perform OCRingin case of windows.Similarly OCRing can be performed on Linux using either Tesseract or Nunace.

Request Method POST

Input parameters required for the batch class creation are as follows:

Input Parameter Value Description
batchClassIdentifier It should contain a valid value of an existing batch Class Identifier. The Batch Class name whose configurations are to be utilised to generate HOCR.xml.
imageName Optional parameter This parameter value contain name tif/tiff or ZIP file for which HOCR XML need to be created with extension specified.


Web Service URL: [http://{serverName}:{port}/dcma/rest/batchClass/createHOCRforBatchClass]

Check list:

  1. Batch Class Identifier should be valid and existing.
  2. Only single page tif/tiff should be passed as an input or a zip file (which may contain single/multipage tiff or pdf).

Sample Input XML:














Sample client code using apache commons http client:-

private static void createHOCRXML() {
		HttpClient client = new HttpClient();
		String url = "http://localhost:8080/dcma/rest/batchClass/createHOCRforBatchClass";
		PostMethod mPost = new PostMethod(url);
		// Adding Input XML file for processing
		File file = new File("C:\\sample\\createHOCR.xml");
		File imageFile = new File("C:\\sample\\US-Invoice.tif");
		Part[] parts = new Part[2];
		try {
			parts[0] = new FilePart(file.getName(), file);
			parts[1] = new FilePart(imageFile.getName(), imageFile);
			MultipartRequestEntity entity = new MultipartRequestEntity(parts, mPost.getParams());
			int statusCode = client.executeMethod(mPost);
			if (statusCode == 200) {
				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) {
				System.out.println("Web service executed successfully.");
			} 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?


Comments are closed.