Showing results for 
Search instead for 
Did you mean: 

Text Location verification in PDF documents


Text Location verification in PDF documents

Hi There,


My AUT is a desktop based that generates a PDF report that I need to test. Apparently the report is a template in a tabular form. My goal is to verify that the text that I enter in the forms are populated in the report under different tables, based on the business logic. I need to verify that the text that I am searching for is printed in the correct tables in the PDF document, 

Although I can get the text that I am looking for, from the pdf, how do I ensure that the text is being printed under the correct tables? Could I get some help from the community regarding locating the exact location of the text from the  PDF? 


For eg:

In the attached screen print, how do I ensure the test "Heparin" is under Once only table and "Panadine" is under the Medication table? 



Community Hero

Re: Text Location verification in PDF documents

We have a simlar problem, only in our case, because of how the PDF is generated, we can't even check for the text.  

So... I've adapted the PDFBox code ( to do the following


1) Generate the PDF

2) Generate a BMP for the page I want to test

3) Use Regions.Compare logic, using a mask, to make sure that a baseline BMP file of the page and the test version match.



Robert Martin
[Hall of Fame]
Please consider giving a Kudo if I write good stuff

Why automate?  I do automated testing because there's only so much a human being can do and remain healthy.  Sleep is a requirement.  So, while people sleep, automation that I create does what I've described above in order to make sure that nothing gets past the final defense of the testing group.
I love good food, good books, good friends, and good fun.

Mysterious Gremlin Master
Vegas Thrill Rider
Extensions available
Community Manager

Re: Text Location verification in PDF documents

Hi @Joso,


It looks like using the image comparison suggested by @tristaanogre is one it the best options.

Also, you can play with the Intelligent Quality Add-On. This is one of the newest TestComplete features that provides Visual Recognition сapabilities with AI. You can create a script to check if a column contains the needed text. Please watch this video for more info:

Tanya Gorbunova
SmartBear Community Manager

Learn SmartBear products in a fun and easy way and prove your knowledge!
>>Participate in the TechCorner Challenge today
This is AWESOME and it works great for our upcoming project. However, it's going to be a challenge for existing project as we do use existing OCR feature today to scrape for a generated value at a specific location within the window that TestComplete can recognize. Is there a way we can pass in ...
New Here?
Join us and watch the welcome video:
Join TechCorner Challenge!
Want a fun and easy way to learn TestComplete? Try solving weekly TechCorner challenges and get into the Leaderboard!

Challenge Status

How to execute remote test and obtain results via Test Runner REST API


Comparing content of HTML table with Excel file data


Compare HTML table with Excel file and correct data in the file


Retrieve Data from a Web Page