use strict; use warnings; use PDF::API2; use PDF::Create; use DB; use DBI; use Time::Format;# qw(%time %strftime %manip); use PDF::API2::Annotation; use PDF::Table; use constant mm => 25.4 / 72; use constant in => 1 / 72; use constant pt => 1; # Connect to Oracle Database and return data using a query and store it in a variable my $user = "scott"; my $password = "tiger"; my $db=DBI->connect("dbi:Oracle:HOSTNAME:1521/ORCL", "$user", "$password") || die($DBI::errstr . "\n"); $db->{AutoCommit} = 0; $db->{RaiseError} = 1; $db->{ora_check_sql} = 0; $db->{RowCacheSize} = 16; my $SEL = "select acc_num, acc_name, item_amt, amt_delayed1, available_date1,date_deposited, amt_delayed2, available_date2, dt_today, case when substr(acc_num,1,2)='IM' then 'X' else NULL end as chk_X, case when substr(acc_num,1,2)='ST' then 'X' else NULL end as sav_X, hold_reason from ( select 'AI12345678, AI654321' as acc_num, 'First Middle Last' as acc_name, '7000.00' as item_amt, '40.00' as amt_delayed1, to_char(trunc(sysdate)+1,'mm/dd/yyyy') as available_date1, to_char(trunc(sysdate)-2,'mm/dd/yyyy') as date_deposited, '3000.00' as amt_delayed2, to_char(trunc(sysdate)+2,'mm/dd/yyyy') as available_date2, to_char(trunc(sysdate),'mm/dd/yyyy') as dt_today, 'Large Deposit,The Check(s) you deposited on this day exceed \$5000' as hold_reason from dual union select 'AS555666777, AS65432155' as acc_num, 'First Middle Last1,First Middle Last2' as acc_name, '2400.00' as item_amt, '1000.00' as amt_delayed1, to_char(trunc(sysdate)+1,'mm/dd/yyyy') as available_date1, to_char(trunc(sysdate)-2,'mm/dd/yyyy') as date_deposited, '1400.00' as amt_delayed2, to_char(trunc(sysdate)+2,'mm/dd/yyyy') as available_date2, to_char(trunc(sysdate),'mm/dd/yyyy') as dt_today, 'Large Deposit2,The Check(s) you deposited on this day exceed \$10000' as hold_reason from dual)"; my $sth = $db->prepare($SEL); $_ = "\t" if !defined($_); my $fileTime = $time{'yyyymmdd.hhmmss.mmm'}; my $picture = 'C:\\Users\\Public\\Pictures\\BOTW 3x1 lockup rbg.jpg'; my ( $paragraph1, $paragraph2,$paragraph3,$paragraph4) = get_data(); my ( $endw, $ypos, $paragraph ) = undef; my $ctr = 0; $sth->execute(); while (my @v_data = $sth->fetchrow_array()) { my ($acc_num, $acc_name, $item_amt, $amt_delayed1, $avl_date1, $dt_deposited, $amt_delayed2, $avl_date2,$dt_today,$chk_X,$sav_X,$hold_reas) = @v_data; my $len_item_amt = length $item_amt; my $len_amt_delayed1 = length $amt_delayed1;#$amt_delayed1; print "Length of Amount Delayed1: ".$len_amt_delayed1; print $hold_reas; my $pdf = PDF::API2->new( -file => "$0.$ctr.pdf" ); print "$0.$ctr.pdf\n"; my %font = ( Helvetica => { Bold => $pdf->corefont( 'Helvetica-Bold', -encoding => 'latin1' ), Roman => $pdf->corefont( 'Helvetica', -encoding => 'latin1' ), Italic => $pdf->corefont( 'Helvetica-Oblique', -encoding => 'latin1' ), }, Times => { Bold => $pdf->corefont( 'Times-Bold', -encoding => 'latin1' ), Roman => $pdf->corefont( 'Times', -encoding => 'latin1' ), Italic => $pdf->corefont( 'Times-Italic', -encoding => 'latin1' ), }, Arial => { Bold => $pdf->corefont( 'Arial-Bold', -encoding => 'latin1' ), Roman => $pdf->corefont( 'Arial', -encoding => 'latin1' ), Italic => $pdf->corefont( 'Arial-Italic', -encoding => 'latin1' ), }, ); my $page = $pdf->page; $page->mediabox( 215.9 / mm, 279.4 / mm); ##Correct dimensions of page for a PDF for A4 paper printing## ###########Block to print image on the page########### my $photo = $page->gfx; die("Unable to find image file: $!") unless -e $picture; my $photo_file = $pdf->image_jpeg($picture); #$photo->image( $photo_file, 20, 710.0 , 280, 50); $photo->image( $photo_file, 20, 610.0, 3/mm, 7/mm); my $right_column_text = $page->text; $right_column_text->font( $font{'Arial'}{'Roman'}, 16 / pt ); $right_column_text->fillcolor('black'); my ( $endw, $ypos, $paragraph ) = text_block( $right_column_text, 'NOTICE OF HOLD', -x => 425 , -y => 725,#555, -w => 160 , -h => 110 , -lead => 10 / pt, -parspace => 0 / pt, -align => 'right', ); my $left_column_text = $page->text; $left_column_text->font( $font{'Arial'}{'Roman'}, 10 / pt ); $left_column_text->fillcolor('black'); ( $endw, $ypos, $paragraph ) = text_block ( $left_column_text, $paragraph1, -x => 30 , -y => 335, -w => 550,#441.5, -h => 110, -lead => 11 / pt, -parspace => 0 / pt, -align => 'justify', ); my ($hold_reas1,$hold_reas2,$hold_reas3,$hold_reas4,$hold_reas5) = split(',',$hold_reas); $left_column_text = $page->text; $left_column_text->font( $font{'Arial'}{'Roman'}, 10 / pt ); $left_column_text->fillcolor('black'); ( $endw, $ypos, $paragraph ) = text_block ( $left_column_text, $hold_reas1."\n".$hold_reas2."\n", -x => 30 , -y => 290, -w => 550,#441.5, -h => 110, -lead => 12 / pt, -parspace => 0 / pt, -align => 'justify', ); # $left_column_text = $page->text; # $left_column_text->font( $font{'Arial'}{'Roman'}, 10 / pt ); # $left_column_text->fillcolor('black'); # ( $endw, $ypos, $paragraph ) = text_block # ( # $left_column_text, # $hold_reas2, # -x => 30 , # -y => 280, # -w => 550,#441.5, # -h => 110, # -lead => 11 / pt, # -parspace => 0 / pt, # -align => 'justify', # ); ###########Text showing NOTICE block on the letter########### $left_column_text = $page->text; $left_column_text->font( $font{'Arial'}{'Roman'}, 10 / pt ); $left_column_text->fillcolor('black'); ( $endw, $ypos, $paragraph ) = text_block ( $left_column_text, $paragraph2, -x => 30 , -y => 206,#306,(This is last perfect position) -w => 550,#441.5, -h => 110, -lead => 11 / pt, -parspace => 0 / pt, -align => 'justify', ); ###########Text showing Phone, URL and FDIC block on the letter########### $left_column_text = $page->text; $left_column_text->font( $font{'Arial'}{'Roman'}, 10 / pt ); $left_column_text->fillcolor('black'); ( $endw, $ypos, $paragraph ) = text_block ( $left_column_text, $paragraph3, -x => 30 , -y => 106, -w => 460,#441.5, -h => 110, -lead => 10 / pt, -parspace => 0 / pt, -align => 'justify', ); $left_column_text = $page->text; $left_column_text->font( $font{'Arial'}{'Roman'}, 8 / pt ); $left_column_text->fillcolor('black'); ( $endw, $ypos, $paragraph ) = text_block ( $left_column_text, $paragraph4, -x => 460,#380 , -y => 40,#106, -w => 460,#441.5, -h => 110, -lead => 10 / pt, -parspace => 0 / pt, -align => 'justify', ); ###########Account and Hold Details labels and data on the letter - LEFT########### $left_column_text = $page->text; $left_column_text->font( $font{'Arial'}{'Roman'}, 10 / pt ); $left_column_text->fillcolor('black'); ( $endw, $ypos, $paragraph ) = text_block ( $left_column_text, 'Account Number:', -x => 30 , -y => 505,#306,(This is last perfect position) -w => 460,#441.5, -h => 110, -lead => 10 / pt, -parspace => 0 / pt, -align => 'justify', ); $left_column_text = $page->text; $left_column_text->font( $font{'Arial'}{'Roman'}, 10 / pt ); $left_column_text->fillcolor('black'); ( $endw, $ypos, $paragraph ) = text_block ( $left_column_text, 'Name:', -x => 30 , -y => 485,#306,(This is last perfect position) -w => 460,#441.5, -h => 110, -lead => 10 / pt, -parspace => 0 / pt, -align => 'justify', ); $left_column_text = $page->text; $left_column_text->font( $font{'Arial'}{'Roman'}, 10 / pt ); $left_column_text->fillcolor('black'); ( $endw, $ypos, $paragraph ) = text_block ( $left_column_text, 'Amount of Item(s):', -x => 30 , -y => 425,#306,(This is last perfect position) -w => 460,#441.5, -h => 110, -lead => 10 / pt, -parspace => 0 / pt, -align => 'justify', ); $left_column_text = $page->text; $left_column_text->font( $font{'Arial'}{'Roman'}, 10 / pt ); $left_column_text->fillcolor('black'); ( $endw, $ypos, $paragraph ) = text_block ( $left_column_text, 'Amount Delayed:', -x => 30 , -y => 405,#306,(This is last perfect position) -w => 460,#441.5, -h => 110, -lead => 10 / pt, -parspace => 0 / pt, -align => 'justify', ); $left_column_text = $page->text; $left_column_text->font( $font{'Arial'}{'Roman'}, 10 / pt ); $left_column_text->fillcolor('black'); ( $endw, $ypos, $paragraph ) = text_block ( $left_column_text, 'Available Date:', -x => 30 , -y => 385,#306,(This is last perfect position) -w => 460,#441.5, -h => 110, -lead => 10 / pt, -parspace => 0 / pt, -align => 'justify', ); $left_column_text = $page->text; $left_column_text->font( $font{'Arial'}{'Roman'}, 10 / pt ); $left_column_text->fillcolor('black'); ( $endw, $ypos, $paragraph ) = text_block ( $left_column_text, '(Date funds are available for withdrawal)', -x => 30 , -y => 375,#306,(This is last perfect position) -w => 460,#441.5, -h => 110, -lead => 10 / pt, -parspace => 0 / pt, -align => 'justify', ); ###########Account and Hold Details labels on the letter - RIGHT########### $right_column_text = $page->text; $right_column_text->font( $font{'Arial'}{'Roman'}, 10 / pt ); $right_column_text->fillcolor('black'); ( $endw, $ypos, $paragraph ) = text_block ( $right_column_text, 'Checking:', -x => 380 , -y => 505,#306,(This is last perfect position) -w => 460,#441.5, -h => 110, -lead => 10 / pt, -parspace => 0 / pt, -align => 'justify', ); $right_column_text = $page->text; $right_column_text->font( $font{'Arial'}{'Roman'}, 10 / pt ); $right_column_text->fillcolor('black'); ( $endw, $ypos, $paragraph ) = text_block ( $right_column_text, 'Today'.''.'s Date:', -x => 380 , -y => 485,#306,(This is last perfect position) -w => 460,#441.5, -h => 110, -lead => 10 / pt, -parspace => 0 / pt, -align => 'justify', ); $right_column_text = $page->text; $right_column_text->font( $font{'Arial'}{'Roman'}, 10 / pt ); $right_column_text->fillcolor('black'); ( $endw, $ypos, $paragraph ) = text_block ( $right_column_text, 'Date Deposited:', -x => 380 , -y => 425,#306,(This is last perfect position) -w => 460,#441.5, -h => 110, -lead => 10 / pt, -parspace => 0 / pt, -align => 'justify', ); $right_column_text = $page->text; $right_column_text->font( $font{'Arial'}{'Roman'}, 10 / pt ); $right_column_text->fillcolor('black'); ( $endw, $ypos, $paragraph ) = text_block ( $right_column_text, 'Amount Delayed:', -x => 380 , -y => 405,#306,(This is last perfect position) -w => 460,#441.5, -h => 110, -lead => 10 / pt, -parspace => 0 / pt, -align => 'justify', ); $right_column_text = $page->text; $right_column_text->font( $font{'Arial'}{'Roman'}, 10 / pt ); $right_column_text->fillcolor('black'); ( $endw, $ypos, $paragraph ) = text_block ( $right_column_text, 'Available Date:', -x => 380 , -y => 385,#306,(This is last perfect position) -w => 460,#441.5, -h => 110, -lead => 10 / pt, -parspace => 0 / pt, -align => 'justify', ); $right_column_text = $page->text; $right_column_text->font( $font{'Arial'}{'Roman'}, 10 / pt ); $right_column_text->fillcolor('black'); ( $endw, $ypos, $paragraph ) = text_block ( $right_column_text, '(Date funds are available for withdrawal)', -x => 380 , -y => 375,#306,(This is last perfect position) -w => 460,#441.5, -h => 110, -lead => 10 / pt, -parspace => 0 / pt, -align => 'justify', ); ###########Account and Hold Details Data on the letter - LEFT########### $left_column_text = $page->text; $left_column_text->font( $font{'Arial'}{'Roman'}, 10 / pt ); $left_column_text->fillcolor('black'); ( $endw, $ypos, $paragraph ) = text_block ( $left_column_text, $acc_num, #'Account Number data:', -x => 140 , -y => 505,#306,(This is last perfect position) -w => 460,#441.5, -h => 110, -lead => 10 / pt, -parspace => 0 / pt, -align => 'justify', ); my ($v_name1,$v_name2) = split(',',$acc_name); $left_column_text = $page->text; $left_column_text->font( $font{'Arial'}{'Roman'}, 10 / pt ); $left_column_text->fillcolor('black'); ( $endw, $ypos, $paragraph ) = text_block ( $left_column_text, $v_name1."\n".$v_name2,#Name data:', -x => 140 , -y => 485,#306,(This is last perfect position) -w => 460,#441.5, -h => 110, -lead => 12 / pt, -parspace => 0 / pt, -align => 'justify', ); $left_column_text = $page->text; $left_column_text->font( $font{'Arial'}{'Roman'}, 10 / pt ); $left_column_text->fillcolor('black'); ( $endw, $ypos, $paragraph ) = text_block ( $left_column_text, $item_amt,#'Amount of Item(s) data:', -x => 140 , -y => 425,#306,(This is last perfect position) -w => 460,#441.5, -h => 110, -lead => 10 / pt, -parspace => 0 / pt, -align => 'justify', ); my $v_pos1 = 140 + $len_item_amt; print $v_pos1."\n\n"; print "len item amt : ".$len_item_amt."\n\n"; print "len amt delayed1: ".$len_amt_delayed1."\n\n"; print "x position: $v_pos1-$len_amt_delayed1"; $left_column_text = $page->text; $left_column_text->font( $font{'Arial'}{'Roman'}, 10 / pt ); $left_column_text->fillcolor('black'); ( $endw, $ypos, $paragraph ) = text_block ( $left_column_text, $amt_delayed1,#'Amount Delayed data:', -x => $v_pos1 - $len_amt_delayed1,#140 , -y => 405,#306,(This is last perfect position) -w => 460,#441.5, -h => 110, -lead => 10 / pt, -parspace => 0 / pt, -align => 'justify', ); $left_column_text = $page->text; $left_column_text->font( $font{'Arial'}{'Roman'}, 10 / pt ); $left_column_text->fillcolor('black'); ( $endw, $ypos, $paragraph ) = text_block ( $left_column_text, $avl_date2,#'Available Date data:', -x => 140 , -y => 385,#306,(This is last perfect position) -w => 460,#441.5, -h => 110, -lead => 10 / pt, -parspace => 0 / pt, -align => 'justify', ); ###########Account and Hold Details Data on the letter - RIGHT########### $right_column_text = $page->text; $right_column_text->font( $font{'Arial'}{'Roman'}, 10 / pt ); $right_column_text->fillcolor('black'); ( $endw, $ypos, $paragraph ) = text_block ( $right_column_text, 'Savings:', -x => 490 , -y => 505,#306,(This is last perfect position) -w => 460,#441.5, -h => 110, -lead => 10 / pt, -parspace => 0 / pt, -align => 'justify', ); $right_column_text = $page->text; $right_column_text->font( $font{'Arial'}{'Roman'}, 10 / pt ); $right_column_text->fillcolor('black'); ( $endw, $ypos, $paragraph ) = text_block ( $right_column_text, $chk_X,#'Checking X:', -x => 550 , -y => 505,#306,(This is last perfect position) -w => 460,#441.5, -h => 110, -lead => 10 / pt, -parspace => 0 / pt, -align => 'justify', ); $right_column_text = $page->text; $right_column_text->font( $font{'Arial'}{'Roman'}, 10 / pt ); $right_column_text->fillcolor('black'); ( $endw, $ypos, $paragraph ) = text_block ( $right_column_text, $sav_X,#'Savings X:', -x => 550 , -y => 505,#306,(This is last perfect position) -w => 460,#441.5, -h => 110, -lead => 10 / pt, -parspace => 0 / pt, -align => 'justify', ); $right_column_text = $page->text; $right_column_text->font( $font{'Arial'}{'Roman'}, 10 / pt ); $right_column_text->fillcolor('black'); ( $endw, $ypos, $paragraph ) = text_block ( $right_column_text, $dt_today,#'Today'.''.'s Date Data:', -x => 490 , -y => 485,#306,(This is last perfect position) -w => 460,#441.5, -h => 110, -lead => 10 / pt, -parspace => 0 / pt, -align => 'justify', ); $right_column_text = $page->text; $right_column_text->font( $font{'Arial'}{'Roman'}, 10 / pt ); $right_column_text->fillcolor('black'); ( $endw, $ypos, $paragraph ) = text_block ( $right_column_text, $dt_deposited,#'Date Deposited Data:', -x => 490 , -y => 425,#306,(This is last perfect position) -w => 460,#441.5, -h => 110, -lead => 10 / pt, -parspace => 0 / pt, -align => 'justify', ); $right_column_text = $page->text; $right_column_text->font( $font{'Arial'}{'Roman'}, 10 / pt ); $right_column_text->fillcolor('black'); ( $endw, $ypos, $paragraph ) = text_block ( $right_column_text, $amt_delayed2,#'Amount Delayed Data:', -x => 490 , -y => 405,#306,(This is last perfect position) -w => 460,#441.5, -h => 110, -lead => 10 / pt, -parspace => 0 / pt, -align => 'justify', ); $right_column_text = $page->text; $right_column_text->font( $font{'Arial'}{'Roman'}, 10 / pt ); $right_column_text->fillcolor('black'); ( $endw, $ypos, $paragraph ) = text_block ( $right_column_text, $avl_date1,#'Available Date Data:', -x => 490 , -y => 385,#306,(This is last perfect position) -w => 460,#441.5, -h => 110, -lead => 10 / pt, -parspace => 0 / pt, -align => 'justify', ); ###########Draw Lines Botom########### my $black_line_bottom = $page->gfx; $black_line_bottom->strokecolor('black'); $black_line_bottom->move( 579, 360 );#( 528, 410 ); $black_line_bottom->line( 30, 360 ); $black_line_bottom->stroke; ###########Draw Lines Top########### my $black_line_top = $page->gfx; $black_line_top->strokecolor('black'); $black_line_top->move( 579, 525 );#( 528, 410 ); $black_line_top->line( 30, 525 ); $black_line_top->stroke; ####################Customer Name And Address Positioning################### $left_column_text->font( $font{'Arial'}{'Roman'}, 10 / pt ); $left_column_text->fillcolor('black'); ( $endw, $ypos, $paragraph ) = text_block( $left_column_text, 'GEORGE WASHINGTON', # 'Customer Name', -x => 90 , -y => 605,#625,#555, -w => 1000 , -h => 1100 , -lead => 7 / pt, -parspace => 0 / pt, -align => 'left' # -hang => "\xB20 " ); $left_column_text->font( $font{'Arial'}{'Roman'}, 10 / pt ); $left_column_text->fillcolor('black'); ( $endw, $ypos, $paragraph ) = text_block( $left_column_text, 'THE WHITE HOUSE', # 'Address', -x => 90 , -y => 590,#610,#555, -w => 1000 , -h => 1110 , -lead => 7 / pt, -parspace => 0 / pt, -align => 'left' # -hang => "\xB20 " ); $left_column_text->font( $font{'Arial'}{'Roman'}, 10 / pt ); $left_column_text->fillcolor('black'); ( $endw, $ypos, $paragraph ) = text_block( $left_column_text, '1600 PENNSYLVANIA AVENUE NW', # 'City', -x => 90 , -y => 575,#595,#555, -w => 1000 , -h => 1110 , -lead => 7 / pt, -parspace => 0 / pt, -align => 'left' # -hang => "\xB20 " ); $left_column_text->font( $font{'Arial'}{'Roman'}, 10 / pt ); $left_column_text->fillcolor('black'); ( $endw, $ypos, $paragraph ) = text_block( $left_column_text, 'WASHINGTON, DC 20500', # 'State and Zip', -x => 90 , -y => 560,#580,#555, -w => 1000 , -h => 1110 , -lead => 7 / pt, -parspace => 0 / pt, -align => 'left' # -hang => "\xB20 " ); $ctr++; $pdf->save; $pdf->end(); } END { $db->disconnect if defined($db); } sub get_data{ qq|The item(s) described above, included in your deposit, is drawn on another financial institution. We are delaying the availability of this item(s) because the funds from the check have not been collected. If this time period is greater than 2 days it is becuause:|, qq|Notice: If you did not receive this notice at the time you made the deposit or cashed a check, and the check you deposited/cashed is paid, we will return to you any fee for the overdraft or returned checks that result solely from the additional delay that we are imposing. To obtain a refund of such fee, |, qq|400-400-4000 www.google.com XXXXX|, qq|(Disclosure revision: 02/2015)| } sub text_block { #my ( $endw, $ypos, $paragraph ) = undef; #my $text_object = shift; #my $text = shift; my $text_object = shift; my $text = shift; my %arg = @_; # Get the text in paragraphs my @paragraphs = split( /\n/, $text ); # calculate width of all words my $space_width = $text_object->advancewidth(' '); my @words = split( /\s+/, $text ); my %width = (); foreach (@words) { next if exists $width{$_}; $width{$_} = $text_object->advancewidth($_); } $ypos = $arg{'-y'}; my @paragraph = split( / /, shift(@paragraphs) ); my $first_line = 1; my $first_paragraph = 1; # while we can add another line while ( $ypos >= $arg{'-y'} - $arg{'-h'} + $arg{'-lead'} ) { unless (@paragraph) { last unless scalar @paragraphs; @paragraph = split( / /, shift(@paragraphs) ); $ypos -= $arg{'-parspace'} if $arg{'-parspace'}; last unless $ypos >= $arg{'-y'} - $arg{'-h'}; $first_line = 1; $first_paragraph = 0; } my $xpos = $arg{'-x'}; # while there's room on the line, add another word my @line = (); my $line_width = 0; if ( $first_line && exists $arg{'-hang'} ) { my $hang_width = $text_object->advancewidth( $arg{'-hang'} ); $text_object->translate( $xpos, $ypos ); $text_object->text( $arg{'-hang'} ); $xpos += $hang_width; $line_width += $hang_width; $arg{'-indent'} += $hang_width if $first_paragraph; } elsif ( $first_line && exists $arg{'-flindent'} ) { $xpos += $arg{'-flindent'}; $line_width += $arg{'-flindent'}; } elsif ( $first_paragraph && exists $arg{'-fpindent'} ) { $xpos += $arg{'-fpindent'}; $line_width += $arg{'-fpindent'}; } elsif ( exists $arg{'-indent'} ) { $xpos += $arg{'-indent'}; $line_width += $arg{'-indent'}; } while ( @paragraph and $line_width + ( scalar(@line) * $space_width ) + $width{ $paragraph[0] } < $arg{'-w'} ) { $line_width += $width{ $paragraph[0] }; push( @line, shift(@paragraph) ); } # calculate the space width my ( $wordspace, $align ); if ( $arg{'-align'} eq 'fulljustify' or ( $arg{'-align'} eq 'justify' and @paragraph ) ) { if ( scalar(@line) == 1 ) { @line = split( //, $line[0] ); } $wordspace = ( $arg{'-w'} - $line_width ) / ( scalar(@line) - 1 ); $align = 'justify'; } else { $align = ( $arg{'-align'} eq 'justify' ) ? 'left' : $arg{'-align'}; $wordspace = $space_width; } $line_width += $wordspace * ( scalar(@line) - 1 ); if ( $align eq 'justify' ) { foreach my $word (@line) { $text_object->translate( $xpos, $ypos ); $text_object->text($word); $xpos += ( $width{$word} + $wordspace ) if (@line); } $endw = $arg{'-w'}; } else { # calculate the left hand position of the line if ( $align eq 'right' ) { $xpos += $arg{'-w'} - $line_width; } elsif ( $align eq 'center' ) { $xpos += ( $arg{'-w'} / 2 ) - ( $line_width / 2 ); } # render the line $text_object->translate( $xpos, $ypos ); $endw = $text_object->text( join( ' ', @line ) ); } $ypos -= $arg{'-lead'}; $first_line = 0; } unshift( @paragraphs, join( ' ', @paragraph ) ) if scalar(@paragraph); return ( $endw, $ypos, join( "\n", @paragraphs ) ) }