Here is a snippet that covers two of your issues (1 and 3):

Update

Fixed an incorrect localisation of $page to make the code run (well I think it will but am to lazy to test it :-) and rememberd to re-init our $y value when we change pages

my $lines_per_page = 50; # print 50 lines per page my $y_init = 600; # initial top line pos my ( @pages, $page, $y ); # declare and scope these vars foreach my $line ( 0 .. $#textstrings ) { # get line from array using index my $text = $textstrings[$line]; # remove all control characters using tr with /d(elete) # option. these are specified in octal notation $text =~ tr/\000-\037//d; # we will have removed the traling newline from each line. # I doubt that it is required but if it is... $text .= "\n"; # use modulus operator % to make a new page whenever # the current line number divided by the lines per # page has a remainder of zero. this will get us a new # $page object when $line == 0, 50, 100 ... # we push each completed page into the @pages array if ( $line % $lines_per_page == 0 ) { push @pages, $page; $page = $root->newpage; $y = $y_init; # reset the $y value to page top } # add the text to the current page $page->string( $f1, 10, 20, $y, $text ); # move y position down 10 pixels $y = $y - 10; } # now summate the pages in @pages (if that's what you need) $page = join'', @pages;

cheers

tachyon

s&&rsenoyhcatreve&&&s&n.+t&"$'$`$\"$\&"&ee&&y&srve&&d&&print


In reply to Re: Text to PDF conversion by tachyon
in thread Text to PDF conversion by aseidas

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.