PDF-XChange - Tracker PDF Viewer - TIFF-XChange - Image-XChange - XMF-XChange - Raster-XChange - Support

Moderators: Tracker Support, TrackerSupp-Daniel, Chris - Tracker Supp, Vasyl-Tracker Dev Team, John - Tracker Supp, Ivan - Tracker Software, Sean - Tracker, Tracker Supp-Stefan

 
John - Tracker Supp
Site Admin
Topic Author
Posts: 8192
Joined: Tue Jun 29, 2004 10:34 am
Location: Vancouver Island - Canada
Contact:

File naming and how to create your own file naming rules

Tue Apr 12, 2005 11:43 am

Because PDF-XChange acts as a 'Virtual' printer and Windows does not naturally provide a comfortable mechanism for passing such 'inconsequential' information as a file name from all applications to printers, this can result in variable behaviour from different applications and this in turn can result in strange file naming behaviour - after all when printing a page to a conventional printer onto paper this is not a critical issue.

However when using this mechanism and a 'virtual' Printer to 'capture' output and create a disk based file - obviously such matters can be very important - we have provided a useful means to apply rules from specified applications to the output captured by PDF-XChange to help formalise this into predefined rules to enable meaningful file name conversion into a useful name format.

titrules.rsl is file PDF-XChange use to describe rules to convert the document title into a useable, formatted, document name.

It is necessary and helpful because many programs do this in different ways (see examples below) and works very simply, once understood.
We create a list of rules for custom programs and one default list for all others.

When a document is printed we know which program has printed the document and the generic document title. The Program is determined by the executable name (for example winword.exe for Microsoft Word), so we will select its own list of rules. If we cannot find custom list of rules for this program we will use default to explain how to use titrules.rsl.

We then try to apply the rules in the order given in the titrules.rsl file.

The first rule matching the application title will be applied, otherwise the document name will be same as the title captured from the output exe.

Here is short explanation of how to define a custom, new rule:

Each line in the titrules.rsl must be a comment or a separate rule. Comments must begin with // and continue until the EOL.

The Rule syntax is:
{executable name}: "{mask}" = "{result}"

Where the {executable name} is the program executable file name (the default extension .exe may be omitted).
Also the executable name may be empty to indicate that this rule is in the default list.

{mask} is a macro which defines how the document title may look to match this rule. Mask and may contain any characters except the "(quote) character as this is reserved.

Also the Mask may contain up to three *(asterisk)characters, which have a special meaning. Each asterisk represents a sequence of characters, which can be used in the resulting document name (see example below).

{result} is a macro which defines how the document name should be created. It may contain any characters except "(quote) character which again is reserved. Also it may contain the *(asterisk) character, followed by 1, 2, or 3. This sequence dictates that you want to insert a character sequence corresponding to one of three asterisks allowed in mask (see example below).

Symbols marked in red are separators and must be present in any valid mask.

For example.

I am a programmer and I have written my own cool program to print text files. I have named it 'MyCoolPrint.exe'. When printing, my program gives print jobs titles formed like this "Cool Print - document.txt - user - printing ...".

I now want to create .pdf files named like "user - document.pdf" from my application. To do this I can define a rule as follows:

MyCoolPrint: "Cool Print - *.* - * - printing ..." = "*3 - *1.*2"

This rule is constructed as follows and will be applied only for documents, printed from 'MyCoolPrint.exe'.

In the mask I have used all three asterisk's allowed as a maximum:

1: For the printed file name
2: For the extension
3: For user name (I know that they can be varied and want to use them in the resulting file name).

In the resulting file name I want to place the user name first, separated from the file name by " - ", so I write
*3 - *1.*2
Now, when I try to print a file, for example Big Document.doc, and my user name as defined by Windows when I logon is 'Admin', I would naturally receive a job title "Cool Print - Big Document.doc - Admin - printing ...".

PDF-XChange will determine; that this job is printing from MyCoolPrint.exe and will try to apply my custom rule as defined above. PDF-XChange will divide the title into the following components (as marked by color):
"Cool Print - Big Documet.doc - Admin - printing ...".

(The Components marked in black will be omitted)

*1 will correspond with "Big Document"
*2 - "doc",
*3 - "Admin".

Therefore PDF-XChange, using the rule provided, will reconstruct the document title "Admin - Big Document.doc", and will create a pdf document named
"Admin - Big Documet.pdf".

Below is the default titrules.rsl file installed on installation and updates to PDF-XChange - be warned that you should keep a copy of titrules.rsl with any changes made by you and on updates you will need to copy back your changes to the titrules.rsl file installed - the default location for titrules.rsl is PDF-XChange installation sub folder called \....\pdfSaver .

// comment
excel: "*" = "*1"
winword: "Microsoft Word - *" = "*1"
notepad: "* - Notepad" = "*1"
: "*.* - *" = "*1.*2"
: "* - *.*" = "*2.*3"
: "* - *" = "*2"

As you can see there are already 3 different rules for specific applications (MS Excel, MS Word and Notepad), and three common rules, which are used for all other unspecificed applications.

Please pay particular attention to the order in which these rules appear in the titrules.rsl file - PDF-XChange will try to apply them in the same order, so if you add a third common rule (: "* - *" = "*2") before the first two - they will never work, because the third rule is more common and included in the first two.

Therefore, if you need several rules for the same application (or wish to add more common rules) please take care when defining the order in which they are added)

Finally - please ensure you edit the titrules.rsl file in a text editor such as notepad and save the file in Unicode format - failure to do so will ensure the file is corrupt and any rules within it likewise - filenaming will become highly unreliable in this event.
If posting files to this forum - you must archive the files to a ZIP, RAR or 7z file or they will not be uploaded - thank you.

Best regards
Tracker Support
http://www.tracker-software.com

Who is online

Users browsing this forum: No registered users and 1 guest