C:\cygwin64\home\Fred\pages2\list>perl list11.pl Wed, May 25, 2016 28. Don't be afraid to give up the good to go for the great. Don't be afraid to give up the good to go for the great. tasks for second page are fold sail new_name is May_25_2016.pdf #### #!/usr/bin/perl use v5.14; use utf8; use PDF::API2; use Time::Piece; use Time::Seconds; my $t = Time::Piece->localtime + ONE_DAY; my $today = $t->strftime("%a, %b %d, %Y"); print "$today\n"; my $header = "List for $today"; my $pdf = PDF::API2->new( width => 595, # A4 dimensions in point height => 842, # 1 point = 1/72 inch ); my $page = $pdf->page; my $txt = $page->text; my $font = $pdf->corefont('Times-Roman'); #header my $linepos = 650; $txt->font( $font, 32 ); $txt->translate( 100, $linepos ); $txt->text( $header ); $linepos -= 50; #add randomtext my $quote = get_quote(); print "$quote\n"; $txt->font( $font, 20 ); $txt->lead(20); # line spacing $txt->translate( 100, $linepos ); $txt->paragraph($quote, 400, 100, -align => "left" ); my $overflow_text = $txt->textpos(); $linepos -= 100; my @task = ( 'wake no later than 8', 'stretch/take meds', 'make coffee/eat cereal', 'eat salad', 'bring food', 'make coconut phone', 'check provisions', 'tie knots', 'fold sail',, ); $txt->font( $font, 20 ); my $vspace = 70; while ( (@task)&&($linepos>0) ) { my $item = shift @task; my $msg = '[ ] ' . $item; drawline( $page, $linepos ); $txt->translate( 70, $linepos+10 ); $txt->text($msg); $linepos -= $vspace } say "tasks for second page are @task"; my $new_name = $t->strftime("%b_%d_%Y.pdf"); say "new_name is $new_name"; $pdf->saveas($new_name); sub drawline { my ( $page, $y ) = @_; my $x1 = 50; my $x2 = 550; my $line = $page->gfx; $line->linewidth(3); $line->move( $x1, $y ); $line->line( $x2, $y ); $line->stroke; } sub get_quote { use HTML::TreeBuilder 5 -weak; my $site = 'http://motivationgrid.com/50-inspirational-quotes-to-live-by/'; my $tree = HTML::TreeBuilder->new_from_url($site); my @quotes; for ( $tree->look_down( _tag => 'p' ) ) { if ( ( my $t = $_->as_text ) =~ m{ ^ \d+ \. \s+ }x ) { $t =~ s{ \x{2019} }{'}gx; $t =~ s{ \xA0 }{ }gx; $t =~ s{ \x{2013} }{--}gx; push @quotes, $t; } } my $randomelement = $quotes[ rand @quotes ]; print "$randomelement\n"; $randomelement =~ s/^\d+\.\s+//; return $randomelement; }