Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Printing Canvas Using Postscript

Status
Not open for further replies.

SNESWhiz

Programmer
Jun 25, 2002
3
US
Hi.

I'm trying to print the contents of a canvas, using the postscript method. However, whenever I print, all I get is an empty page. When I write the Postscript output to a file and view it, it too is blank.

Here's the code:

-----START CODE-----
canvas .thecanvas
label .thecanvas.thelabel -text "moo asdf qwert test\nqq uuiioopp\naassddffgg\nhhjjkkll\nzzxxccvv bbnnmm"
pack .thecanvas.thelabel -in .thecanvas
pack .thecanvas

set x0 0
set y0 0
set x1 [winfo width .thecanvas]
set y1 [winfo height .thecanvas]

foreach {x0 y0 x1 y1} [.thecanvas bbox all] {}
set w [expr $x1 - $x0]
set h [expr $y1 - $y0]

set ps [.thecanvas postscript -x $x0 -y $y0 -width $w -height $h]
#exec lpr -d$printer << [.thecanvas postscript -x $x0 -y $y0 -width $w -height $h]

set moo [open &quot;~/test.ps&quot; w]
puts -nonewline $moo $ps

puts &quot;x: $x0, y: $y0, w: $w, h: $h&quot;
-----END CODE-----

For some reason, the width and the height (w and h) are both 1 in this program. In my full program, they are 815 and 1180, though that also prints a blank page.
 
Since -x and -y default to the positions you specify, as do -width and -height, why not leave them out?

Anyway, I use the following proc for network printing (no &quot;exec lpr...&quot;) and it works fine for me:

proc psprnt {prtAdd} {
set sid [socket $prtAdd 9100]
<casnvas name> postscript -colormode color -channel $sid -rotate true
flush $sid
close $sid
Bob Rashkin
rrashkin@csc.com
 
Hello,Bong!
I´m not very experienced in using network things. Could you tell me what &quot;$prtAdd&quot; should be used for the local printer?
Thanks
 
firelex,

$prtAdd in my script is the IP address of the network printer. For example: 20.5.32.130 Bob Rashkin
rrashkin@csc.com
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top