The function PrintCanvas is in the file print.c . It prints out the contents of the plot window, and all four of its borders in postscript format.
It is very easy in Tcl/Tk to dump out a postscript file of a canvas. The trick here was to combine five postscript files from five canvases (plot window and four borders) into one postscript file.
The way this is accomplished is, perhaps, not too elegant, but it does work. A brief outline of the algorithm is given below.
First the five canvases are dumped into five seperate postscript files. The file names are:
The input file (.ipl.total.ps) is scanned line by line, searching for keywords or phrases and replaces them with hard coded information.
These changes include.
-80 250 translate
.5 .5 scale
%%Page: n 5 where n is the page number
save
306.0 396.0 translate
1.44 1.44 scale
Here we add another translation line which depends upon the page
number. Below are the page numbers and their translations.
Page 0: -50 225 translate
Page 1: -50 -225 translate
Page 2: 50 -225 translate
Page 3: 500 -225 translate
Page 4: -50 -302 translate
After writing the final line, the algorithm reads four lines of input and ignores them, to skip whatever four lines were replaced by the last four shown above.
Note in the code you will see the input being compared to something like %%BoundingBox and be replaced with %%%%BoudingBox. This is because % is a special character in C and requires printing %% to actually print %.
Finally, the file .ipl.iplot.ps is sent off to the default printer. If the user wishes to print to a printer other than the default one, the easiest way is to just go to the UNIX command line. The file will not be erased, although it will be replaced by the next printing.