Comparing PDF files

This function allows two PDF files to be compared automated with each other. Any differences detected upon comparison are shown in the ExecutionLog after the test execution has finished.

The Module TC PDF Compare, which can be downloaded from the Tosca Exchange Portal, is used for comparing PDF files.

PDF comparisons can be performed using Adobe Acrobat Version 5, 6 or 7.

Settings

In the Settings dialog, the program to be used for PDF comparison is defined via the setting Application.

Options

PDF files are displayed as defined via the option Tools->View PDF. The following options are available:

Options: PDF to load

Select PDF file’s title

Specifies the path to the base file. This can either be manually entered or searched for using the Browsebutton.

Line separators

Defines the character to be set at the end of document lines. \r\n is used by default (carriage return and line feed).

Strings to replace

Any number of strings which should be excluded from comparison can be entered into this field separated by semicolons.

Close

This button aborts the process. Values which have already been entered are not saved.

View

The base file content can be shown using this button. This opens the program ViewDiffs (this program is part of Tricentis Tosca).

PDF to load window

Module TC PDF Compare

The Module TC PDF Compare contains the following ModuleAttributes:

Attributes

Attribute

Description

BaseLinePath

The path to the base file which is used for the comparison.

BaseFile

The name of the base file. If no name has been specified, the name of the TestCase is used as the file name.

PDF File

The name of the PDF file to be compared with the base file.

LineSeparator

Specifies the characters to be used at the end of a line in the document. \r\n is used by default.

StringsToReplace

Various character strings which should be excluded from comparison can be entered here separated by semicolons.

Special characters such as *, ? and # can be used in order to specify dynamic values.

  • The character * represents any number of characters (special characters, letters, digits).

  • The character ? represents exactly one character (special character, letter, digit).
  • The character # represents exactly one number.

Sample TestCase: Compare matching files

This TestCase compares two files with identical content.

TestCase Compare matching files

The files have the following content:

Content Example_basefile.pdf and Example_compareMatch.pdf

Sample TestCase: Compare differing files

The base file Example_basefile.pdf is compared with the document Example_compareNumbers.pdf, which contains different values for Datum (date) and AngebotsNr. (Quote no.) from in the base file.

TestCase Compare differing files

The file Example_compareNumbers.pdf has the following content:

Content Example_compareNumbers.pdf

The execution results in a verification error. The error description lists the differences between the two documents.

Sample TestCase: Replace strings and compare

In this TestCase, strings that should be excluded from comparison are replaced by wildcards.

The following three options exist for using wildcards in comparisons:

Replace numbers with # signs

The special character # is used as a wildcard for each number to be replaced. In the following example, the date 20.06.2007 is replaced by the wildcards ##.##.####. If the numbers before and after the Strings to replace should be ignored, a * must be set as a delimiter: *##.##.####*.

Replace numbers with # signs

Replace characters with ? signs

The character ? is used as a wildcard for each character to be replaced. If the characters before and after the Strings to replace should be ignored, a * must be set as a delimiter: *????*.

Replace numbers with ? signs

Replace numbers and characters with * signs

The wildcard * serves to replace any number of characters. In the following example, the entire string 20.06.2007 and the partial string 2346 are each replaced by *.

Replace numbers and characters with * signs

Testing strings (StringToReplace)

The character string for the TestStepValue StringToReplace can be tested in advance.

  1. Select the option Tools->View PDF from the main menu in Tosca Commander.

  2. Fill the input fields as described in chapter "Options".

String to replace - character string

 

  1. Click on the View button. If the string is valid, it is provided in the subsequent window on the appropriate line.

PDF file content with String to replace

Error description in the ExecutionEntry

As soon as the test execution is finished, the differences from the PDF comparison are listed in the ExecutionLog.

ExecutionLog including details on the PDF comparison