Settings->Document Name



The options on the Document Name tab allow you to manipulate the document name. The document name passed in by the printing application may contain unwanted strings in addition to the desired document name. If the unwanted string is static text (such as "Microsoft Word -"), you can simply specify the exact text to remove.

Dynamic unwanted string
If the unwanted string is dynamic text, you can use regular expressions to eliminate the unwanted string.
First, you need to define the Document Name macro ([%DocName]) on the Save tab:


Assume the file name outputs are as follows:
John-Job200-1-0 sales - INV#195-0594.tif
Henry-Job268-1-0 sales - INV#195-0595.tif

You would like to remove the following unwanted strings at the beginning of the name:
"John-Job200-1-0 sales - "
"Henry-Job268-1-0 sales - "
The problem is that this is not going to be static information:
"John" is the username and will change.
"Job200-1-0" will increment.
"sales" is the document type and may change.
To accomplish your goal, you can construct a regular expression by putting the various components of the expression pattern between a pair of forward slash (/) characters.
One regular expression that can achieve this is:
/[^\-]*\-[^\-]*\-[^\-]*\-[^\-]*\-(.*)/[%1]/




Regex document name
When the Regex Document Name macro [%RegexDocName] is defined on the Save tab, image files names can be customized based on a value within the document. Note that text extraction is not OCR based, only plain text in the source document can be parsed by the regex. In other words, Zan Image Printer cannot parse text from scanned documents. To check whether or not Zan Image Printer can receive the value (client name, invoice number, etc.) within the document being printed as a character string from the associated printing application, enable text extraction on the Zan Image Printer's Text Extraction tab; then print to a Zan Image Printer to start collecting the extracted strings into the specified text file. If the generated text file does not contain the value that you want to use, you will not be able to use the [%RegexDocName] macro to automatically name the image files.

You need to construct a regular expression by putting the various components of the expression pattern between a pair of forward slash (/) characters.

Regex document name example #1:
The document to be printed will always be named "ABC Product Label", inside the print text is a string labeled "Contract Number:"
SHIPPING
Some Company
123 Cherry St
TRACKING #: 1X 012 VE2 01 1234 5678
BILLING: X/X
Contract Number: 12345678981698
You want to name the image file based on the text following the "Contract Number:", for the above example 12345678981698. An example regular expression that can achieve this is:
/Contract Number:\s*(\d*)/[%1]/



Regex document name example #2:
The document to be printed contains the following text:
(0088)
123 Cherry St
DOB: 8/16/1986, ID: 1234
You want to name the image file based on the address text following the "(0088)", for the above example 123 Cherry St. An example regular expression that can achieve this is:
/\)(.*?)dob:/[%1]/



Regex document name example #3:
The invoice to be printed contains the following text:
193967 Invoice
Page No. 1
Address: 123 Cherry St
Agent: Zefor
Name: De Rohtfawt
Account No: RF8188133
Date: 12DEC10
All the invoices are formatted with the 6-digit invoice number at the top and the account number (which always contains 2 capital letters and 7 digits) several lines below. You would like the file to be named as 193967 RF8188133.pdf. An example regular expression that can achieve this is:
/([0-9]{6})(.*?)([A-Z]{2}[0-9]{7})/[%1] [%3]/



Remove path
Select this option if you want to remove the path portion of document name and only use its file component. For example: c:\temp\file.txt is converted to file.txt


Remove whitespace
Select this option if you want to remove all white space characters from the document name.


Remove unwanted strings from document name
Select this option to parse the document name and remove unwanted strings.


Unwanted strings to exclude / Regular expression
Specify the strings that you want to remove from the document name. The strings are case-insensitive. Use a semi-colon ';' to separate multiple strings (e.g., file; temp). Leading and trailing white spaces in a string are ignored. Leading/trailing white spaces can be enclosed within double quotes (" ") if they are to be used as part of a string.
The table below lists some applications and the static strings that you may want to remove from the document name passed in by them.
Application Unwanted String
Microsoft Word "Microsoft Word -"
Notepad " - notepad"

