Create controls for PDF files

With the PDF Engine 3.0, you can test whether the content of a PDF file is what you expect it to be.

This chapter explains how to create controls for your PDF file. You can then edit the PDF controls, save them as a Module and create tests based on the PDF Module.

Types of controls

You can create the following types of controls:

  • text areas

  • image areas

  • table areas

Ways to create controls

You can create a control in one of the following ways:

  • Specify an area using its absolute position, that is, its location in your PDF file.

  • Specify an area using its relative position, that is, its location in relation to an anchor element in your PDF file.

    This is useful if PDF elements always appear in the same position relative to each other, but you can't safely predict their location on the page. For instance, if you want to test multiple invoices. The invoices follow the same basic format, but the actual location of some fields, such as "Net price" and "Gross price", differ in each file.

Specify an area using its absolute position

To create a control by specifying an area based on its absolute position, follow the steps below: 

  1. Open the PDF Scan.

  2. In the PDF Scan window, select what you want to steer:

    • To select text, click on the menu button Text.

    • To select an image, click on the menu button Image.

    • To select a table, click on the menu button Table.

  3. In the PDF View, specify the control area that you want to steer with your mouse.

    The PDF Scan turns the specified area into a ModuleAttribute and displays it in the Controls View on the right.

Specify areas in PDF view

  1. For the control type Table, perform the following additional actions:

    1. Open the Content View by clicking the menu button Show Content Preview.

    2. Specify the number of row or column headers, if applicable.

    3. Adjust cell margins with the slider Adjust cell borders, if necessary. Make sure that the structure of the table shown in the Content View matches that of the original table in the PDF document.

Adjust table cell margins with the Content View slider

Specify repetitive areas

Optionally, if an element of your PDF file appears in the same area on all pages of the document, you can create repetitive areas. For instance, if you want to check that the same area on all pages contains a certain text.

To create a repetitive area, follow the steps below:

  1. In the PDF View, specify the area that you want to turn into a repetitive area with your mouse.

  2. Right-click the area and select Repetitive Area from the context menu.

When you create a Module with one or more repetitive areas, an additional ModuleAttribute Repetitive Area Exclusions is also generated. This allows you to prevent these areas from being executed on certain pages. In test steps that use the module, you can do the following:

  1. Select Odd numbered pages from the ModuleAttribute's ValueRange to exclude all odd numbered pages.

  2. Select Even numbered pages from the ModuleAttribute's ValueRange to exclude all even numbered pages.

  3. Specify as a Value on the ModuleAttribute the pages to exclude. To do so, use the following syntax: <n>;<n-n>; ....

    Example: The value 1; 3-6; 9 excludes pages 1, 3, 4, 5, 6 and 9.

Specify an area using its relative position

You can create a control based on its position relative to another page element. To do so, you need to define the following elements:

  • The anchor control. This is the page element you use to define the position of the target control.

  • The target control. This is the element that you want to steer, and you define it by its relative position to the anchor control.

During testing, the PDF Engine 3.0 identifies the anchor control by searching the PDF document for the text or image that you define. Once it locates the anchor, it calculates the location of the target in relation to the anchor. After you save your PDF Module, you can specify the level of accuracy with which the PDF Engine 3.0 finds anchor controls in the document.

Note the following requirements:

  • Target and anchor must on the same page.

  • The anchor control must be uniquely identifiable in the PDF document.

  • You can't use a table or a repetitive area as an anchor control.

To specify an area using its relative position, follow the steps below:

  1. Open the PDF Scan.

  2. Specify at least two areas on the same page by their absolute position.

  3. In the PDF View, right-click the control that you want to use as the anchor and select one of the following options in the context menu:

    • To use it as a text anchor, select Use as Text Anchor for...

    • To use it as an image anchor, select Use as Image Anchor for...

  4. Select the name of the target control from the context menu list.

The PDF Scan shows an arrow pointing from the anchor to the target.

Once you have turned an area into an anchor control, you cannot change it back to an ordinary area.

Use Book Title as the anchor control for Book Authors

Edit an anchor control

Once you have turned an area into an anchor control, right-click on it to edit it. The context menu that opens gives you the following options:

  • To change the type of the anchor control, select Text Anchor or Image Anchor.

  • To add a target control to the anchor control, select Add/Remove target controls and select the target control that you want to add.

  • To remove a target control from the anchor control, select Add/Remove target controls and select the target control that you want to remove.

Make an anchor control uniquely identifiable

An existing anchor can become not uniquely identifiable if you perform one of the following actions:

  • You redraw an anchor control.

  • You rescan a Module which contains anchor control.

The Controls View highlights not uniquely identifiable anchor controls in orange.

To make an anchor control uniquely identifiable again, redraw it. The PDF Engine 3.0 calculates positions of its target controls relative to the new position of the anchor control.

Additional options

Additionally, the PDF Scan menu offers the following options:

Option

Description

Zoom

Change the zoom level of the PDF View.

 Zoom Fit

Enlarge the scanned PDF to fit the PDF View.

Show scanned areas

Show or hide the scanned areas in the PDF View.

Select Document Language

Select the language of the scanned PDF. The PDF Scan uses this language for optical character recognition (OCR).