Browse our Products

Aspose.OCR for Java 26.7 - Release Notes

What was changed

KeySummaryCategory
OCRJAVA‑467Added document type detection for common OCR scenarios by using the rule-based and neural-model algorithms.New feature

Public API changes and backwards compatibility

This section lists all public API changes introduced in Aspose.OCR for Java 26.7 that may affect the code of existing applications.

Added public APIs:

The following public APIs have been introduced in this release:

com.aspose.ocr.AsposeOCR.DetectDocumentType - a new method

Analyzes input images and returns detected document types for common OCR scenarios.

New Methods

MethodDescription
ArrayList<DocTypeOutput> DetectDocumentType(OcrInput images)Detects document type for each input image or page.

com.aspose.ocr.DocTypeOutput - a new class

Represents the document type detection result for a single input item.

New Fields

FieldDescription
String sourceInput source identifier, such as a file path or URL when available.
int pageZero-based page index.
DocType docTypeDetected document category.
float confidenceConfidence score in the range from 0.0 to 1.0.

com.aspose.ocr.DocType - a new enum

Defines supported document categories: UNKNOWN, PICTURE, HANDWRITTEN, BOOK, FORMULA, TABLE, PRESENTATION, SCIENTIFIC, and INVOICE.

Updated public APIs:

No changes.

Removed public APIs:

No changes.

Examples

The code samples below illustrate the changes introduced in this release:

Detect document type for a single image

import com.aspose.ocr.AsposeOCR;
import com.aspose.ocr.DocTypeOutput;
import com.aspose.ocr.InputType;
import com.aspose.ocr.OcrInput;

import java.util.ArrayList;

public class DetectDocumentTypeExample {
    public static void main(String[] args) throws Exception {
        OcrInput input = new OcrInput(InputType.SingleImage);
        input.add("invoice.png");

        try (AsposeOCR api = new AsposeOCR()) {
            ArrayList<DocTypeOutput> results = api.DetectDocumentType(input);

            for (DocTypeOutput result : results) {
                System.out.println(result.source
                        + ", page " + result.page
                        + ": " + result.docType
                        + " (" + result.confidence + ")");
            }
        }
    }
}

Detect document types in a multi-page PDF

import com.aspose.ocr.AsposeOCR;
import com.aspose.ocr.DocTypeOutput;
import com.aspose.ocr.InputType;
import com.aspose.ocr.OcrInput;

import java.util.ArrayList;

public class DetectDocumentTypePdfExample {
    public static void main(String[] args) throws Exception {
        OcrInput input = new OcrInput(InputType.PDF);
        input.add("mixed-document.pdf", 0, 3);

        try (AsposeOCR api = new AsposeOCR()) {
            ArrayList<DocTypeOutput> results = api.DetectDocumentType(input);

            for (DocTypeOutput result : results) {
                System.out.println("Page " + result.page
                        + ": " + result.docType
                        + " (" + result.confidence + ")");
            }
        }
    }
}