I would like to create a small gui application with ability to print
plain-text reports. It will be used mainly on Linux, but it is
possible that also on MS Windows. The question is - how can I print
something (text, not graphics) from Tcl? Couldn't find any useful
information, is it really not supported?
Regards!
One of the not Windows compatible and very hakish methods I choose some
years ago was to write html file, convert it with html2ps and feed the
postscript file directly to lp.
At least Debian also ships a 'a2ps' converter that should be able to
convert plaintext directly to postscript.
Ugly but works.
> The question is - how can I print something (text, not graphics) from Tcl?
> Couldn't find any useful information, is it really not supported?
There are some possible ways:
http://wiki.tcl.tk/_/search?S=print&_charset_=utf-8
#v+
2009-07-22 11:40:17 . . . Printing under Windows
2009-06-05 01:08:58 . . . Tcl/Tk Printing Support
2009-05-22 18:38:53 . . . pdict: Pretty print a dict
2009-04-08 11:02:13 . . . printing
2009-02-27 15:47:45 . . . Printing under MacOSX
2008-12-27 00:47:09 . . . quoted-printable
2008-11-12 18:18:31 . . . Brace-level pretty printer
2008-01-07 01:28:34 . . . Print Area Selector
2007-11-13 19:51:36 . . . Printing text files under Windows
2007-05-20 21:54:21 . . . Printing a canvas under Windows
2007-01-26 20:43:54 . . . Printing DYMO Labels with Tcl and tcom
2007-01-09 16:10:12 . . . XML pretty-printing
2006-11-01 13:40:42 . . . Printing a text file to a lpr printer
2006-10-30 22:43:22 . . . Category Printing
2006-10-30 19:49:51 . . . Printing a canvas using GhostScript
2006-05-01 14:17:48 . . . Uploading Type1 fonts to a network printer
2005-10-25 09:38:36 . . . BLT - graph - printing postscript
2005-07-15 12:24:42 . . . email pretty printer
2005-05-20 10:56:37 . . . Printing proc sequence
2004-01-16 18:22:32 . . . BLT - graph - printing from Windows
#v-
--
Zbigniew
To print, you could:
open a pipe to a command line print command like lpr or lp, and write
the text to the pipeline
open a port to which a printer is connected and write to the printer
use a PDF creation extension, write your report out as a PDF, then
invoke the command appropriate on the platform for printing PDFs
open a text file and write the report out to the file, close the file,
then invoke the command line appropriate on the platform for printing
plain text files
open a file, write out the report as html, then invoke a web browser
with the flags for it to display the html file and to print it
make use of one of the frameworks which allow you to send the report
to a printing component available elsewhere on the machine. There used
to be a framework called ToolTalk for this sort of thing, but I think
that's been long gone and I think something liek CORBA or other
frameworks are now used.
Perhaps others can add to this list.
As you can see, the topic of printing, as popular as it is, is rather
complex because printing means so many different things to people.
There isn't such a package, unfortunately. Linux, UNIX, and MacOSX ALL
have lp/lpr and lpstat available -- it is trivial to use these programs
to implement a dialog box to select a printer (lpstat will give you a
list of possible printers, their status, and which one is the default)
and to implement sending a Postscript file to the print queue (ie: $canvas
postscript -file "|lpr -P..." ...). MS-Windows is the 'odd ball' here,
with its strange / wonderful printer interface logic. It would be
seriously non-trivial to write an extension for this. Either a large
chunk of Ghostscript would have to be incorporated into this extension
(eg the Postscript => MS-Windows GDI code) OR the canvas widget would
have to be rewritten to implement a 'gdi' command to call the GDI API to
'draw' every item (parallel code to the existing X11 and Postscript
code).
It is far easier to punt. I'm using the pdf4tcl package to generate a
PDF file for one application. The end user is on his/her own to
actually get it on paper. Another app creates a LaTeX file and runs
pdflatex to make a PDF file. Again the user is on his/her own getting
this on paper. Presumably they can download either the MS-Windows port
of Ghostview/Ghostscript or Adobe's reader. There might be some other
free PDF readers (has xpdf been ported to MS-Windows?).
>
--
Robert Heller -- 978-544-6933
Deepwoods Software -- Download the Model Railroad System
http://www.deepsoft.com/ -- Binaries for Linux and MS-Windows
hel...@deepsoft.com -- http://www.deepsoft.com/ModelRailroadSystem/
FYI, there a number of free PDF readers available for Windows. Among
them...
- Foxit Reader
- PDF-XChange Viewer
- Cool PDF Reader
- Perfect PDF Reader
- Sumatra PDF Viewer
I have some experience with the first two - both of which are nice.
Jeff