Automating Document Processing
Business processes often stall at the point where someone has to manually read a PDF invoice, a scanned receipt, or a paper form and enter the data into the system. OCI Document Understanding uses AI to automatically extract text, tables, key-value pairs, and classification from documents, turning unstructured files into structured data your APEX application can process.
Key Capabilities
OCR (Text Detection): Extracts all text from scanned documents and images with high accuracy across multiple languages. Table Extraction: Identifies tables within documents and returns them as structured rows and columns. Key-Value Extraction: Recognizes common document fields like invoice number, date, total, vendor name, and line items without custom training. Document Classification: Categorizes documents by type (invoice, receipt, contract, purchase order) to route them to the appropriate processing workflow.
Calling Document Understanding From PL/SQL
DECLARE
l_response CLOB;
l_doc_base64 CLOB;
BEGIN
-- Convert uploaded BLOB to base64
l_doc_base64 := APEX_WEB_SERVICE.BLOB2CLOBBASE64(l_pdf_blob);
-- Call OCI Document Understanding
l_response := APEX_WEB_SERVICE.MAKE_REST_REQUEST(
p_url => 'https://document.aiservice.us-ashburn-1.oci.oraclecloud.com'
|| '/20221109/actions/analyzeDocument',
p_http_method => 'POST',
p_body => '{"features":[{"featureType":"KEY_VALUE_EXTRACTION"},
{"featureType":"TABLE_EXTRACTION"}],
"document":{"source":"INLINE",
"data":"' || l_doc_base64 || '"}}',
p_credential_static_id => 'OCI_AI_CRED'
);
-- Parse extracted fields
APEX_JSON.PARSE(l_response);
:P10_INVOICE_NUMBER := APEX_JSON.GET_VARCHAR2(
p_path => 'pages[1].documentFields[?(@.fieldLabel.name=="InvoiceNumber")].fieldValue.value');
:P10_TOTAL := APEX_JSON.GET_NUMBER(
p_path => 'pages[1].documentFields[?(@.fieldLabel.name=="Total")].fieldValue.value');
END;
APEX Integration Pattern
Build an APEX page with a file upload region. When the user uploads a PDF or image, a page process sends it to Document Understanding. Display the extracted fields in a form that the user can verify and correct. Save the verified data to your application tables. This “upload, extract, verify, save” pattern dramatically reduces manual data entry while keeping humans in the loop for quality assurance.
Custom Models
For documents specific to your business (custom forms, proprietary invoices), train a custom key-value extraction model in OCI Document Understanding. Upload sample documents, label the fields you want to extract, and OCI trains a model specific to your document layout. Custom models significantly improve extraction accuracy for non-standard document formats.