Updated 2013-01-18 02:21:27 by pooryorick

Ezprint is a Tcl extension for simplified Windows printing. It allows a Tcl application running on a Windows NT/2000/XP system to send raw data to a local or network-connected printer. It uses Tcl channel routines to define a new type of channel for printing.

To clarify: Ezprint does no data conversion. It just transports raw data to your printer. The data goes via a Windows installed printer driver, but in RAW mode, so the driver does no data conversion either. It is up to your application to generate data which is compatible with your printer. If you need data conversion - for example, an application generates PostScript but you need it to go to some random ink-jet printer - you probably won't find Ezprint useful.

Ezprint is distributed under an open source license, and comes with source code and a Borland-built DLL.

Ezprint doesn't have a real home page or development site, but you can get the latest version here: http://mysite.verizon.net/l.bayuk/ezprint.html (Broken as of March 24th, 2012)

You will find downloads for both Tcl8.4 and Tcl8.5.

The Windows installer of the NAP package includes the ezprint extension.

Here are some example code fragments, which assume you've already loaded the extension.

Make an option menu list of all available printers, with the user's default printer selected:
global selected_printer
set selected_printer [ezprint defaultprinter]
eval tk_optionMenu $widgetname selected_printer [ezprint listprinters]

Send a file "report.pcl" to the default printer:
set f [open report.pcl]
fconfigure $f -translation binary
set p [ezprint open [ezprint defaultprinter]]
fconfigure $p -translation binary
puts -nonewline $p [read $f]
close $p
close $f

Send a canvas $canvas as PostScript to a printer:
set pr [ezprint open $printername]
$canvas postscript -channel $pr
close $pr

Although ezprint is not stubs-enabled, Jeff Godfrey has touched up a version to make it so. [more refs]

(Ezprint is not stubs-enabled because it is built using the Borland compiler, and I do not think it is possible to make stubs-enabled extensions to Tcl using this compiler. This is because the Tcl core is built with MSVC. I probably should incorporate Jeff's patches to the source code anyway, using conditionals (not __BORLANDC__), but I have no way to test the result. -ljb)