The 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. 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.
# 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
2) Use the (undocumented) "printer" command and the "print2" operation in the graph. 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).
# 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
The [blt::printer names] function only returns local printers. But if you have a list of valid network printer names, the [blt::printer open] function appears to accept them. Michael Schwart's printing extension (see TkPrint) seems to get a valid list of network printers.
3) Use the "snap" operation to generate an enhanced windows metafile. You can then include the file into a Windows document (such as as a PowerPoint slide) and print that document. You can also send the metafile to the clipboard and paste it in. (Note that the "snap" operation works on both Windows and Unix, but you can only snap photos on Unix.)
# Print the graph .graph snap -format emf file.emf # Copy the graph to the clipboard for pasting .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. See BLT - graph - printing postscript for an example.
Network Printers
Note that the [blt::printer names] function only returns locally connected printers. But if you just call the [blt::printer print1] or [blt::printer print2] function without a printer id, then the standard Windows printer dialog pops up, and the user can just select the printer they want.