Syntax Guide
Version 6.x.x.x

Important

When using the syntax described in this document it MUST BE WRITTEN EXACTLY AS DESCRIBED

All syntax is CASE SENSITIVE.

All syntax applies to the latest release only (see Release Notes for details of latest release)

ADRMatchId Variable

The ID of the ADR match for a matched document.

Syntax

{page.ADRMatchId}

Example

Match={page.ADRMatchId}

AppPath Variable

Return a string containing the path of the folder where the applications runs.

Syntax

{AppPath}

Example

Example used in the “Data block expression” setting of the Data Exporter plugin:

{AppPath},{OutputFilePath},{GetBarcodeText()},{Date():ddMMyyyy}

BarcodeCount Variable

The number of found barcodes.

Syntax

{BarcodeCount}

Example

Example used in the “Document footer” settings of the Document Visualisation plugin:

{BarcodeCount} barcode(s) in this document

BatchCapturedPageCount Variable

The total number of pages in the captured batch.

Syntax

{BatchCapturedPageCount}

Example

Example used in the “Capture complete” settings of the Document Visualisation plugin:

Captured Pages={BatchCapturedPageCount}

BatchDocumentSavedCount Variable

Return the number of saved documents in a batch.

Syntax

{BatchDocumentSavedCount}

Example

Example used in the “Capture complete” settings of the Document Visualisation plugin:

Documents saved={BatchDocumentSavedCount} documents

BatchTotalSavedPageCount Variable

The total number of pages saved in a batch.

Syntax

{BatchTotalSavedPageCount}

Example

Example used in the “End of save” settings of the Document Visualisation plugin:

Total pages saved={BatchTotalSavedPageCount}

Capitalise Function

Return a capitalized version of an input string.

Syntax

{Capitalise(input)}

Example

Example used in the “Output file path” settings of the Automatic File Namer plugin:

{Capitalise(“scantopdf”)}

Result = SCANTOPDF

Concatenate Function

Concatenate 2 strings together into 1 output.

Syntax

{Concatenate(string 1, string 2)}

Example

C:\PDF Files\{Concatenate(“Invoice”,GetBarcodeText())}.pdf 

CountList Function

Return a count of the number of items in a given list, and given separator.

Syntax

{CountList(string list, string delim, bool ignoreEmptyEntries)}

Example

{CountList(“A-B-C”,”-“,true)}

Result = 3

Date Function

Provides a date in a specified format.

Syntax

{Date():format specifier}

Examples

{Date():dd-MM-yyyy} – UK Date format e.g. 28-12-1996

{Date():MM-dd-yyyy} – US Date format e.g. 12-28-1996

{Date():hh-mm-ss} – Time format e.g. 11:43:59

{Date():dd MMM yyyy} – Date with abbreviated month format e.g. 01 May 2021

Document Object

Return a document object.

Properties Syntax

{document.Property}

Properties

IncludedPageCount – the number of pages in the document.
OutputFileExtension – the windows extension of the output document.
OutputFileName – the file name of the output document.
OutputFilePath – the full file path of the output document (including extension).
OutputFolder – the folder of the output document.

Example

For a 7-page document saved with a path of: C:\PDF Files\12345.pdf

{document.OutputFilePath} – would return: C:\PDF Files\12345.pdf
{document.OutputFolder} – would return: C:\PDF Files
{document.OutputFileName} – would return: 12345.pdf
{document.OutputFileExtension} – would return: .pdf
{document.IncludedPageCount} – would return: 7

Methods Syntax

{document.Method()}

GetBarcodeCount – the number of barcodes in a document.

Example

