You can call outlines() from a PDF::API2 instance to get a PDF::API2::Outlines object. That's what the line in the PDF::API2::Outlines constructor section is telling you.

$otl = PDF::API2::Outline->new $api,$parent,$prev Returns a new outline object (called from $otls->outline).

I got the following to work. Started with an example (ex 12-5) I found in the O'Reilly book 'Perl Graphics Programming' by Shawn Wallace. But it's mostly from the documentation for PDF::API2.

use warnings; use strict; use PDF::API2; # Create a blank PLF file my $pdf = PDF::API2->new(-file => 'test7.pdf'); #------- Don't call new from PDF::API2::Outline directly... my $otls = $pdf->outlines(); # Add a built-in font to the PDF my $font = $pdf->corefont('Helvetica-Bold'); foreach my $section ( 1..3 ){ my $otl = $otls->outline; $otl->title("Section $section"); foreach my $pagenumber (1..4) { #add blank page... my $page = $pdf->page(); # Set the page size $page->mediabox('Letter'); my $text = $page->text(); $text->translate(225,600); $text->font($font, 20); $text->text("Hello world, s$section, p$pagenumber"); # add suboutline. my $sotl = $otl->outline(); $sotl->title("Page $pagenumber"); $sotl->dest($page); } } $pdf->save();

In reply to Re: PDF::API2::Outline functions by Lotus1
in thread PDF::API2::Outline functions by Copacetic

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.