Available Now: Explore our latest release with enhanced accessibility and powerful IDP features

Unleashing The Power of OCR with JavaScript

By Garry Klooesterman | 2025 Jan 22

Sanity Image
Read time

4 min

Summary: This blog provides a guide for developers on how to extract text from images in PDFs or image-based PDFs using OCR in JavaScript. Apryse OCR SDK empowers developers to adjust their OCR solutions to address the unique challenges and requirements of the business needs.

Introduction

Copied to clipboard

If you’ve developed apps for the Web, chances are you already have a good grasp of JavaScript. As a beginner-friendly, versatile, full-featured scripting language, along with many other advantages, it’s easy to understand why JavaScript is currently one of the most popular programming languages.

In this blog, we’ll explore using JavaScript to implement a solution for a common challenge businesses face in today’s world; unlocking the information trapped in documents. Slow, inefficient, and error prone manual entry comes with higher costs and can easily drown a business. This is where Optical Character Recognition (OCR) technology saves the day.

Whether you’re transcribing patient records, verifying document authenticity, or automating data entry for supply chain management, the versatility of OCR technology and ability to streamline processes, improve efficiency, and unlock valuable insights makes it a critical tool across various industries.

Apryse OCR SDK: Your powerful JavaScript solution

Copied to clipboard

Apryse OCR SDK provides a comprehensive solution offering seamless integration, scalability, robust security, and exceptional accuracy.

Key Features

  • Handles various document types, including tables, multiple languages, and different text orientations.
  • Automatically enhances image quality, leading to more accurate image recognition.
  • Efficiently handles high-volume workflows.
  • A server-based solution, keeping your sensitive material protected.
  • Easily integrated into existing systems and server environments.
  • Can be fine-tuned for optimal performance by adjusting processing parameters.

Apryse OCR SDK empowers developers to adjust their OCR solutions to address the unique challenges and requirements of the business needs.

By leveraging the power of Apryse OCR SDK, your business can realize such benefits as reduced cost, increased efficiency, improved accessibility, customized data output, and more.

OCR Engines

Copied to clipboard

Apryse offers three OCR engines to add advanced text extraction capabilities to your applications.

LEADTOOLS OCR Engine: Powered by LEADTOOLS technology, this is the default OCR engine in the Apryse OCR SDK. Added in our v11 release, this OCR engine delivers improved accuracy and speed over previous versions.

Tesseract OCR Module: The Apryse Tesseract OCR Module is built on Tesseract 4.0 with added features such as improved word and character recognition, multiple language support and JSON output.

Note: When using the Apryse OCR SDK, the module automatically selects the best engine for the task based on what it is processing at the time. The default OCR module is available on Windows, Linux, macOS.

IRIS OCR Module: The IRIS OCR Module, based on the IRIS iDRS engine, may provide better results in certain situations, such as processing items with multiple disconnected text snippets on a page, for example, magazine covers or CAD documents. The IRIS module is licensed separately from the standard Apryse OCR module and is currently available on Windows and Linux.

For this blog, we’ll focus on setting up the default OCR module to process an image or image-based PDF.

Getting started with Apryse OCR SDK

Copied to clipboard

The Apryse OCR module adds OCR functionality into the Apryse SDK to gain the ability to process an image or image-based PDF and create a PDF that is searchable with selectable text. The module can be used with a number of programming languages, such as C#, C++, Java, Python, and more. For this example, we’ll use JavaScript.

Implementing the OCR module using JavaScript is incredibly easy and requires minimal code.

Step 2: Now let’s use OCR to make a searchable PDF by adding invisible text to an image or an image-based PDF using the following code:

For an image:

async function main() { 
const doc = await PDFNet.PDFDoc.create(); 
// Run OCR on the image without options 
await PDFNet.OCRModule.imageToPDF(doc, image_path); 
} 
PDFNet.runWithCleanup(main); 

For an image-based PDF:

async function main() {
const doc = await PDFNet.PDFDoc.createFromFilePath(filename);
// Set English as the language of choice
const opts = new PDFNet.OCRModule.OCROptions();
opts.addLang("eng");
// Run OCR on the PDF with options
await PDFNet.OCRModule.processPDF(doc, opts);
}
PDFNet.runWithCleanup(main);

See the full code sample with examples for various scenarios.

Input Resolution

Adjusting the input image resolution can sometimes provide better results. Use the following code to manually set the DPI:

// Manually override DPI
opts.addDPI(300);

Language Options

The Apryse OCR module has various language options, including specifying a target language, adding new languages through trained language files, and using multiple languages when processing a document.

Other Options

In addition to processing an image or PDF as we did earlier, you can apply raw OCR output (text and metadata in JSON or XML format) to the input document. See the documentation for more details and options.

Conclusion

Copied to clipboard

The Apryse OCR SDK brings a powerful OCR to your JavaScript projects with seamless integration to effortlessly extract text, even for documents with multiple languages or complex layout. With the power of Apryse OCR SDK in your JavaScript projects, you can decipher text from various languages, unlock insights from images or image-based PDFs, and access a universe of information locked in documents. With Apryse OCR, process anything from historical archives to your latest research papers, boosting productivity, and optimizing your business potential.

Want to see Apryse OCR SDK in action? Check out a demo now or contact our sales team.

Need help? Join our Discord community for support and discussions.

Sanity Image

Garry Klooesterman

Senior Technical Content Creator

Share this post

email
linkedIn
twitter