#!/usr/bin/perl use v5.14; use utf8; use PDF::API2; my $header = 'placeholder header'; my $pdf = PDF::API2->new( width => 595, # A4 dimensions in point height => 842, # 1 point = 1/72 inch ); sub drawline { my ($line, $y) = @_; my $x1 = 50; my $x2 = 550; $line->linewidth(3); $line->move( $x1, $y ); $line->line( $x2, $y ); $line->stroke; } my $page = $pdf->page; my $txt = $page->text; my $font = $pdf->ttfont('DejaVuSans.ttf'); $txt->font($font, 32); $txt->translate(100, 650); $txt->text($header, -encoding => 'utf8'); my @task = ( 'wash the dishes', 'buy some meat', 'run a mile', 'buy more meat', 'plan a barbecue', ); my $line = $page->gfx; $txt->font($font, 20); my $vspace = 70; for my $i (0..$#task) { my $linepos = 500-($i*$vspace); my $msg = '[ ] '.$task[$i]; drawline ($line, $linepos); $txt->translate(70, $linepos+10); $txt->text($msg); } $pdf->saveas("output.pdf");