Skip to main content
Back to Articles

Converting Supplier Invoices (PDFs) to Structured JSON

By Wilson TechnologyPublished
AIAutomationIntegrationAccountingERP

For mid-market and enterprise businesses managing complex supply chains, manual invoice processing is a costly operational bottleneck. Accounts payable teams waste valuable payroll keying data from unpredictable vendor PDFs into legacy accounting software, leading to frequent errors and stunted cash flow visibility. The fundamental issue is that supplier invoices, like the product specs buried in vendor PDFs, arrive in chaotic, unstructured formats, yet enterprise systems require clean, structured data. While legacy OCR templates and manual data entry were historical workarounds, modern operations demand a smarter approach.

Today, businesses are driving true invoice automation by leveraging multimodal AI to seamlessly convert PDF to JSON. These advanced models read documents spatially and semantically, replacing brittle OCR templates. In this article, we explore the architectural patterns for using multimodal AI to ingest unstructured vendor documents and map them directly into an ERP. This robust ERP integration eliminates manual entry, accelerating financial cycles and streamlining back-office operations.

The Wilson Tech Approach

When tackling the unstructured data problem of vendor invoices, the classic tech fix is often to buy a standalone, tier-based SaaS OCR tool. This approach typically involves signing a costly contract for a point solution that claims it will magically handle all your PDFs, only for you to discover it struggles with varied vendor templates or requires constant manual template retraining. It becomes yet another brittle band-aid that your IT team has to maintain alongside your primary ERP integration layer.

This is The Wilson Tech Approach: solving the business problem first, building the tech around it, avoiding band-aid technical solutions for technical symptoms, and taking a holistic approach analyzing the entire operational lifecycle to reduce costs and improve performance with minimal investment. The business problem isn't "we need better OCR software." The business problem is that accounts payable is a bottleneck causing financial blind spots and vendor friction. Instead of adding a disconnected SaaS product to your tech stack, we design custom, serverless pipelines. We capture the email attachment at the source, utilize standard API calls to multimodal LLMs (Large Language Models) to extract the data into standard JSON, and orchestrate that data directly into your ERP—like Oracle NetSuite, SAP S/4HANA, or Microsoft Dynamics—using a unified custom API gateway. This eliminates per-page SaaS licensing fees, consolidates your architecture, and provides a scalable foundation for true invoice automation that grows with your transaction volume rather than penalizing you for it.

The Evolution: From Template OCR to Multimodal AI

To understand why this architectural shift is so powerful, we must look at why traditional OCR fails in the real world of B2B commerce. Legacy OCR relies almost entirely on spatial templates. If Vendor A sends an invoice, you map out where the "Invoice Number" and "Total Amount" are located on the page. But if Vendor A updates their billing software and the logo moves down an inch, the template breaks, and the data fails to ingest. You are left managing hundreds of fragile templates.

Multimodal AI models—like OpenAI's GPT-4o, Anthropic's Claude 3.5, or Azure Document Intelligence—change this paradigm entirely. They do not rely on strict X/Y coordinates. They understand the document spatially and semantically, much like a human clerk. They recognize that a string of text next to "Inv#" is the invoice number, regardless of where it appears on the page. This capability drastically reduces the maintenance overhead of invoice automation.

However, extracting the text is only the first half of the battle. The crucial second step is structuring that unstructured text into a format that a machine can digest. By explicitly prompting a multimodal LLM to output its findings as a strict JSON schema, you bridge the gap between unstructured human-readable PDFs and the rigid requirements of enterprise REST APIs.

Designing the Invoice Automation Architecture

Creating a reliable pipeline for converting supplier invoices (PDFs) to structured JSON requires a decoupled, serverless architecture. We strongly advise against monolithic approaches or relying on basic automation scripts and lightweight tools like Zapier, which are unsuitable for enterprise operations due to brittle workflows, compliance risks, high costs at scale, and dropped orders.

A resilient ingestion architecture typically follows these stages:

1. The Ingestion Trigger

Instead of human clerks downloading PDFs from an inbox, set up an automated ingestion point. You can configure an email service (such as AWS SES or SendGrid) to route incoming billing emails to an object storage bucket (like AWS S3). When a new PDF lands in the bucket, an event triggers a message queue (e.g., AWS SQS), which is then consumed by a serverless function (e.g., AWS Lambda). While serverless functions can scale infinitely, we must first consider the business impact: a sudden spike in billing emails could overwhelm downstream ERPs, causing system crashes, operational downtime, and financial liability from dropped orders. To prevent this, architectural designs must configure strict Event Source Mapping limits and Reserved Concurrency on queue consumers. This intentionally throttles throughput to protect downstream systems from simultaneous concurrent executions during traffic spikes.

2. Multimodal AI Extraction

The serverless function retrieves the PDF document. For models that require images, the PDF may be converted to high-resolution images first. The document is then passed to the multimodal AI API along with a strict system prompt. The prompt must explicitly define the expected JSON schema. For example, it should enforce keys for invoice_number, invoice_date, vendor_name, line_items (an array of objects containing sku, quantity, unit_price), and total_amount.

