#!/usr/bin/perl -w # Example 12-2. Hello World with graphics use strict; use PDF::API2; my $pdf=PDF::API2->new; my $page=$pdf->page(); $page->mediabox(400, 200); my $g = $page->gfx(); # Add a Gfx object $g->strokecolor("#FF0000"); # Set the stroke color $g->fillcolor("#FF0000"); # Set the fill color for my $i (0..10) { for my $j (0..5) { # Draw a circle with random radius $g->circle($i*40, $j*40, rand(25)+1); } } $g->fillstroke(); # Fill and stroke my $text=$page->text(); $text->translate(65, 75); $text->font($pdf->corefont('Helvetica-Bold',1),48); $text->text('Hello World'); print $pdf->stringify(); $pdf->end; exit;