11.4. Using the config.properties File

Typically PDFUnit does not need to be configured, but the file config.properties gives you the chance to do so. The following sections show you how:

Date Format for PDF Internal Dates

In the real world the creation date and modification date of a PDF document can be formatted in many different ways depending on the program which creates the PDF. So the required format string can be set in the config file:

###################################################################
# Declaring the default format for dates in PDF documents.
# Use the format strings according to java.util.SimpleDateFormat.
###################################################################
# Using date only:
#dateformat = 'D:'yyyyMMdd
# Using date and time:
dateformat = 'D:'yyyyMMddHHmmss

Locale of PDF Documents

Java needs a locale when working with date values and for the conversion of strings into lowercases too. PDFUnit reads the value of the locale from config.properties. All the constants defined in java.util.Locale are allowed. The default value is en (English).

#############################################################################
# Locale of PDF documents, required by some tests.
#############################################################################
pdf.locale = en
#pdf.locale = de_DE
#pdf.locale = en_UK

You can write all values in lowercase or uppercase. PDFUnit also accepts underscore and hyphen as a delimiter between language and country.

If you delete the key pdf.locale from config.properties by accident, then the default locale from the Java-runtime is taken (Locale.getDefault()).

Output Folder for Error Images

When a difference is detected while comparing rendered pages of two PDF documents, a diff image is created. It shows the master document on the left and differences to the actual test document on the right side. The differences are shown in red. The name of the test is placed above the image.

You can configure the output directory in the config.properties. By default the diff images will be stored in the directory containing the test PDF. That might be useful for some projects. But when you want to have a fixed folder for all diff images, you can configure that behaviour by using the property diffimage.output.path.files:

#############################################################################
#
# The path can be absolute or relative. The base of a relative path depends 
# on the tool which starts the junit tests (Eclipse, ANT, etc.).
# The path must end with a slash. It must exist before you run the tests.
#
# If this property is not defined, the directory containing the PDF 
# files is used.
#
#############################################################################
diffimage.output.path.files = ./

If your test produces diff images of PDF documents which are processed as streams or byte arrays, you can configure the output folder using the property diffimage.output.path.streams_and_bytearrays:

#############################################################################
#
# If this property is not defined, the directory of the running process
# is used.
#
#############################################################################
diffimage.output.path.streams_and_bytearrays = ./