3.32.  Text - in Page Regions


You might find that a certain text exists more than once on a page, but only one of the occurrences has to be tested. This requires you to narrow the search to a section of a page. The syntax is simple:

// Reducing the validation to a page region:
// The following validations are limited to the regions.


The following example shows the definition and the usage of a page region:

public void hasTextOnFirstPageInPageRegion() throws Exception {
  String filename = "documentUnderTest.pdf";
  int leftX  =  17;  // in millimeter
  int upperY =  45;
  int width  =  60;
  int height =   9; 
  PageRegion pageRegion = new PageRegion(leftX, upperY, width, height);
            .containing("on first") 

When comparing text in page areas, all the test methods are available which are available when comparing text on entire pages. These methods are described in section 13.4: “Comparing Text”.

A page region can also be used when testing images.