{document.GetBarcodeCount()

Retained for backward compatibility only. Use document IncludedPageCount instead.

DocumentIncludedPageCount Variable (Obsolete)

The number of pages in the current document.

Syntax

{DocumentIncludedPageCount}

Example

Example used in the “Document header” settings of the Document Visualisation plugin:

This document contains {DocumentIncludedPageCount} page(s)

DocumentNumber Variable

The number of the current document in the batch.

Syntax

{DocumentNumber}

Example

Example used in the “Document header” settings of the Document Visualisation plugin:

This is document number {DocumentNumber}

DocumentPageNumber Variable

The page number within the current document.

Syntax

{DocumentPageNumber}

Example

Example used in the “Page caption” settings of the Document Visualisation plugin:

This is page number {DocumentPageNumber}

DocumentProfileName Variable

The active document profile name (when Document Profile Selector is installed).

Syntax

{DocumentProfileName}

Example

Example used in the “Output file path” settings of the Automatic File Namer plugin:

C:\PDF Files\{DocumentProfileName}\{GetBarcodeText()}.pdf

DocumentSize Variable (In Bytes)

The size of the current document in bytes.

Syntax

{DocumentSize}

Example

Example used in the “Data block” settings of the Data Exporter plugin:

{DocumentSize},{DocumentIncludedPageCount},{OutputFilePath}

A more “user friendly” format is:

{FormatByteSize(DocumentSize)}

EmailFlag Variable

A Boolean variable indicating whether the mail (output) document option is on.

Syntax

EmailFlag=boolean

Example

Example used in the “Condition” setting of the SMTP plugin:

EmailFlag=true

EnhanceOCRData Function

Enhances OCR data using a pattern so that common OCR misreads can be corrected, for example:

  • Misreading number 8 as the letter B
  • Misreading number 0 as the letter O
  • Misreading number 1 as the lower case letter l
Syntax

{EnhanceOCRData(object variable ,string pattern)

Pattern is a placeholder using N to represent the position of a NUMERIC character and A to represent the position of an ALPHA character.

Example

If the OCR result had extract data incorrectly, for example:

Actual text = 19BR863
OCR result = 198R863

Into a variable called dgCaseNumber and this needed correction, the function would be:

EnhanceOCRData(dgCaseNumber, “NNAANNN”)

Result = 19BR863
The pattern requires an Alpha character in position 3, so the 8 is corrected to a B.

Environment Object

Returns information about the system environment.

Syntax

{Environment.MachineName}

Example

{Environment.MachineName}

Result = A string containing the name of the computer

More details are available on the Microsoft website.

Extract Function

Returns an extracted substring from a given input using delimiter and index.

Syntax

{Extract(input,delimiter,index)}

Example

{Extract(“FIELD1-FIELD2-FIELD3″,”-“,3)}

Result = FIELD3

GetBarcode Function

Returns a barcode object (for optional parameters of barcode type, matching regex pattern and on a given page number). A Barcode object has the following properties:

  • Coordinates – The position of the barcode (x and y position and height & width).
  • Direction – The direction (orientation) of the barcode (left to right, right to left, top to bottom, bottom to top).
  • Text – The text value encoded into the barcode.
  • Type – The barcode type (for example Code39, Code128 etc).
Syntax

{GetBarcode(string barcode type, string Regex, integer Page Number)}

Example

Example used in the “Data block expression” settings of the Data Exporter plugin:

{GetBarcode(“Code39″,”^TMC”).Text}

GetBarcodeLiteralList Function

Returns a list of barcode values delimited by a delimiter and matching an optional regular expression from a given optional page range.

Syntax

{GetBarcodeLiteralList(String delimiter,String regular expression,Boolean default to empty, String page range}

Example

To extract a list of barcodes that match a pattern of 5 digits from the 1st page of a document, separated by a dash character and default to empty if none found.

{GetBarcodeLiteralList(“-“,”[0-9]{5}”,true,”1″)}

GetBarcodeText Function

By default returns the first available barcode text value using an optional barcode type, matching a regular expression and on a given page number. An alternative use is to return a particular barcode using an index number. The barcodes on a page are read from left to right and then top to bottom.

Syntax

{GetBarcodeText(String barcode type,String regular expression,integer page number)}

Example

To get the first available barcode on a page – {GetBarcodeText()}

To get the 3rd barcode on a page (barcodes read left to right, top to bottom) – {GetBarcodeText(3)}

To get a code 39 barcode that starts with INV and is followed by 6 digits on page 1 of a document – {GetBarcode(“code39″,”INV[0-9]{6}”,1)}

GetCounter Function

Gets the current value of a counter. See also IncrementCounter

Syntax

{GetCounter(String counter name):optionalformat}

Please note : If a counter name is not specified then this function returns the value of the global counter used in the IncrementCounter function

Example

Example 1 – To get the value of a counter called BC formatted to 4 digits to create a value such as 0001, 0002, 0003

{GetCounter(“BC”):0000}

GetDoubleInputFileName

Display a special validation file dialog designed to double input a file name.

Syntax

{GetDoubleInputFileName(string title, string inital directory, string filter, string file name)}

Example

{GetDoubleInputFileName(“Enter a file name”,”C:\PDF Files\”,”.pdf”,”Invoice-“}.pdf

GetFileName

Returns the file name of a given file path

Syntax

{GetFileName(file path as string)}

Example

{GetFileName(ImportFilePath)}

This will return the filename of the imported file

GetFileNameWithoutExtension

Returns the file name of a given file path without the file extension.

Syntax

{GetFileNameWithoutExtension(filepath)}

Example

Example used in the “Error case name generation” settings of the Automatic File Namer plugin:

C:\PDF Files\Errors\{GetFileNameWithoutExtension(ImportFilePath)}.pdf

This would save the file using the name of the imported source file.

GetFilePathWithUniqueVersion Function

Returns a unique file path with a formatted version suffix.

Syntax

GetFilePathWithUniqueVersion(string filepath, string format, boolean useOriginal, integer startInd ex}

filepath – a string to represent the path of the output file format – a string to represent the format to use for the version number.
useOriginal – a boolean set to true to use just the name for the first version, set to false to use the name and version.
startIndex – an integer to represent the number to use for the first version (1 by default).

Example

Example 1 – used in the “Output file path” settings of the Automatic File Namer plugin:

{GetFilePathWithUniqueVersion(“C:\PDF Files\doc.pdf”,”_{0:000}”, true,1)}

This would create the following file path/name:

C:\PDF Files\doc.pdf – no version number
C:\PDF Files\doc_001.pdf – version 1
C:\PDF Files\doc_002.pdf – version 2

Example 2 – used in the “Output file path” settings of the Automatic File Namer plugin:

{GetFilePathWithUniqueVersion(“C:\PDF Files\”+ GetBarcodeText()+”.pdf”,”_{0:000}”,true,1)}

This would use the barcode value for the file name and then create new versions if the same barcode was recognised again. For example if the barcode value was TMC7200, this would create the following file path/name:

C:\PDF Files\TMC7200.pdf – no version number
C:\PDF Files\TMC7200_001.pdf – version 1
C:\PDF Files\TMC7200_002.pdf – version 2

 

GetFolderName Function

Returns a folder name for a given file path.

Syntax

{GetFolderName(filepath as string)}

Example

Example used in the “Output file path” settings of the Automatic File Namer plugin:

{GetFolderName(ImportFilePath)}\Output\{Date():dd-MM-yyyy}-{IncrementCounter():000}.pdf

GetLastVariable Function

Returns a variable from a page, document or save batch. If the variable being used does not exist on a page, it checks the document, if not on the document it checks in the save batch. This enables variables to be set once per save batch and used in multiple documents.

Syntax

{GetLastVariable(string variable name)}

Example

Example used in the “Output file path” settings of the Automatic File Namer plugin:

C:\PDF Files\{GetLastVariable(“folder”)}\{Date():dd-MM-yyyy}-{IncrementCounter():000}.pdf

This would use a variable called folder, which had been captured using the Regex setting in barcode recognition.

GetWeekOfYear Function

Returns the week number corresponding to a date.

Syntax

{GetWeekOfYear(Date)}

Example

{GetWeekOfYear(Date())}

Result = Integer representing the current week number of the current year.

ImportFilePath Variable

Returns the file path of the imported source document.

Syntax

{ImportFilePath}

Example

Example used in the “Data block expression” settings of the Data Exporter plugin:

{ImportFilePath},{OutputFilePath},{GetBarcodeText()},{Date():ddMMyyyy}

ImageExtension Variable

Returns the image extension of a given file path

Syntax

File Path.{ImageExtension}

Example

Example used in the “Data” setting of the Data Exporter plugin:

{GetFileNameWithoutExtension(OutputFilePath)}.{ImageExtension}

IncrementCounter Function

Increments a counter for use in automatic file naming. The counter can be formatted using an optional format as shown below.

Syntax

{IncrementCounter(name as string, increment as integer, condition as boolean):optionalformat}

Example

Example 1 – To increment a simple counter of the format 1, 2, 3 etc.

C:\PDF Files\{IncrementCounter()}.pdf

This would create the following file path/name:

C:\PDF Files\1.pdf
C:\PDF Files\2.pdf
C:\PDF Files\3.pdf

Example 2 – To increment a counter of the format 001, 002, 003 etc.

C:\PDF Files\{IncrementCounter():000}.pdf

This would create the following file path/name:

C:\PDF Files\001.pdf
C:\PDF Files\002.pdf
C:\PDF Files\003.pdf

Example 3 – To increment a counter called bc, incrementing the counter by 2 each time, whenever a barcode is present on the document.

C:\PDF Files\{IncrementCounter(“bc”,2,GetBarcodeText()!=null):000}.pdf

This would create the following file path/name:

C:\PDF Files\001.pdf
C:\PDF Files\003.pdf
C:\PDF Files\005.pdf

InputBox Function

Displays an input box with a given prompt, title and optional default value to allow entry of data.

Syntax

C:\PDF Files\{InputBox(“Invoice number”,”Accounts Department”,”INV”)}

This would produce an input box when a document is saved.

Example

Example used in the “Data block expression” settings of the Data Exporter plugin:

{ImportFilePath},{OutputFilePath},{GetBarcodeText()},{Date():ddMMyyyy}

IsNull Function

Returns true if a variable is null.

Syntax

IsNull(variable)

Example

Example used in the “Condition” settings of the Document Indexing plugin:

IsNull(invoiceNumber)

Launch Function

Launch an external application.

Syntax

{Launch(string command, string parameters, string error message)}

Syntax breakdown:

  • command – the command to execute
  • parameters – the parameters to add to the command when it is launched
  • error message – an error message to display if the command cannot be launched
Example

Launch(“C:\Program Files (x86)\Adobe\Acrobat Reader DC\Reader\AcroRd32.exe”,document.OutputFilePath,”Cannot launch {0}”)

MergePDFFiles Function

Merges PDF Files Together

Syntax

MergePDFFiles(string destinationFilePath, FilesToMerge)

Note FilesToMerge is the list of files to merge so it can be a string[] or List<string> or a string of file paths separated by “,” see example for more details

Example

Example used in the Supervisor plugin >>  Action script >> End of save batch event to merge all the files saved in a batch into a single merged PDF file

MergePDFFiles(“C:\PDF Files\Batch” + batchReference + “.pdf”, savedDocuments.OutputFilePaths)

where batchReference is a ScanToPDF variable OR constant

RemoveChars Function

Removes chars defined as ASCII codes (single or comma separated list) and returns result.

Syntax

{RemoveChars(string input,asciiCodes)}

Example

Example 1

{RemoveChars(“HELLO WORLD”,32)}

Example 2

{RemoveChars(“HELLO WORLD”,’ ‘)}

Result = “HELLOWORLD”

NOTE: ASCII CODE DECIMAL 32 IS THE SPACE CHARACTER.

RemoveExtraSpaces Function

Removes trailing and leading spaces and sequences of 2 or more spaces from an input string.

Syntax

{RemoveExtraSpaces(string input)}

Example

{RemoveExtraSpaces(” HELLO WORLD “)}

Result = “HELLO WORLD”

RemoveSpaces Function

Returns a string stripped of all spaces from a string input.

Syntax

{RemoveSpaces(string input)}

Example

{RemoveSpaces(“HELLO WORLD”)}

Result = “HELLOWORLD”

Replace Function

Replace an old value in a given string with a new value.

Syntax

{Replace(string input, string old-value, string new-value)}

Example

{Replace(GetBarcodeText(),”SO”,”SALES-ORDER”)}

Example breakdown:

  • Input = SO-12345
  • Result = SALES-ORDER-12345

SetBookmarkForCurrentPageIf Function

Create a bookmark in a PDF document when a condition is met.

Syntax

SetBookmarkForCurrentPageIf(condition, path, title, includePageInOutputDocument, color, displaystyle, expanded, coordinates)

Parameters:

  • condition – a condition that returns true or false (Boolean)
  • path – the path of the bookmark
  • title – a title for the bookmark
  • includePageInOutputDocument – a Boolean to indicate if the page containing the bookmark should be contained in the output document
  • color – a color for the bookmark
  • displaystyle – set the style used for the bookmark font – Regular, Bold or Italic
  • expanded – Boolean to indicate if the bookmark should default to expanded when the document is opened
Example

SetBookmarkForCurrentPageIf(Regex.IsMatch(GetBarcodeText(),”^BOOKMARK”),”\” + GetBarcodeText(),GetBarcodeText(), false)

This sample would insert a bookmark using the barcode value for the path and name, for any barcode that started with BOOKMARK, removing the page containing the barcode.

SetVariable Function

Sets a ScanToPDF variable. The variable can then be used in other syntax, for example in file naming or data export.

Syntax

SetVariable(string context, string varName, string varValue)

Parameters:

  • context – the context of the variable storage and can be either of global, page or document
  • varName – the name of the variable to assign
  • varValue – the value to set the variable to
Example

Examples used in the “Action Script” settings of the Barcode Recognition plugin:

SetVariable(“global”,”FIELD1″,GetBarcodeText())

This would set a global variable called FIELD1 containing the value of the first barcode found on a page. The variable FIELD1 could then be used in the automatic file namer output file path setting, just enclose the variable in curly braces to use it, for example:

C:\PDF Files\Invoices\{FIELD1}.pdf

SetVariable(“global”,”DocDate”,DateTime.Now.ToString(“dd-MM-yyyy”))

This would set a variable called DocDate with the current date in the form 25-12-2021

SMTPSendMail Function

Use the SMTP Mailer plug-in to send an email.

Syntax

SMTPSendMail(fromAddress, toAddress, subject, body)

Example

Example used in the “Action Script” settings of the Supervisor plugin:

SMTPSendMail(‘me@oimaging.co.uk’,’you@oimaging.co.uk’, ‘Error’, ‘There has been an error with the file import’)

SubString Function

Retrieves a substring from a given string. The substring starts at a specified character position and has a specified length.

Syntax

SubString(string, startindex, length)

Parameters:

  • string – the string to be processed
  • startindex – the starting position of the substring (zero based)
  • length – the length of the substring
Example

C:\PDF Files\{SubString(GetBarcodeText(),0,3)}.pdf

This would return the first 3 characters of a barcode.

Ternary Function

Returns a string from choices decided by conditions. Var1 is returned for the true condition. Var2 is returned for a false condition.

Syntax

Ternary(Boolean condition, String var1, String var2)

Example

Example 1

{Ternary(docType=”INV”,”INV” + invoiceNumber,”PO” + poNumber)}

NOTE: Improved in version 5.1.2.14

An extended Ternary syntax where each condition is tested sequentially:

Ternary(condition1, value1, [condition2], [value2], …, [elseValue])

Example 2

{Ternary(docType=”INV”,”INV” + invoiceNumber,docType=”PO”,”PO” + poNumber)}

Translate Function

Returns a translated input string where all found elements in list1 have been replaced by their corresponding element in list2. The lists are separated by the pipe ‘|’ character.

Syntax

{Translate(String input, String list1, String list2)}

Example

{Translate(docType,”SO|PO|INV”,”Sales Order|Purchase Order|Invoice”)}

Parameters:

  • SO – would become Sales Order
  • PO – would become Purchase Order
  • INV – would become Invoice

TranslateUsingCSVFile

Returns a translated input string from a CSV file.

Syntax

{TranslateUsingCSVFile(Object input, String csv file path, Object default, Boolean skip 1st line, Integer search column, Integer result column)}

Example

{TranslateUsingCSVFile(alpha,”c:\oic\translate.csv”,”NOT FOUND”,true,1,2)}

This syntax would translate the variable called alpha into a new value using the 1st column of the CSV file c:\oic\translate.csv as the search column, returning the value in column 2 as the result. If the search was un-successful the return value would be NOT FOUND. The CSV file has column headers in the 1st line so the 1st line is skipped (setting the Boolean skip 1st line to True).

ValueMatchesRegex Function

Returns true if input matches regex pattern.

Syntax

{ValueMatchesRegex(String input, String Regex)}

Example

Example used in the “Condition” settings of the Document Indexing plugin:

{ValueMatchesRegex(GetBarcodeText(),”INVOICE”)}

This would display the document indexing window if the barcode value was INVOICE.

Have A Question / Need Further Help?

ScanToPDF

Privacy Overview

This website uses cookies so that we can provide you with the best user experience possible. Cookie information is stored in your browser and performs functions such as recognising you when you return to our website and helping our team to understand which sections of the website you find most interesting and useful.

Further information on how we use your cookie data can be found in our Privacy Policy.