PDF::FromHTML::Template::Element::Bookmark - PDF::FromHTML::Template::Element::Bookmark documentation


PDF-FromHTML documentation Contained in the PDF-FromHTML distribution.

Index


Code Index:

NAME

Top

PDF::FromHTML::Template::Element::Bookmark

PURPOSE

Top

Creates a bookmark in the resultant PDF.

NODE NAME

Top

BOOKMARK

INHERITANCE

Top

PDF::FromHTML::Template::Element

ATTRIBUTES

Top

None

CHILDREN

Top

Text and <VAR> nodes. The text contained will be the location of the bookmark.

AFFECTS

Top

Resultant PDF

DEPENDENCIES

Top

None

USAGE

Top

  <bookmark text="Some Bookmark"/>

That now adds a bookmark for that spot to the PDF, called "Some Bookmark".

AUTHOR

Top

Rob Kinyon (rkinyon@columbus.rr.com)

SEE ALSO

Top


PDF-FromHTML documentation Contained in the PDF-FromHTML distribution.

package PDF::FromHTML::Template::Element::Bookmark;

use strict;

BEGIN {
    use vars qw(@ISA);
    @ISA = qw(PDF::FromHTML::Template::Element);

    use PDF::FromHTML::Template::Element;
}

sub new
{
    my $class = shift;
    my $self = $class->SUPER::new(@_);

    $self->{TXTOBJ} = PDF::FromHTML::Template::Factory->create('TEXTOBJECT');

    return $self;
}

sub render
{
    my $self = shift;
    my ($context) = @_;

    return 0 unless $self->should_render($context);

    return 1 if $context->{CALC_LAST_PAGE};

    my $txt = $self->{TXTOBJ}->resolve($context);

    unless (defined $txt)
    {
        warn "Bookmark: no text defined!", $/;
        $txt = 'undefined';
    }

    $context->{PDF}->add_bookmark($txt, 0, 0);

    return 1;
}

1;
__END__