Hi everyone,
I have some problems about the postscript method that I cannot figure out. Does anyone know about it and could help me fix it ?
Now, I have a canvas with a certain items on it and all I want to do is to use the postscript method to dump it out and send the ps file to the printer.
What I expect to have is a single or multiple pages printed out but What I get was a blank page. Here is the program :
#!perl use warnings; use strict; use Tk; my $mw=MainWindow->new(-title=>"Print out the canvas"); my c=$mw->Scrolled("Canvas")->pack(-expand=>1,-fill=>'both'); my $canvas=$c->Subwidget("canvas"); $canvas->createLine(100,100,20,20,-arrow=>'both',-arrowshape=>[10,10,1 +0]); $canvas->createOval(100,80,65,75,-fill=>"blue"); $canvas->createRectangle(30,50,60,80, -fill=>"red",-width=>5); $canvas->createText(150,1100,-text=>"check postscript",-justify=>"left +"); $canvas->createOval(150,1150,300,1300,-fill=>"blue"); $canvas->createRectangle(150,1300,400,1350, -fill=>"red",-width=>5); $canvas->configure(-scrollregion=>[$canvas->bbox("all")]); $canvas->update(); my $button=$canvas->Button(-text=>"Print",-command=>\&buttonDo) ->pack(-side=>"bottom"); MainLoop; sub buttonDo{ $canvas->update; my @coord=$canvas->bbox('all'); my $maxwidth=$coord[2]; my $maxheight=$coord[3]; $canvas->postscript( '-x'=>'0','-y'=>'0', -colormode=>'color', -file=> "file.ps", -rotate=>0, -width=>$maxwidth, -height=>$maxheight, -pageheight=>'10.5 i', -pagewidth=>'8 i'); system("lpr -S serverN-P printerN file.ps") == 0 or die $!; }
I suppose to get all the items of my canvas and then dump them out with the postscript method because I already used $canvas->bbox().
I tried to use pageheight and pagewidth to scale all my items in one page 8x11 inches but it seems not to work somehow.
I also used width and height options to specify the canvas surface that I want to print but all I get is blank.
Did I do something wrong ?
or is it a problem of the resolution of my printer since it cut all the items out the standard frame before printing?
Thanks so much.

In reply to $canvas->postscript method - unexpected result by cta

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.