Other PDF Issues

How to Extract PDF Text Coordinates Using MS Access VBA and Acrobat API

Khadija KhanKhadija Khan Nov 24, 2026 868 views

Question details

A developer needs a programmatic way to locate specific text in a PDF and retrieve its precise X and Y coordinates.

How to Extract PDF Text Coordinates Using MS Access VBA and Acrobat API
Product
Adobe Acrobat / MS Access VBA
Device & OS
not provided
Scenario
Developing a script in MS Access VBA using the Adobe Acrobat Type Library to process PDF documents and extract text positions.
Observed behavior
Needs the specific API objects and methods to return the bounding box coordinates of found strings.
Before you start

Ensure that you have Adobe Acrobat Professional or Standard installed, as the free Adobe Reader does not support the Interapplication Communication (IAC) API required for programmatic manipulation via VBA. You must also add the Adobe Acrobat Type Library reference in your MS Access VBA editor before executing the code.

Solution 1Recommended

Extract Coordinates Using Acrobat IAC API and JSObject

Use Acrobat's Interapplication Communication (IAC) to bridge VBA and Acrobat JavaScript, allowing the retrieval of coordinate objects via the getPageNthWordRects() method.

The Acrobat API exposes Acrobat JavaScript functionalities through the JSObject. By creating instances of AcroPDDoc and using JSObject, you can execute JavaScript functions directly from Access VBA to extract precise text bounding boxes.

1
Reference the Acrobat Type Library

Open your MS Access VBA Editor by pressing Alt + F11. Navigate to Tools > References, scroll down, and check the box for 'Adobe Acrobat x.x Type Library'.

2
Initialize Acrobat Objects

Declare and instantiate your AcroApp, AcroPDDoc, and AcroAVDoc objects in your VBA script to open the target PDF file in the background.

3
Create the JSObject Bridge

Retrieve the GetJSObject property from your active AcroPDDoc instance. This object acts as a bridge to execute Acrobat JavaScript methods natively from VBA.

4
Search and Retrieve Coordinates

Loop through the document pages and words. Use the JSObject's getPageNthWordRects() method on the matched text to get an array containing the bounding box coordinates (left, top, right, bottom).

Extract Coordinates Using Acrobat IAC API and JSObject
Coordinate System: The coordinates returned by getPageNthWordRects() are typically measured in points (1/72 of an inch) starting from the bottom-left corner of the PDF page.
Free Microsoft Office alternative

Looking for a Lightweight Office Suite with Built-in PDF Tools?

While advanced VBA scripting for PDF coordinates requires specific Adobe APIs, WPS Office provides a comprehensive, free alternative to Microsoft Office with a powerful built-in PDF editor. It seamlessly handles Word, Excel, PowerPoint, and PDF files in one lightweight application.

  1. 1. Download WPS Office: Visit the official WPS website and download the free installation package for your operating system.
  2. 2. Install the Software: Run the installer and follow the simple on-screen instructions to set up WPS Office on your device.
  3. 3. Open Your Documents: Launch WPS Office to seamlessly open, edit, and manage your Office and PDF files in one unified workspace.
Fully compatible with Microsoft Office formats (.docx, .xlsx, .pptx)Built-in PDF editor to view, edit, annotate, and convert PDF documents easilyLightweight installation with a familiar, user-friendly interfaceFree to download and use across Windows, Mac, Linux, and mobile devices
microsoft office alternative - wps office

Frequently Asked Questions

What unit of measurement does the Acrobat API use for PDF coordinates?

The Acrobat API typically uses points (1/72 of an inch) as the standard unit of measurement. The origin point (0,0) is usually located at the bottom-left corner of the PDF page.

Can I use Adobe Reader to extract PDF coordinates via VBA?

No, the free Adobe Reader does not support the Interapplication Communication (IAC) API required for this level of programmatic access. You must have Adobe Acrobat Standard or Professional installed.

Why does getPageNthWordRects return an array instead of a single coordinate?

A word in a PDF is represented by a bounding box rather than a single point. The method returns an array containing four values (left, top, right, bottom) that define the rectangular area the word occupies on the page.

Is it possible to find coordinates of scanned text using this VBA method?

No, the Acrobat API can only retrieve coordinates for actual text elements. If the PDF is a scanned image, you must first perform Optical Character Recognition (OCR) to convert the image into selectable text before running your VBA script.