Hi,

I tried to post this on beginners@perl.org, but it didn't make it (sometimes my mails to them get lost). Hopefully it will get here.

I am trying to print a canvas using the postscript method, but it's a really big canvas (not too wide, just high / long), and always comes out scaled to a single page. Any easy way to get the postscript method to make it a multi-page document, or should I just start hacking the resulting eps? I've tried playing with all the options to the postscript method, but haven't gotten anything to help.

Example code:

#!/usr/bin/perl -w # written/testing on MSwin ###################################### use Tk; use strict; my $temp = "C:\\temp"; my $file="$temp\\psfile.ps"; chomp(my @files = `dir/b $temp\\psfile.* 2>&1`); for (@files) { # get rid of all psfile.* next if /file not found/i; if (-e "$temp\\$_") { unlink "$temp\\$_"; } } my $cw=595; # 595.44 printer points A4 my $ch=841; # 841.68 printer points A4 my $mw= tkinit; my $c = $mw->Scrolled('Canvas', -scrollregion => [0,0,'596 p','842 p'], )->pack(-expand => 1, -fill => 'both', ); # create "page size" box and text in each corner $c->createRectangle(0,0,$cw.'p',$ch.'p',-outline=>'blue'); $c->createText(0,0, -text => 'nw', -anchor => 'nw'); $c->createText($cw.'p',0, -text => 'ne', -anchor => 'ne'); $c->createText($cw.'p',$ch.'p',-text => 'se', -anchor => 'se'); $c->createText( 0,$ch.'p',-text => 'sw', -anchor => 'sw'); # create numbers down the middle (3 "pages" worth) for (my $i = 0; $i <= (3*$ch); $i += 72) { $c->createText(($cw/2).'p',$i.'p',-text => $i); } my $b = $mw->Button(-text=>'output',-command=>\&ps)->pack; MainLoop; sub ps { $c->postscript( -colormode=> 'color', -file=> $file, -width=> $cw.'p', -height=> (3*$ch).'p', # height of canvas to print -x=> 0, -y=> 0, -pagex=> 0, -pagey=> 0, -pageanchor=> 'nw', -pagewidth=> $cw.'p', -pageheight=> (3*$ch).'p', # all 3 pages on single page # -pageheight=> $ch.'p', # all 3 pages on single page ); }

I also haven't had much luck getting things to change using -pagex, -pagey or -pageanchor. Exhaustive searching on the web for using the postscript method has mostly resulted in the same info as in Learning (or Mastering) Perl/Tk. Options explained but not many examples of use.

Any help / advice appreciated, but using a different widget set is not an option.

Thanks, Cort


In reply to multi-page from Tk::Canvas by cort

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.