Loading...
New Winner – Cross-Border Excellence | Payoneer India 2026 Check out
Featured Recognized by Salesforce; Proven by impact! Check out

Salesforce OCR utilizes Optical Character Recognition to convert text from images and scanned documents into machine-readable text, enabling businesses to efficiently update Salesforce records. This guide explains how to integrate OCR.space with Salesforce, detailing the process of sending PDFs to the OCR API, extracting information, and updating fields using Apex. It includes a scenario for extracting a credit score from a PDF and emphasizes the importance of security and data handling when integrating external services. By implementing this process, organizations can streamline their document processing workflows.

Many times it’s crucial to extract information from documents such as loan statements, invoices, applications, identity documents, and scanned forms. When the information is stored as an image or scanned PDF, it cannot be directly read and used as regular text.

This is where Salesforce OCR becomes useful. Optical Character Recognition can convert text from images and scanned documents into machine-readable text, allowing businesses to process the information and use it to update Salesforce records.

For example, a lender may receive a credit report as a Salesforce PDF document. Instead of opening the file and manually searching for information, OCR can extract the required text and help move that information into the appropriate Salesforce field.

In this guide, we will explain what OCR is, how OCR.space works, how to send a PDF to its API, process the response, and use Apex to extract specific information and update Salesforce records.

What Is OCR?

OCR stands for Optical Character Recognition. It is a technology that reads text from images or scanned documents and converts it into machine-readable text. This makes the extracted information easier to search, process, and use in applications.

For example:

PDF/Image β†’ OCR β†’ Extracted Text β†’ Salesforce Field Update

What Is OCR.space?

OCR.space is an OCR service that provides an API for processing images and PDF documents. It processes the submitted document and returns the OCR results in JSON format.

OCR.space supports different ways of submitting documents, including file uploads, URLs, and Base64-encoded data. The API can also be connected with Salesforce through an Apex HTTP callout.

How Salesforce Sends Documents to OCR.space

A typical Salesforce integration with OCR.space follows this flow:

  1. PDF Document
  2. Salesforce
  3. Apex HTTP Callout
  4. OCR.space API
  5. OCR Processing
  6. JSON Response
  7. Extracted Text
  8. Parse Required Information
  9. Update Salesforce Fields

Common API parameters may include:

  • apikey β€” API authentication key.
  • file β€” File submitted for OCR processing.
  • base64Image β€” Base64-encoded image or document data.
  • url β€” URL of the document.
  • language β€” Language of the document.
  • filetype β€” File type such as PDF.
  • OCREngine β€” OCR engine to use.
  • isCreateSearchablePdf β€” Option related to searchable PDF output.


Scenario: Extracting a Credit Score from a PDF

To understand the process, consider a lender that uploads a credit report PDF to an Account. The document contains a line such as β€œSCORE: 658,” and the goal is to automatically save that number in a custom Account field.

The same process can also capture the complete text returned by OCR.space through the ParsedText value when the entire document needs to be stored.

The flow works like this:

  • A PDF is attached to an Account. This inserts a ContentDocumentLink record, which is what kicks off the automation β€” a trigger on ContentDocumentLink hands off to an Apex class.
  • The Apex class checks for PDF attachments that are linked to an Account. It then sends the work to an @future(callout=true) method because a trigger cannot make an HTTP callout directly. This allows the process to run asynchronously.
  • The future method gets the actual PDF file from the ContentVersion record, converts the PDF into Base64 format, and sends it to the OCR.space API.
  • The OCR.space API returns a JSON response containing the extracted text. A regular expression is then used to find the credit score from that text.
  • The Account record is then found and updated with the extracted credit score.

s1

How to Integrate OCR.space with Salesforce

Now that the OCR.space process is clear, the next step is connecting it with Salesforce using Apex. The implementation below follows the credit-score scenario and covers the API credentials and the complete Apex implementation.

Step 1 β€” Store the API Credentials

Before making the callout, the OCR.space endpoint and API key need to be stored outside Apex rather than hardcoded.

  • Create a Custom Metadata Type named IntegrationMetadata__mdt.
  • Create a record with the Developer Name OCRSpaceAPI.
  • Store the API endpoint in the End_point__c field.
  • Store the API key in the API_Key__c field.
  • Apex queries this metadata at runtime when making the API call.

ss1

Step 2 β€” The Complete Implementation

This is the complete implementation for the scenario. It includes a trigger that runs when a file is linked to a record and a controller class that handles the callout, parsing, and field update.

Trigger:

Controller:

Security and Data Considerations

