Terminalski supports terminal control escape sequences for redirecting received data to a printer; it is commonly referred to as 'local printing' in legacy terminals. Terminalski recognizes the following control escape sequences for local printing:

Is a standard ANSI/VT100 terminal control escape sequence? Description
<ESC>[5i Yes Start local printing; all received text is sent to a printer.
<ESC>[2016i No
(Proprietary escape sequence for Terminalski)
Start direct file printing.
Requires the content to be in data URI scheme:
data:[<mediatype>][;filename=<filename>][;base64],<data>
<ESC>[4i Yes Stop local printing.

Local Printing Modes

None

Terminalski will recognize the local printing control escape sequences, but the actual content will be simply discarded.

Apply font and margins

If the regular local printing (<ESC>[5i) or the direct file printing (<ESC>[2016i) for plain text file is started, it will be formatted according to the font and margin settings. Text lines are not wrapped and 0x0C (or U+000C) character will be treated as a form-feed (FF) control character that starts a new page.

Once Terminalski finishes receiving the printing content, it will open a preview window. If the content is in supported format (ex. plain text, PDF, JPG/PNG, etc.), you should be able to directly print it on your local printer. For unsupported formats, you should at least have an option to save it as a file.

Save to file

Instead of a preview window, Terminalski will open a 'Save As' window and try to save the content directly.

Direct raw network printing

Terminalski opens a TCP/IP connection to the specified address and writes the content data as they are received.

Please note that when direct file printing (<ESC>[2016i) is used, Terminalski sends the original file content to the printer instead of the raw encoded data it received from the server. Hence, if your server can generate actual printer control codes, you can transparently have them printed on your local network printer.

For example, if your local network printer accepts PostScript and your server can also generate output in the same format, you can simply save your output as a PostScript file and send it over 'direct file printing (<ESC>[2016i)'. You can also safely transfer printer control codes with binary data such as PCL.

Direct File Printing Data Format

When <ESC>[2016i is used, you must format the content of your file in data URI scheme (RFC 2097).

data:[<mediatype>][;filename=<filename>][;base64],<data>

<filename> must be percent-encoded (or URL encoded). If ;filename=<filename> is not provided, Terminalski assigns a random file name. If ;base64 is present, <data> must be encoded in Base64; otherwise, <data> must be percent-encoded (whitespace characters are ignored).

Please note that ;charset= parameter will be ignored even if provided. The character code page currently set for the terminal session will always be used.

EXAMPLE
data:text/plain;filename=hello.txt;base64,SGVsbG8gV29ybGQhCg==

Direct File Printing Sample Script

In order to make use of the direct file printing feature in Terminalski, the printing command and data must be sent from the server in data URI scheme. This can be easily accomplished by using tools and commands commonly found in Unix-like systems.

The following script demonstrates one of such possibilities. This script should work on most Unix-like systems with modern shells such as bash or tcsh.

Copy to Clipboard
Download as a File (tpr)

After downloading, please check its content and make sure the tools and commands used in the script are supported by your server. Once you have confirmed its compatibility and made necessary changes, you should upload it to your '~/bin' folder and give it an 'execute' permission:

chmod 755 tpr

Once you finish setting up the 'tpr' file, you can easily print files in Terminalski supported formats (ex. plain text, PDF, JPG, etc.) over the current connection (ex. tpr "~/plots/lines.pdf").