#!/usr/bin/perl -w # # Example 12-6. Create a bookmark frame use strict; use PDF::API2; # Used to generate the PDF output # Create a new top-level document my $pdf = PDF::API2->new(); # Initialize the root of the outline tree my $outline_root = $pdf->outlines(); # Use Helvetica throughout my $font = $pdf->corefont('Helvetica'); my ($page, $text); # Create four sections foreach my $s (1..4) { # Add an entry for each section. Each section has # suboutline entries my $section = $outline_root->outline(); $section->title("Section $s"); # Add five pages for each section foreach my $n (1..5) { # Draw some text on the page $page = $pdf->page(); $page->mediabox(612, 792); $text = $page->text(); $text->transform( -translate => [306, 396]); $text->font($font, 36); $text->text_center("Section $s, page $n"); # Add an outline entry for the page, # title it, and link it. my $outline = $section->outline(); $outline->title("Page $n"); $outline->dest($page); } } print $pdf->stringify(); exit;