Version 13 of printing

Updated 2003-06-27 14:03:16

Use this page to accumulate pointers to various issues tcl has with printing:


Question:

How do I print the contents of a text widget that contains various unicode, mixed fonts, etc. ?

What about a text widget with embedded images?


Also, see LV's pithy introduction to the complexity of "printing" [L1 ].

In summary: printing means many things - to some, it means generating a report, like perl's format type command . To others, it means the equivalent of a screen shot of a particular window. To others, it means produce on paper the equivalent of what is on the screen, only scaled to the size on the paper. Or even to write, directly to a printer, the reports. And there may be other interpretations as well.

Different printers can expect data to be in ASCII, PostScript, as well as a variety of custom (and sometimes proprietary) languages.


Windows printer information with no particular connection to Tcl;

    package require registry
    registry keys HKEY_CURRENT_USER\\Printers\\Connections

or

    package require printer
    printer list

"printer" here is Michael I. Schwartz's.


[Discuss use of Xbit to help with printing. Example: the following script will create a Tk photo from a GUI window:

    # create ram image from a GUI window
    rimage window ramimg [rimage window $guiPath frame]

    # create a gimg image from a ram image
    set img [image create gimg -file ramimg]

    # create a Tk Photo named gui.photo
    $img dump gui.photo TKPHOTO 8 1

    # create a canvas image item with the gui.photo and print it

.....]


RS (ab)uses IE as printer driver for multilingual documents by generating a temporary HTML file (see taiku goes multilingual).


KBK's quick-and-dirty Unix-side Tcl-ignorant xwd-enabled screen-dump-to-printer:

    exec xwd -id [winfo id .] | xwdtopnm | ppmtops | lpr

During summer 2002, KBK says on comp.lang.tcl:

I'd love to have native printing on Windows, and would even devote a fair amount of time to it. The difficulty, though, is in coming up with a specification of just what "native printing" is - one that meets the requirements of a fair number of applications.

Generally speaking, page layout is vastly different from screen layout, so what's desired is NOT simply a "print screen" function. Printing a canvas to PostScript comes close for drawing applications, but is totally wrong for a text editor, and a "print" function for the text widget is out of reach unless we can define the pagination mechanism.

It's a hard problem to get started on. The mechanics aren't horribly difficult -- in fact, the hard part from the mechanical standpoint would be a backport of the functionality to Unix. Instead, the really thorny issue is defining what's wanted.


A Windows way to have a printer properties dialog come up:

 RUNDLL32 PRINTUI.DLL,PrintUIEntry /p /n\\machine\printer

[What category is this page?]