Version 0 of BLT - graph - printing from Windows

Updated 2003-10-08 21:38:13

The Windows printing functions are not documented in the HTML distributed with the BLT extension, but you can find information on this and other features in the presentation file 'slides.pdf' in the Files section of the SourceForge project [L1 ]. But George graciously posted this summary to comp.lang.tcl.

Here are the different ways to print a graph under Windows.

1) Use the (undocumented) "printer" command and the "print1" operation in the graph.

 # Get a list of printers (local, not network)
 set names [blt::printer names]

 # Open the first one
 set pid [blt::printer open [lindex $names 0]]

 # Print the graph
 .graph print1 $pid

 # Close the printer.
 blt::printer close $pid

This prints the graph as a bitmap. This should work with most printers. The down side is that graph may look pixelated because the image is stretched to the resolution of the printer.

2) Use the (undocumented) "printer" command and the "print2" operation in the graph.

 # Get a list of printers (local, not network)
 set names [blt::printer names]

 # Open the first one
 set pid [blt::printer open [lindex $names 0]]

 # Print the graph
 .graph print2 $pid

 # Close the printer.
 blt::printer close $pid

This prints the graph to the printer device context. This works with many printers, but has problems with PostScript printer (but then you should be printing PostScript instead).

3) Use the "snap" operation to generate an enhanced windows metafile.

 # Print the graph
 .graph snap -format emf file.emf

   You can then include the file into a Windows document (such as
   as a PowerPoint slide) and print that document.  If the tool
   doesn't include enhanced metafiles directory, you can send it 
   to the clipboard and paste it in.

 # Print the graph
 .graph snap -format emf CLIPBOARD

4) Convert PostScript of the graph into PDF and print. You can generate a PostScript file of the graph and then run the file through a distiller to generate PDF. You can use either Adobe Acrobat or the Ghostscript distiller.


Category BLT