The table above gives examples of static unwanted strings. If the unwanted string is dynamic or the Regex Document Name macro is defined, you need to construct a regular expression.

A regular expression, sometimes referred to as regex, is a pattern of text that consists of ordinary characters and special characters, known as metacharacters. The pattern describes one or more strings to match when searching a body of text. The regular expression serves as a template for matching a character pattern to the string being searched.

Zan Image Printer uses the Perl regular expression syntax. The following table contains a list of metacharacters and character classes for a quick reference:
Metacharacter Description Example/Comment
. matches exactly one character "r.t" matches "rat", "rut", "r t", but not "root"
? matches the preceding character or subexpression zero or one times "data?.dat" matches "datax.dat" and "data2.dat"
* matches the preceding character or subexpression zero or more times "zo*" matches "z" and "zoo"
+ matches the preceding character or subexpression one or more times "ab+c" matches "abc", "abbc", but not "ac"
\ escape character, used to find an instance of a metacharacter like a period "[0-9]\+" matches a digit followed by a plus character, but [0-9]+ matches one or more digits
| an OR operator to separate two expressions "x|y" matches an instance of "x" or "y"
$ matches the position at the end of the input string In Zan Image Printer, all newline characters are removed before parsing, so the $ metacharacter is not used
^ a negative character set "^[abc]" matches all characters except "a", "b" and "c"
- indicates a range of characters "[a-z]" matches any lowercase alphabetic character in the range 'a' through 'z'
[ ] indicates character class, matches any character inside the brackets "[abc]" matches "a", "b" and "c"
{x} matches must occur exactly x times "[0-9]{3}-[0-9]{4}" matches a regular 7 digit phone number
{x,} matches must occur at least x times "x{3,}" matches on at least 3 occurrences of x
{x,y} matches must occur at least x times, but no more than y times "[0-9]{4,6}" matches any sequence of 4, 5 or 6 digits
( ) indicates a match group (backreference)for later reuse, each captured match group is stored as it is encountered from left to right.
In Zan Image Printer, "[%0]" is the substring that matched the entire pattern, "[%1]" is the substring that matched the pattern enclosed in the first set of parentheses, and so on.
"www\.([a-z]+)\.com" matches "www.mycompany.com" and sets the back reference to mycompany.
\d matches a digit character "\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}" matches any IP address
\D matches a non-digit character "a\Dz" matches "abz", "aTz", but not "a2z"
\s matches a white space character "a\sz" matches any three-character string starting with "a" and ending with "z" and whose second character is a space
\S matches a non-whitespace character "a\Sz" matches any three-character string starting with "a" and ending with "z" and whose second character is not a space
\w matches a word boundary "\wcomput" matches "computer", "computing", but not "supercomputer"
\W matches a nonword boundary "\Wcomput" matches "supercomputer", but not "computing"



For Zan Image Printer, the regular expression should take the following form:
/pat1/pat2/g

pat1: required, the regular expression to search. The search is case-insensitive, thus you don't need to worry about capitalization (the metacharacter must still have the proper case). If the specified regular expression is invalid (such as mismatched parentheses or invalid syntax), Zan Image Printer will raise an error. So please ensure that the entered regular expression syntax is correct and enter the trailing forward slash (/) character only when you are done entering the regular expression.

pat2: optional, select and process captured match groups to form the desired document name. The use of [%0] within pat2 refers to the substring that matched the entire pattern, [%1] is the substring that matched the pattern enclosed in the first set of parentheses. If you have more than one group, you refer to them consecutively by [%2], [%3], and so on. If part2 is omitted, [%0] is assumed.

g: optional, the global flag indicates that the expression is applied to as many matches as it can find in the input string.

Example
This field is read only. When any option on this page is changed, this field will also change to reflect the processed (filtered) document name.


Help
Loads the help file, and displays the Settings->Document Name topic.