This article shows how to automate the creation of PDF reports using perl. The module PDF::API2 provides raw access to creating pdf files.
The PDF::API2 module gives you the ability to automate the creation of beautiful PDF reports without the need to purchase expensive software. Using the PDF::Table module, one can generate complex tables in your report. One can abstract out many of the common features of a report and create an entire framework for generating reports. Here is some sample code that creates a landscape page with a title and a line.

use strict;

use PDF::API2

# create a pdf object giving it the name of the file to save the pdf to

my $pdf = PDF::API2->new(-file => “report1.pdf”);

my $font = $pdf->corefont(’Helvetica-Bold’);

my $page = $pdf->page;

$page->mediabox(792,612);

# create a text label

my $txt = $page->text;

$txt->textlabel(72,540,$font,20,”Title of report1″);

# create a line

my $gfx = $page->gfx;

$gfx->strokecolor(’#000000′);

$gfx->move(72,360);

$gfx->linewidth(1);

$gfx->line(720,360);

$gfx->stroke;

$pdf->save;