Version 4 of ezprint

Updated 2005-12-26 14:49:40

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 is looking for a better home, but for now you can get it at http://lbayuk.home.mindspring.com/ezprint/


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 generally not stubs-enabled, Jeff Godfrey has touched up a version to make it so. [more refs]


Category Windows