I am using the module to enable print functionality on a script I have been working on. As of now I have had to half arse some formatting to get this app to print more than one page with correct text location, etc...

sub print { my $dc = new Win32::Printer( papersize => 1, dialog => 0x000004, description => $filename, unit => 'mm' ); my $font = $dc->Font($font, $size); $dc->Font($font); chomp(my $page = $t->get("1.0", "end")); my @page = split(/\n/, $page); my $lncnt = 0; $lncnt++ for (@page); my $total = (($lncnt/83) + 1); if ($total =~ /\./) { my $trash; ($total, $trash) = split(/\./, $total); } my $y = 15; my @flnm = split(/\//, $filename); my $file = pop(@flnm); my $current = 1; $dc->Write("-- $file --", 20, 5); foreach (@page) { $dc->Write($_, 10, $y); $y+=3; if ($y > 264) { $dc->Write("$current of $total pages", 180, 267); $current++; $dc->Page(); $dc->Write("-- $file --", 10, 5); $y = 15; } if ($current == $total) { $dc->Write("$current of $total pages", 180, 267); } } $dc->Close(); $info = "Print job complete!"; }

This is what I have come up wioth so far and it somewhat works but is too static for my taste. It will only look decent if the user uses portrait and not landscape and the specific style and size font defined. Also as of now text that extends past the edge of the paper is cutoff and does not wrap.

Is there any better built in functionality to this module to allow for easier and more dynamic formatting of the print page layout? I have searched the documentation and have found nothing that will seem to help me with this, although I am sure there is and maybe I am simply overlooking it.


www.perlskripts.com

In reply to Win32::Printer formatting? by Elijah

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.