When integrating an external OCR service with Salesforce, document security and data handling should be considered carefully.

  • When integrating an external OCR service with Salesforce, document security and data handling should be considered carefully.
  • Review the OCR provider’s privacy policy and data-processing terms.
  • Understand how submitted documents are handled and retained.
  • Avoid sending sensitive documents unless the organization’s requirements allow the external processing.
  • Store API credentials securely and do not hardcode API keys in Apex β€” Custom Metadata Types and Named Credentials are both valid approaches; Named Credentials keeps the key out of Apex entirely, while Custom Metadata is simpler to set up and still keeps it out of source code.
  • Validate OCR output before updating important Salesforce fields.


Conclusion

With the right Apex setup, Salesforce OCR can become part of a practical document-processing workflow. The approach shown here helps turn information inside uploaded files into usable Salesforce data without requiring users to manually read and enter every value.

The OCR.space API provides a straightforward way to process documents and return extracted text that Apex can work with. A Salesforce PDF can therefore become a usable source for specific values that need to be identified, processed, and saved.

This Salesforce API integration can be extended around the same approach for different document-based requirements. By combining the callout, text parsing, and record update steps, teams can build workflows that handle extracted information more efficiently.

Watch Demo Video

Frequently Asked Questions
Can Salesforce extract text from a PDF?

Yes. Salesforce can extract text from a Salesforce PDF through an OCR API integration, allowing scanned content to be processed and stored as usable Salesforce data.

How does OCR improve Salesforce PDF processing?

OCR converts text from scanned PDFs and images into machine-readable content, helping Salesforce workflows identify values and reduce manual data entry from Salesforce PDF documents.

How does Salesforce API integration connect with OCR.space?

A Salesforce API integration can use Apex HTTP callouts to send PDF data to OCR.space, receive the OCR response, extract required values, and update Salesforce records.

How should API credentials be secured in Salesforce OCR integrations?

API credentials should not be hardcoded in Apex. Salesforce Custom Metadata Types or Named Credentials can keep integration credentials outside the application code.

Related Articles
Passwordless Login with Passkeys in Salesforce: A Practical Setup Guide

Passwordless login with passkeys gives Salesforce users another way to authenticate without entering a traditional password every time. Instead, users can verify their identity through a device, browser, or supported passkey manager. For Salesforce admins and consultants, setting up passkeys requires a little planning. Each user needs access to their own registered passkey, and backup […]

Read More
How to Configure Salesforce for Google Chat Integration

Google Chat integration with Salesforce connects team communication with Salesforce data, helping teams receive important updates without constantly switching between platforms. It makes collaboration simpler and keeps sales teams informed. The integration works across three key components: Salesforce: Acts as the source system for business information, record updates, and automation. Google Cloud Console: Provides the […]

Read More
How to Integrate Tasks Between NikoHealth and Salesforce

How to Integrate Tasks Between NikoHealth and Salesforce Tasks play an important role in healthcare workflows and can be associated with Patients, Orders, Invoices, Documents, and Assigned Staff Members. With MultiSync Made Easy, organizations can synchronize Task records while maintaining these important relationships. This Niko Health image-based workflow also makes it easier to understand how […]

Read More
How to Build an AI-Powered Salesforce Record Assistant Using LWC and Models API

Sales representatives often work with Salesforce records that contain a lot of information, including emails, tasks, events, and Chatter activity. Going through all this information manually can make it easy to miss important details. With Salesforce LWC and Models API, you can build an AI-powered record assistant that brings this information together, summarizes important details, […]

Read More
How to Build an AI Email Generator for Salesforce Cases Using Salesforce Models API

Support agents spend a lot of time writing the same kind of customer emails, whether it is a case update, resolution message, or simple follow-up after an issue. An email generator for Salesforce can help reduce this repetitive work by creating a first draft directly from the Case record, using the information already available in […]

Read More
How to Integrate Purchase Orders Between NikoHealth and Salesforce

Purchase Orders are used to manage inventory procurement, vendor orders, product replenishment, and supply chain operations. Using MultiSync Made Easy, organizations can synchronize Purchase Orders between NikoHealth and Salesforce while maintaining relationships with: Vendors Products Purchase Order Items Locations In this guide, we will configure: NikoHealth β†’ Salesforce Purchase Order Synchronization Salesforce β†’ NikoHealth Purchase […]

Read More
Our Location worldwide
Indian Flag India
3rd Floor, A-10, Pegasus Tower, Sector 68, Noida, Uttar Pradesh 201301 +91-1203669505
United States of America Flag USA
333 West Brown Deer Road Unit G – 366 Milwaukee WI, USA 53217 +1(262) 310-7818
United Kingdom Flag UK
7 Bell Yard, London, WC2A 2JR +44 20 3239 9428
CA Flag Canada
HIC Global Solutions INC
6D - 7398 Yonge St #1124 Thornhill, ON L4J 8J2 Canada +1(262) 310-7818