in reply to Text to PDF conversion
Here is a snippet that covers two of your issues (1 and 3):
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
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Re: Text to PDF conversion
by aseidas (Beadle) on Mar 15, 2002 at 21:36 UTC |