Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Algorithm for Canvas

2 views
Skip to first unread message

Bill Parker

unread,
Aug 5, 1996, 3:00:00 AM8/5/96
to

Does anyone already have an algorithm that I can use to call the
postscript command and it will print my canvas on multiple pages if
needed ? I know I can use the x y width height parameters of the
postscript command, but I want the file to be in multiple pages if
needed. Any response will be appreciated and you can send it to
bpa...@evtech.com

Thanks,

Bill

Mark Weissman

unread,
Aug 7, 1996, 3:00:00 AM8/7/96
to bpa...@evtech.com
What I do is a real inefficient hack, but here it is:

I maintain a list of canvases, one for each page of output.
At ps generation time, I maintain an associative array to hold
the postscript. I then edit the postscript on the fly to get rid
of the EOF stuck on each page (the canvas postscript command assumes
only one page). The two big inefficiencies are separate canvases and the
the redundant postscript header information on each postscript page. I
did get
rid of that at one time, using regsub, but the performance was too slow.

Here's the routine I use to generate the output:

set gblReportFonts(TitleFont)
"-*-Helvetica-Bold-*-*-*-*-140-*-*-*-*-*-*"
set gblReportFonts(NormalFont)
"-*-fixed-medium-*-*-*-*-80-*-*-*-*-*-*"
set gblReportFonts(LabelFont)
"-*-Helvetica-Bold-*-*-*-*-100-*-*-*-*-*-*"
set gblReportFonts(RowLabelFont)
"-*-Helvetica-Bold-*-*-*-*-80-*-*-*-*-*-*"
set gblReportFonts(TableFont)
"-*-fixed-medium-*-*-*-*-100-*-*-*-*-*-*"
set gblReportFonts(PageHeaderFont)
"-*-Helvetica-medium-*-*-*-*-80-*-*-*-*-*-*"
set gblReportFonts(PageFooterFont)
"-*-Helvetica-medium-*-*-*-*-80-*-*-*-*-*-*"

# X font spec to Postscript mapping
set gblReportPsFontMap($gblReportFonts(TitleFont)) {Helvetica-Bold
18.0}
set gblReportPsFontMap($gblReportFonts(NormalFont)) {Helvetica 6.0}
set gblReportPsFontMap($gblReportFonts(LabelFont)) {Helvetica-Bold
10.0}
set gblReportPsFontMap($gblReportFonts(RowLabelFont)) {Helvetica-Bold
8.0}
set gblReportPsFontMap($gblReportFonts(TableFont)) {Courier 8.0}
set gblReportPsFontMap($gblReportFonts(PageHeaderFont)) {Helvetica 6.0}
set gblReportPsFontMap($gblReportFonts(PageFooterFont)) {Helvetica 6.0}

proc rptPSGenerator { canvList psFile {orientation portrait} reportName}
{
set page 0
set outfile [open $psFile w]
puts "generating postscript to $psFile ..."
foreach canv $canvList {
global gblReportPsFontMap
incr page
puts " page $page..."
rptHeader $canv $reportName $page

update idletasks
if {$orientation=="landscape"} {
set ps($page) [$canv postscript -pagewidth 8.5i -pageheight
11i \
-height 8.5i -width 10i -rotate 1 \
-colormode gray -fontmap gblReportPsFontMap ]
} else {
set ps($page) [$canv postscript -pagewidth 8.5i -pageheight
11i \
-width 8.5i -height 10i \
-colormode gray -fontmap gblReportPsFontMap ]
}
puts -nonewline " substitution..."
regsub {%%Trailer.*%%EOF} $ps($page) {%%} ps($page)
puts -nonewline $outfile $ps($page)
puts " done."
}
puts $outfile "%%Trailer\nend\n%%EOF"
close $outfile
}

--
Bradley P. Orner email: bor...@gte.com
GTE Laboratories, Inc voice: 617-466-2935
40 Sylvan Rd. fax: 617-466-2960
Waltham, MA 02254

Mark A Harrison

unread,
Aug 7, 1996, 3:00:00 AM8/7/96
to

Bill Parker (bpa...@evtech.com) wrote:
: Does anyone already have an algorithm that I can use to call the
: postscript command and it will print my canvas on multiple pages if
: needed ? I know I can use the x y width height parameters of the
: postscript command, but I want the file to be in multiple pages if
: needed. Any response will be appreciated and you can send it to
: bpa...@evtech.com


Tako Schotanus has written a very nice canvas print dialog that features
page previewing, specification of page orientation, number of
pages, etc. It is distributed as part of [incr Widgets]. You can
look at

http://www.tcltk.com/iwidgets/iwidgets/canvasprintdialog.html
and
http://www.tcltk.com/iwidgets/

for more details.

Hope this helps,
Mark.

--
Mark Harrison http://jasper.ora.com/mh/

0 new messages