3. Probabilistic vs. Deterministic Processing

This is the most critical architectural boundary in the entire process. Large Language Models (LLMs) are probabilistic and belong in unstructured data processing. Standard deterministic logic remains mandatory for structured APIs and core operations (e.g., financial transactions, inventory levels, order routing), where AI hallucinations or probabilistic parsing would introduce severe business risks — the same failure mode behind why Tray.io's AI assistant produces invalid JSON paths when it is trusted with structured output unsupervised.

Therefore, the AI is solely responsible for extracting the data from the PDF into JSON. Once the JSON is generated, the AI's job is done. You must never allow an LLM to directly issue an API call to your ERP.

Instead, the generated JSON is passed back to your custom backend service or custom API gateway. Here, standard code takes over to validate the data. Does the sum of the line items equal the extracted total amount? Is the invoice date in a valid format? If any validation fails, the invoice is flagged for human review. It is critical to remember that custom dashboards are strictly presentation layers. They cannot orchestrate intelligent retry logic, queue orders, or natively throttle APIs. Always architect solutions where a separate custom backend service or API gateway handles the asynchronous queuing and API throttling, which the dashboard then monitors, completely shielding the ERP from corrupted data.

ERP Integration: Mapping JSON Directly into the ERP

Once the JSON is validated, it must be mapped and pushed into your ERP. This integration layer must handle the complexities of your specific business rules.

For example, when integrating with ERP systems like NetSuite or Microsoft Dynamics 365, the custom API gateway will take the structured JSON and begin cross-referencing records. It will search the ERP for the vendor record to obtain the internal Vendor ID. It will look up the provided PO number to ensure the billed quantities match the original purchase order (a three-way match process). If the quantities match, the integration uses the ERP's REST API or SOAP web services to programmatically generate a Vendor Bill record.

By utilizing a custom API gateway or a robust enterprise iPaaS like Celigo to orchestrate these connections, you maintain total control over the retry logic, API throttling, and error handling. While powerful, platforms like Celigo can introduce expensive downtime or licensing-tier limitations if not carefully managed. By architecting this layer correctly, you ensure that even during high-volume periods, your ERP is protected from API rate limit exhaustion.

Handling Complex Edge Cases

Real-world invoice automation is rarely straightforward. Vendor invoices often contain edge cases that disrupt simple automated flows. A well-designed architecture must account for:

  • Handwritten Notes: It is common for vendors to scribble corrections or adjustments on a printed invoice before scanning and emailing it. Modern multimodal AI is highly adept at reading handwriting alongside printed text, ensuring those critical notes are not lost in the extraction phase.
  • Multiple Pages and Continued Tables: Line items spanning multiple pages can confuse basic OCR. By passing all pages to the multimodal model and instructing it to compile a single unified array of line items in the JSON, the architecture handles multi-page tables seamlessly.
  • Currency and Tax Variations: Global supply chains mean dealing with multiple currencies and complex tax lines (VAT, GST). The JSON schema must be designed to extract the currency symbol and explicitly map tax amounts as separate line items or specific fields, allowing the ERP's deterministic logic to handle the final tax calculations correctly.
  • Historical Pricing Context: Once invoices are structured, the same JSON pipeline can feed structuring internal pricing history for vendor negotiation prep, giving procurement teams a clean record to negotiate from at renewal time.

Turning Unstructured Invoices into a Reliable Data Pipeline

Relying on manual data entry for accounts payable is a slow, error-prone process that scales poorly. By leveraging modern multimodal AI to translate unstructured PDFs into clean, structured JSON, businesses can build resilient, automated data pipelines that feed directly into their ERP. This approach eliminates the need for brittle OCR templates and costly SaaS workarounds, returning control to your core systems and freeing your team to focus on strategic financial analysis.

Ready to automate your accounts payable invoice pipeline?

If your accounts payable process is slowing down your operational growth, or you're tired of paying exorbitant licensing fees for legacy OCR tools that barely work, a custom multimodal AI pipeline can replace both.

Ready to convert supplier PDFs into clean, ERP-ready JSON automatically? Contact WTECH to schedule a technical discovery session.

Frequently Asked Questions

Can multimodal AI handle handwritten notes on supplier invoices?

Yes, modern multimodal AI models can accurately read and extract handwritten text alongside printed text on invoices, converting both into structured JSON data.

How do we handle AI hallucinations when extracting financial data?

AI is used strictly for extraction. The resulting JSON must pass through deterministic business logic to cross-reference PO numbers and math totals before ERP ingestion.

Does this replace our existing EDI connections?

No. EDI is a structured protocol for high-volume vendors. Multimodal AI ingestion handles the long tail of vendors who only send unstructured PDFs via email.

How exactly do you convert the PDF to JSON?

Converting PDFs to structured JSON is achieved by sending the document image to a multimodal API (like GPT-4V) with a strict prompt defining the exact JSON schema required.