CGI/Perl Guide | Learning Center | Forums | Advertise | Login
Site Search: in

  Main Index MAIN
INDEX
Search Posts SEARCH
POSTS
Who's Online WHO'S
ONLINE
Log in LOG
IN

Home: Perl Programming Help: Beginner:
printing a Tk canvas

 



airo
stranger

Oct 12, 2001, 2:24 PM

Post #1 of 5 (753 views)
printing a Tk canvas Can't Post

hi,
I'm not sure if this is the correct place for this question. But...
is there a way to print a canvas to a printer.
here is a simple example of what i have.....
use strict;
use Tk;
use Tk::Menubutton;
use Tk::Canvas;

my $mw = MainWindow->new;


my $canvas = $mw->Canvas(-width=>200,-height=>110,
-background=>"white")->pack(
-side=>"top",-anchor=>"n");
$canvas->createText(100,20,
-text=>"Here is an example of what\nthe form should look like.",-tags=>"note");
$canvas->createText(85,60,
-text=>"\nTitle Colors\n(10 spaces)Blue\n(10 spaces)Green\n(10 spaces)Red",
-tags=>"note");$canvas->createRectangle(80,50,150,35,-tags=>'note');
$canvas->createRectangle(80,68,150,53,-tags=>"note");
$canvas->createRectangle(80,83,150,70,-tags=>"note");
$canvas->createRectangle(80,100,150,85,-tags=>"note");
$mw->Button(-text=>'Print Canvas',-command=>sub {$canvas->postscript(-file=>"testps.out");},-width=>17)->pack;
MainLoop;
the button will create a postscript file but I want to just click and have the canvas print. is it possible????
thanks
paul




mhx
Enthusiast / Moderator

Oct 12, 2001, 11:27 PM

Post #2 of 5 (748 views)
Re: printing a Tk canvas [In reply to] Can't Post

Since it seems you already know how to create a PostScript file from your Canvas, your only problem is how to send this to your printer. If you have a printer that understands PostScript (most high quality laser printers do) you can directly send the postscript file to your printer. On my HP-UX this would be something like:

Code
lp -ops testps.out

If you don't have a PostScript printer, you may need ghostscript. This tool will convert PostScript input to printer specific output. It even generates PDF output, if you like.

-- Marcus


Code
s$$ab21b8d15c3d97bd6317286d$;$"=547269736;split'i',join$,,map{chr(($*+= 
($">>=1)&1?-hex:hex)+0140)}/./g;$"=chr$";s;.;\u$&;for@_[0,2];print"@_,"



airo
stranger

Oct 13, 2001, 6:18 AM

Post #3 of 5 (747 views)
Re: printing a Tk canvas [In reply to] Can't Post

Marcus,
I downloaded ghostscript and was able to print the postscript file no problem.. can I include gscript within my perl program when I complie or will it need to be a separately installed program.
I guess I just need to go back to the ghostscript site and check there.
thanks for the help
paul



mhx
Enthusiast / Moderator

Oct 13, 2001, 8:03 AM

Post #4 of 5 (745 views)
Re: printing a Tk canvas [In reply to] Can't Post

I fear you have to install ghostscript. To the best of my knowledge, there's no module that incorporates the functionality of ghostscript as a printer driver. There is, however, a module called Tk::Ghostscript, but it is for displaying postscript files with Tk.

-- Marcus


Code
s$$ab21b8d15c3d97bd6317286d$;$"=547269736;split'i',join$,,map{chr(($*+= 
($">>=1)&1?-hex:hex)+0140)}/./g;$"=chr$";s;.;\u$&;for@_[0,2];print"@_,"



airo
stranger

Oct 13, 2001, 9:42 AM

Post #5 of 5 (743 views)
Re: printing a Tk canvas [In reply to] Can't Post

Thanks,

I'm gonna look around.
I'll reply if I find something

paul


 
 


Search for (options) Powered by Gossamer Forum v.1.2.0

Web Applications & Managed Hosting Powered by Gossamer Threads
Visit our Mailing List Archives