Products | About Us

Mapping characters with Print Distributor

The Generic Text driver in Windows 95/98/Me had a nice character mapping facility labeled TTY Custom which would let you modify individual character codes to suit certain types of line or ASCII printers. Unfortunately the Generic Text driver in Windows NT/2000/XP only has a set of standard code pages, there is no equivalent to the TTY Custom in the older driver.

Using the Script action in Print Distributor 3.1 we can add this facility back in again, this tutorial will take you through the necessary steps to set it up. Start by creating your virtual printer in the Print Distributor Manager application selecting the Generic Text driver. When you get to the list of actions in the Wizard start by adding a new Script action, this script is going to modify the print file before it gets passed to any following actions. Copy the following script and paste it in the new Script action:

' Sample character mapping script

Option Explicit

Dim Characters(255)
Dim I

' Fill characters with defaults

For I = 1 to 255
    Characters(I) = Chr(I)
Next


' Custom character mapping

Characters(65) = "B"
Characters(66) = "A"

Dim objFSO, objTSIn, objTSOut
Dim lChar

' Create a temporary file with the new mapping

Set objFSO = CreateObject("Scripting.FileSystemObject")
Set objTSIn = objFSO.OpenTextFile(PrintFilePath, 1, false, 0)
Set objTSOut = objFSO.CreateTextFile(PrintFilePath & ".tmp", true, false)

Do While objTSIn.AtEndOfStream = False
    lChar = Asc(objTSIn.Read(1))
    objTSOut.Write(Characters(lChar))
Loop

objTSIn.Close
objTSOut.Close

' Delete the original and move the new file in its place
objFSO.DeleteFile PrintFilePath
objFSO.MoveFile PrintFilePath& ".tmp", PrintFilePath

Now click on the OK button to save the script and then add your normal Actions after the Script action such as WriteFile or RePrint. By default this script has two character changes, it swaps a capital A and B characters. To change this behaviour replace the two lines with your own character mappings:

Characters(65) = "B"
Characters(66) = "A"

The Script action was added in Print Distributor 3.1, if you have an earlier version you can download an upgrade here.

Feed