in reply to download an array of text as pdf

Try setting the line spacing (leading) and adding newlines. You can also set the line spacing within the cr method. For example

#!perl use strict; use warnings; use PDF::API2; my $save_pdf_as = "mypdf.pdf"; my $pdf = PDF::API2->new(); my $page = $pdf->page() ->mediabox('Letter'); my $font = $pdf->corefont('Helvetica-Bold'); my $text = $page->text(); $text->lead(25); $text->font($font, 20); $text->translate(100, 700); while (<DATA>){ $text->text($_); $text->cr(); #$text->cr(-25); # move down } $pdf->saveas($save_pdf_as); __DATA__ line 1 line 2 line 3 line 4
poj

Replies are listed 'Best First'.
Re^2: download an array of text as pdf
by ajaykannan (Novice) on Dec 02, 2016 at 18:50 UTC

    thank you for the help and can you tell me how to increase the width to print the data. Because for now its printing full content but only half are visible.

      Reduce the font size, rotate the page to landscape or try this.

      #!perl use strict; use warnings; use PDF::API2; my $save_pdf_as = "mypdf.pdf"; my $pdf = PDF::API2->new(); my $page = $pdf->page() ->mediabox('Letter'); my $font = $pdf->corefont('Helvetica-Bold'); my $text = $page->text() ->font($font, 20); $text->lead(25); $text->translate(100, 700); while (<DATA>){ $text->paragraph($_, 400, 400, -align => "left" ); # width height $text->cr(-5); } $pdf->saveas($save_pdf_as); __DATA__ line 1 is a very long line that extends past the end of the page line 2 is also very long line that extends past the end of the page line 3 line 4

      The height of the paragraph box needs to be large enough for the text

      If you need to spread the text across multiple pages then it can get complicated !

      poj

        thank you poj once again for helping me. The goal is to spread the text across multiple pages. And please help me out from this.please