pdf

Provides generic methods for working with PDF files.

If you are using oxygen.conf.js, pdf module must be added.

modules: ['web', 'log', 'assert', 'date', 'db', 'email', 'eyes', 'http', 'pdf']

assert

Asserts that text is present in a PDF file

Parameters:

Name

Type

Description

pdfFilePath

String

Relative or absolute path to the PDF file.

text

String

Text to assert.

pageNum

Number

optional Page number.

message

String

optional Message to throw if assertion fails.

reverse

Boolean

optional Check also reverse variant of string.

pdf.assert('./Data/pdf.pdf', 'Hello World', 1, 'Text was not found in PDF')

assertNot

Asserts that text is not present in a PDF file

Parameters:

Name

Type

Description

pdfFilePath

String

Relative or absolute path to the pdf file.

text

String

Text to assert.

pageNum

Number

optional Page number.

message

String

optional Message to throw if assertion fails.

reverse

Boolean

optional Check also reverse variant of string.

pdf.assertNot('./Data/pdf.pdf', 'Whats Up World', 1, 'Text was found in PDF')

count

Count the number of times specified text is present in a PDF file.

Parameters:

Name

Type

Description

pdfFilePath

String

Relative or absolute path to the pdf file.

text

String

Text to count.

pageNum

Number

optional Page number.

reverse

Boolean

optional Check also reverse variant of string.

Returns:

Number - Number of times the specified text was found.

var world_count = pdf.count('./Data/pdf.pdf', 'World', 1, true)
log.info('The word World appears: ' + world_count + ' time inside this PDF')