NAME

Mxpress::PDF - PDF

VERSION

Version 0.14

Note

This is experimental and may yet still change.

SYNOPSIS

use Mxpress::PDF;

my @data = qw/
	Brian
	Dougal
	Dylan
	Ermintrude
	Florence
	Zebedee
/;

my $gen_text = sub { join( ' ', map { $data[int(rand(scalar @data))] } 0 .. int(rand(shift))) };

my $pdf = Mxpress::PDF->new_pdf('test',
	page => {
		background => '#000',
		padding => 15,
		columns => 3,
	},
	cover => {
		columns => 1
	},
	toc => {
		font => { colour => '#00f' },
	},
	title => {
		font => {
			colour => '#f00',
		},
		margin_bottom => 3,
	},
	subtitle => {
		font => {
			colour => '#0ff',
		},
		margin_bottom => 3
	},
	subsubtitle => {
		font => {
			colour => '#f0f',
		},
		margin_bottom => 3
	},
	text => {
		font => { colour => '#fff' },
		margin_bottom => 3,
		align => 'justify'
	},
);

$pdf->cover->add->title->add(
	'Add a cover page'
)->image->add(
	't/hand-cross.png'
)->cover->add(
	cb => ['text', 'add', q|you're welcome|]
)->cover->end;

$pdf->title->add(
	'Table Of Contents'
)->toc->placeholder;

$pdf->page->header->add(
	show_page_num => 'right',
	page_num_text => "page {num}",
	cb => ['text', 'add', 'Header of the page', align => 'center', font => Mxpress::PDF->font($pdf, colour => '#f00') ],
	h => $pdf->mmp(10),
	padding => 5
);

$pdf->page->footer->add(
	show_page_num => 'left',
	cb => ['text', 'add', 'Footer of the page', align => 'center', font => Mxpress::PDF->font($pdf, colour => '#f00') ],
	h => $pdf->mmp(10),
	padding => 5
);

for (0 .. 100) {
	$pdf->toc->add(
		[qw/title subtitle subsubtitle/]->[int(rand(3))] => $gen_text->(4)
	)->text->add( $gen_text->(1000) );
}

$pdf->save();

Description

This module currently allows you to easily create a PDF. Why? For fun.

Factory

Mxpress::PDF is a factory package and the entry point for Mxpress::PDF::* objects.

new_pdf

Returns a new Mxpress::PDF::File object. This is the MAIN object for working on the PDF file.

my $file = Mxpress::PDF->new_pdf($filename, %page_args);

page

Returns a new Mxpress::PDF::Page Object. This object is for managing an individual PDF page.

my $page = Mxpress::PDF->page(%page_args);

cover

Returns a new Mxpress::PDF::Page::Component::Cover Object. This object is for managing the PDF cover page.

my $cover = Mxpress::PDF->cover(%cover_args);

Returns a new Mxpress::PDF::Page::Component::Header Object. This object is for managing an individual PDF page header.

my $header = Mxpress::PDF->header(%header_args);

Returns a new Mxpress::PDF::Page::Component::Footer Object. This object is for managing an individual PDF page footer.

my $footer = Mxpress::PDF->footer(%footer_args);

font

Returns a new Mxpress::PDF::Plugin::Font Object. This object is for loading a PDFs text font.

my $font = Mxpress::PDF->font($file, %font_args);

line

Returns a new Mxpress::PDF::Plugin::Shape::Line Object. This object is for drawing lines.

my $line = Mxpress::PDF->line($file, %line_args);

box

Returns a new Mxpress::PDF::Plugin::Shape::Box Object. This object is for drawing box shapes.

my $box = Mxpress::PDF->box($file, %box_args);

circle

Returns a new Mxpress::PDF::Plugin::Shape::Circle Object. This object is for drawing circle shapes.

my $box = Mxpress::PDF->box($file, %circle_args);

pie

Returns a new Mxpress::PDF::Plugin::Shape::Pie Object. This object is for drawing pie shapes.

my $pie = Mxpress::PDF->pie($file, %pie_args);

ellipse

Returns a new Mxpress::PDF::Plugin::Shape::Ellipse Object. This object is for drawing ellipse shapes.

my $ellipse = Mxpress::PDF->ellipse($file, %ellise_args);

text

Returns a new Mxpress::PDF::Plugin::Text Object. This object aids with writing text to a pdf page.

my $text = Mxpress::PDF->text($file, %text_args);

title

Returns a new Mxpress::PDF::Plugin::Text::Title Object. This object aids with writing 'title' text to a pdf page.

my $title = Mxpress::PDF->title($file, %title_args);

subtitle

Returns a new Mxpress::PDF::Plugin::Text::Title Object. This object aids with writing 'subtitle' text to a pdf page.

my $subtitle = Mxpress::PDF->subtitle($file, %subtitle_args);

subsubtitle

Returns a new Mxpress::PDF::Plugin::Text::Subsubtitle Object. This object aids with writing 'subsubtitle' text to a pdf page.

my $subsubtitle = Mxpress::PDF->subsubtitle($file, %subsubtitle_args);

toc

Returns a new Mxpress::PDF::Plugin::TOC Object. This object is for managing a table of contents.

my $toc = Mxpress::PDF->toc($file, %toc_args);

add_outline

Returns a new Mxpress::PDF::Plugin::TOC::Outline Object. This object is for managing an indivual outline for the table of contents.

my $outline = Mxpress::PDF->add_outline($file, %ouline_args);

image

Returns a new Mxpress::PDF::Plugin::Image Object. This object aids with adding images to a pdf page.

my $image = Mxpress::PDF->image($file, %image_args);

annotation

Returns a new Mxpress::PDF::Plugin::Annotation Object. This object aids with adding annotations to a pdf page.

my $annotation = Mxpress::PDF->annotation($file, %image_args);

File

Mxpress::PDF::File is the main object that you will use when creating a pdf using this library. To instantiate call add_file with a file name and any plugin attributes.

my $file = Mxpress::PDF->add_file($filename,
	page => {},
	toc => {},
	title => {},
	subtitle => {},
	subsubtitle => {},
	text => {},
	toc => {},
	box => {},
	line => {},
	circle => {},
	pie => {},
	ellipse => {}
);

Attributes

The following attributes can be configured for a Mxpress::PDF::File, they are all optional.

$file->$attr

file_name (type => Str);

The file name of the pdf

$file->file_name;

pdf (type => Object);

A PDF::API2 Object.

$file->pdf;

pages (type => ArrayRef);

A list of Mxpress::PDF::Page objects.

$file->pages;

page (type => Object);

An open Mxpress::PDF::Page object.

$file->page;

onsave_cbs (type => ArrayRef);

An array of arrays that define cbs, triggered when $file->save() is called.

[
	[$plugin, $method_name, @%args]
]

font (type => Object)

A Mxpress:PDF::Plugin::Font Object.

$file->font->load;

line (type => Object)

A Mxpress::PDF::Plugin::Shape::Line Object.

$file->line->add;

box (type => Object)

A Mxpress::PDF::Plugin::Shape::Box Object.

$file->box->add;

circle

A Mxpress::PDF::Plugin::Shape::Circle Object.

$file->circle->add;

pie

A Mxpress::PDF::Plugin::Shape::Pie Object.

$file->pie->add;

ellipse

A Mxpress::PDF::Plugin::Shape::Ellipse Object.

$file->ellipse->add;

toc

A Mxpress::PDF::Plugin::TOC Object.

$file->toc->placeholder->toc->add(
	title => 'A title'
);

title

A Mxpress::PDF::Plugin::Title Object.

$file->title->add;

subtitle

A Mxpress::PDF::Plugin::Subtitle Object.

$file->title->add;

subsubtitle

A Mxpress::PDF::Plugin::Subsubtitle Object

$file->subsubtitle->add;

text

A Mxpress::PDF::Plugin::Text Object

$file->text->add;

Methods

The following methods can be called from a Mxpress::PDF::File Object.

add_page

This will add a new Mxpress::PDF::Page to the file. You can pass any page attributes defined in the documentation below.

$file->add_page(%page_attrs)

save

This will save the pdf file. Note call only once you are finished generating the pdf file.

$file->save();

onsave

Add a onsave callback to the file. The callbacks will be triggered when you call $file->save();.

$file->onsave($plugin, $cb, \%plugin_args);

mmp

Convert mm to pt.

my $pt = $file->mmp(10);

Page

An open Mxpress::PDF::Page object. Mxpress::PDF::Page is for managing an individual PDF page. To access the current open page call the attribute on the file object.

my $page = $file->page;

To add a new page to the pdf call add_page on the file object.

my $new_page = $file->add_page(%page_attributes)->page;

Attributes

The following attributes can be configured for a Mxpress::PDF::File, they are all optional.

$page->$attr

page_size (type => Str);

The page size of the pdf, default is A4.

$page->page_size('A4');

background (type => Str);

The background colour of the page.

$page->background('#000');

num (type => Num, required => 1);

The page number.

$page->num;

current (type => Object);

The current PDF::API2::Page Object.

$page->current;

columns (type => Num);

The number of columns configured for the page, default is 1.

$page->columns(5);

column (type => Num);

The current column that is being generated, default is 1.

$page->column(2);

rows (type => Num);

The number of rows configured for the page, default is 1.

$page->rows(5);

row (type => Num);

The number of rows configured for the page, default is 1.

$page->row(2);

is_rotated (type => Num);

Is the page rotated (portrait/landscape).

$page->is_rotated;

x (type => Num);

The current x coordinate.

$page->x($x);

y (type => Num);

The current y coordinate.

$page->y($y);

w (type => Num);

The available page width.

$page->w($w);

h (type => Num);

The available page height.

$page->h($h);

full (type => Bool);

Disable any column/row configuration and render full width/height.

$page->full(\1);

padding (type => Num);

Add padding to the page (mm).

$page->padding($mm);

margin_top (type => Num);

Add margin to the top of the page (mm).

$page->margin_top($mm);

margin_bottom (type => Num);

Add margin to the bottom of the page (mm).

$page->margin_bottom($mm);

onsave_cbs (type => ArrayRef);

Callbacks that will be triggered when $file->save is called.

$page->onsave_cbs([
	[$plugin, $method_name, @%args]
]);

header (type => HashRef|Object);

A Mxpress::PDF::Page::Component::Header Object.

$page->header;

A Mxpress::PDF::Page::Component::Footer Object.

$page->footer;

Methods

The following methods can be called from a Mxpress::PDF::Page Object.

rotate

Rotate the current page.

$page->rotate();

next_column

Find the next column of the page.

$page->next_column();

next_row

Find the next row of the page.

$page->next_row();

onsave

Add a onsave callback to the page. The callbacks will be triggered when you call $file->save();.

$page->onsave($plugin, $cb, @%plugin_args);

attrs

Return attributes for the page.

my $attrs = $page->attrs(@attrs);

Component

Cover

Mxpress::PDF::Page::Component::Cover extends Mxpress::PDF::Page::Component and is for managing an the PDF cover page.

You can pass default attributes when instantiating the page object.

$file->add_page(
	cover => { %cover_atts }
);

or when calling the objects add method.

$page->cover->add(
	%cover_attrs
);

Attributes

The following additional attributes can be configured for a Mxpress::PDF::Page::Component::Cover, they are all optional.

$page->cover->$attr

show_page_num (type => Str);

Alignment for the page number

show_page_num => 'right'

page_num_text (type => Str);

Text to display around the page number.

page_num_text => 'Page {num}'

active (type => Bool);

Control whether to display the cover, default is false however it is set to true if ->cover->add() is called.

active => true

Methods

The following methods can be called from a Mxpress::PDF::Page::Component Object.

add

Add content to the cover. You can pass any attribute for the header along with a cb function which will be added to the onsave_cbs.

$page->coverr->add(
	cb => [...],
	%cover_atts
);

set_position

Set the position of the header.

$page->header->position($x, $y, $w, $h);

process_page_num_text

Process the page_num_text into printable form.

$self->header->processs_page_num_text();

activate

Activate the header.

$page->activate()

end

Move to page 2.

$page->end;

Header

Mxpress::PDF::Page::Component::Header extends Mxpress::PDF::Page::Component and is for managing an individual PDF page header.

You can pass default attributes when instantiating the page object.

$file->add_page(
	header => { %header_atts }
);

or when calling the objects add method.

$page->header->add(
	%header_attrs
);

Attributes

The following additional attributes can be configured for a Mxpress::PDF::Page::Component::Header, they are all optional.

$page->header->$attr

show_page_num (type => Str);

Alignment for the page number

show_page_num => 'right'

page_num_text (type => Str);

Text to display around the page number.

page_num_text => 'Page {num}'

active (type => Bool);

Control whether to display the header, default is false however it is set to true if ->header->add() is called.

active => true

Methods

The following methods can be called from a Mxpress::PDF::Page::Header Object.

add

Add content to the header. You can pass any attribute for the header along with a cb function which will be added to the onsave_cbs.

$page->header->add(
	cb => [...],
	%header_atts
);

set_position

Set the position of the header.

$page->header->position($x, $y, $w, $h);

process_page_num_text

Process the page_num_text into printable form.

$self->header->processs_page_num_text();

activate

Activate the header.

$page->activate()

Footer

Mxpress::PDF::Page::Component::Footer extends Mxpress::PDF::Page and is for managing an individual PDF page footer.

You can pass default attributes when instantiating the page object.

$file->add_page(
	footer => { %footer_atts }
);

or when calling the objects add method.

$page->footer->add(
	%footer_attrs
);

Attributes

The following additional attributes can be configured for a Mxpress::PDF::Page::Component::Footer, they are all optional.

$page->footer->$attr

show_page_num (type => Str);

Alignment for the page number

show_page_num => 'right'

page_num_text (type => Str);

Text to display around the page number.

page_num_text => 'Page {num}'

active (type => Bool);

Control whether to display the header, default is false however it is set to true if ->footer->add() is called.

active => true

Methods

The following methods can be called from a Mxpress::PDF::Page::Footer Object.

add

Add content to the footer. You can pass any attribute for the footer along with a cb function which will be added to the onsave_cbs.

$page->footer->add(
	cb => [...],
	%footer_atts
);

set_position

Set the position of the footer.

$page->footer->position($x, $y, $w, $h);

process_page_num_text

Process the page_num_text into printable form.

$self->header->processs_page_num_text();

activate

Activate the header.

$page->activate()

Plugin

Mxpress::PDF::Plugin is a base class for plugins, it includes Mxpress::PDF::Utils.

Font

Mxpress::PDF::Plugin::Font extends Mxpress::PDF::Plugin and is for managing pdf fonts.

You can pass default attributes when instantiating the file object.

Mxpress::PDF->add_file($filename,
	font => { %font_atts },
	text => {
		font => { %font_attrs }
	}
);

or when calling some objects add methods like Mxpress::PDF::Plugin::Text->add.

$file->text->add(
	font => { %font_attrs },
);

Attributes

The following attributes can be configured for a Mxpress::PDF::Plugin::Font object, they are all optional.

$font->$attr();

colour (type => Str);

The font colour.

size (type => Num);

The font size.

family (type => Str);

The font family.

loaded (type => HashRef);

Loaded hashref of PDF::API2 fonts.

line_height ( type => Num);

Line height of the font.

Methods

The following methods can be called from a Mxpress::PDF::Plugin::Font Object.

load

Load the PDF::API2 font object.

$font->load()

find

Find a PDF::API2 font object.

$font->find($famild, $enc?)

Shape

Mxpress::PDF::Plugin::Shape extends Mxpress::PDF::Plugin and is the base class for all shape plugins.

Line

Mxpress::PDF::Plugin::Shape::Line extends Mxpress::PDF::Plugin::Shape and is for aiding with drawing lines on a Mxpress::PDF::Page.

You can pass default attributes when instantiating the file object.

Mxpress::PDF->add_file($filename,
	line => { %line_attrs },
);

or when calling the objects add method.

$file->line->add(
	%line_attrs
);

Attributes

The following attributes can be configured for a Mxpress::PDF::Plugin::Line object, they are all optional.

$line->$attr();

fill_colour (type => Str);

The colour of the line.

$line->fill_colour('#000');

position (type => ArrayRef);

The position of the line

$line->position([$x, $y]);

end_position (type => ArrayRef);

$line->end_position([$x, $y]);

Methods

The following methods can be called from a Mxpress::PDF::Plugin::Shape::Line Object.

add

Add a new line to the current Mxpress::PDF::Page.

$line->add(%line_args);

Box

Mxpress::PDF::Plugin::Shape::Box extends Mxpress::PDF::Plugin::Shape and is for aiding with drawing boxes on a Mxpress::PDF::Page.

You can pass default attributes when instantiating the file object.

Mxpress::PDF->add_file($filename,
	box => { %box_attrs },
);

or when calling the objects add method.

$file->box->add(
	%box_attrs
);

my $box = $file->box;

Attributes

The following attributes can be configured for a Mxpress::PDF::Plugin::Box object, they are all optional.

$box->$attr();

fill_colour (type => Str);

The background colour of the box.

$box->fill('#000');

position (type => ArrayRef);

The position of the box.

$box->position([$x, $y, $w, $h]);

Methods

The following methods can be called from a Mxpress::PDF::Plugin::Shape::Box Object.

add

Add a new box to the current Mxpress::PDF::Page.

$box->add(%box_attrs);

Circle

Mxpress::PDF::Plugin::Shape::Circle extends Mxpress::PDF::Plugin::Shape and is for aiding with drawing circles on a Mxpress::PDF::Page.

You can pass default attributes when instantiating the file object.

Mxpress::PDF->add_file($filename,
	circle => { %circle_attrs },
);

or when calling the objects add method.

$file->box->add(
	%circle_attrs
);

my $circle = $file->circle;

Attributes

The following attributes can be configured for a Mxpress::PDF::Plugin::Shape::Circle object, they are all optional.

$circle->$attr();

fill_colour (type => Str);

The background colour of the circle.

$circle->fill_colour('#000');

radius (type => Num);

The radius of the circle. (mm)

$circle->radius($num);

position (type => ArrayRef);

The position of the circle. (pt)

$circle->position([$x, $y, $w, $h]);

Methods

The following methods can be called from a Mxpress::PDF::Plugin::Shape::Circle Object.

add

Add a new circle shape to the current Mxpress::PDF::Page.

$circle->add(%line_args);

Pie

Mxpress::PDF::Plugin::Shape::Pie extends Mxpress::PDF::Plugin::Shape and is for aiding with drawing pies on a Mxpress::PDF::Page.

You can pass default attributes when instantiating the file object.

Mxpress::PDF->add_file($filename,
	pie => { %pie_attrs },
);

or when calling the objects add method.

$file->pie->add(
	%pie_attrs
);

my $pie = $file->pie;

Attributes

The following attributes can be configured for a Mxpress::PDF::Plugin::Shape::Pie object, they are all optional.

$pie->$attr();

fill_colour (type => Str);

The background colour of the pie.

$pie->fill_colour('#000');

radius (type => Num);

The radius of the pie.

$pie->radius($num);

start (type => Num);

Start percent of the pie.

$pie->start(180)

end (type => Num);

End percent of the pie.

$pie->end(90);

position (type => ArrayRef);

The position of the pie (pt)

$pie->position([$x, $y, $w, $h]);

Methods

The following methods can be called from a Mxpress::PDF::Plugin::Shape::Pie Object.

add

Add a new pie shape to the current Mxpress::PDF::Page.

$pie->add(%pie_attrs);

Ellipse

Mxpress::PDF::Plugin::Shape::Ellipse extends Mxpress::PDF::Plugin::Shape and is for aiding with drawing ellipses on a Mxpress::PDF::Page.

You can pass default attributes when instantiating the file object.

Mxpress::PDF->add_file($filename,
	ellipse => { %ellise_attrs },
);

or when calling the objects add method.

$file->ellipse->add(
	%pie_attrs
);

my $pie = $file->ellipse;

Attributes

The following attributes can be configured for a Mxpress::PDF::Plugin::Shape::Ellipse object, they are all optional.

$ellipse->$attr();

Attributes

fill_colour (type => Str);

The background colour of the ellipse.

$ellipse->fill_colour('#000');

radius (type => Num);

The radius of the ellispe.

$ellispse->radius($r);

start (type => Num);

Start percent of the ellipse

$ellipse->start($p)

end (type => Num);

End percent of the ellipse.

$ellipse->end($p);

position (type => ArrayRef);

The position of the ellipse (pt)

$pie->position([$x, $y, $w, $h]);

Methods

The following methods can be called from a Mxpress::PDF::Plugin::Shape::Ellipse Object.

add

Add a new ellipse shape to the current Mxpress::PDF::Page.

$ellipse->add(%ellipse_attrs);

Text

Mxpress::PDF::Plugin::Text extends Mxpress::PDF::Plugin and is for aiding with writing text to a Mxpress::PDF::Page.

You can pass default attributes when instantiating the file object.

Mxpress::PDF->add_file($filename,
	text => { %text_attrs },
);

or when calling the objects add method.

$file->text->add(
	%text_attrs
);

my $text = $file->text;

Attributes

The following attributes can be configured for a Mxpress::PDF::Plugin::Text object, they are all optional.

$text->$attrs();

font (type => Object);

An Mxpress::PDF::Plugin::Font object.

$text->font(Mxpress::PDF->font($file, %font_args));

paragraph_space (type => Num);

Configure the spacing between paragraphs.

$text->paragraph_space($mm);

paragraphs_to_columns (type => Bool);

If true then paragraphs within the passed text string will be split into individual columns.

$text->paragraphs_to_columns(\1);

first_line_indent (type => Num);

Indent the first line when rendering given text.

$text->first_line_indent($mm);

first_paragraph_indent (type => Num);

Indent the first line when rendering given text.

$text->first_paragraph_indent($mm);

align (type => Str); #enum

Align the text on each line. (left|justify|center|right)

$text->align('justify');

margin_bottom (type => Num);

Set a bottom margin to be added after text has been rendered.

$text->margin($mm);

indent (type => Num);

Set an indent for the block of text.

$text->indent($mm);

pad (type => Str);

Pad the passed text to fit the available space, default is undefined.

$text->pad('.');

pad_end (type => Str);

Append a string to the padded text.

$text->pad_end('!');

Methods

The following methods can be called from a Mxpress::PDF::Plugin::Text Object.

add

Add a text to the current Mxpress::PDF::Page.

$text->add($string_of_text, %text_args);

Title

Mxpress::PDF::Plugin::Title extends Mxpress::PDF::Plugin::Text and is for aiding with adding titles to a Mxpress::PDF::Page.

You can pass default attributes when instantiating the file object.

Mxpress::PDF->add_file($filename,
	title => { %title_attrs },
);

or when calling the objects add method.

$file->title->add(
	%title_attrs
);

Subtitle

Mxpress::PDF::Plugin::Subtitle extends Mxpress::PDF::Plugin::Text and is for aiding with adding subtitles to a Mxpress::PDF::Page.

You can pass default attributes when instantiating the file object.

Mxpress::PDF->add_file($filename,
	subtitle => { %subtitle_attrs },
);

or when calling the objects add method.

$file->subtitle->add(
	%subtitle_attrs
);

Subsubtitle

Mxpress::PDF::Plugin::Subsubtitle extends Mxpress::PDF::Plugin::Text and is for aiding with adding subsubtitles to a Mxpress::PDF::Page.

You can pass default attributes when instantiating the file object.

Mxpress::PDF->add_file($filename,
	subsubtitle => { %subsubtitle_attrs },
);

or when calling the objects add method.

$file->subsubtitle->add(
	%subsubtitle_attrs
);

TOC

Mxpress::PDF::Plugin::TOC extends Mxpress::PDF::Plugin and is for managing a table of contents.

You can pass default attributes when instantiating the file object.

Mxpress::PDF->add_file($filename,
	toc => { %toc_attrs },
);

or when calling the objects add method.

$file->toc->add(
	%toc_attrs
);

my $toc = $file->toc;

Attributes

The following attributes can be configured for a Mxpress::PDF::Plugin::TOC object, they are all optional.

$toc->$attr();

count (type => Num);

The current count of toc links

$file->toc->count;

indent (type => Num);

The indent used for each level, default is 5.

$file->toc->indent(0);

levels (type => ArrayRef);

The levels that can be used for TOC. For now we just have title|subtitle|subsubtitle but this is where you could extend.

$file->toc->levels;

toc_line_offset (type => Num);

The line height offset when rendering the table of contents.

$file->toc_line_offset($mm);

font (type => HashRef);

Attributes to be used for building the font class for TOC outlines

$toc->font(\%font_attrs);

Methods

The following methods can be called from a Mxpress::PDF::Plugin::TOC Object.

placeholder

The placeholder position where the table of contents will be rendered.

$toc->placeholder(%placeholder_attrs);

add

Add to the table of contents

$toc->add(
	title => $title,
	%toc_attrs
)

$toc->add(
	subtitle => [$subtitle, %subtitle_attrs]
);

TOC Outline

Mxpress::PDF::Plugin::TOC::Outline extends Mxpress::PDF::Plugin and is for managing a table of content outline.

my $outline = $file->FACTORY->add_outline()

Attributes

The following attributes can be configured for a Mxpress::PDF::Plugin::TOC::Object object.

$outline->$attrs();

outline (type => Object);

The PDF::API2 Outline object.

$outline->outline;

x (type => Num);

The x coordinates of the outline.

$outline->x($x);

y (type => Num);

The y coordinates of the outline.

$outline->y($y);

title (type => Str);

The title text used to render in the table of contents.

$outline->title($text);

page (type => Object);

The linked Mxpress::PDF::Page object.

$ouline->page();

level (type => Num);

The level of the outline.

$ouline->level(1);

children (type => ArrayRef);

An arrarref of linked Mxpress::PDF::Plugin::TOC::Outline objects.

$ouline->children

Image

Mxpress::PDF::Plugin::Image extends Mxpress::PDF::Plugin and is for adding images to a Mxpress::PDF::Page.

You can pass default attributes when instantiating the file object.

Mxpress::PDF->add_file($filename,
	image => { %image_attrs },
);

or when calling the objects add method.

$file->image->add(
	%image_attrs
);

my $image = $file->image;

Attributes

The following attributes can be configured for a Mxpress::PDF::Plugin::Image object, they are all optional.

$img->$attrs();

width (type => Num);

The width of the image.

$img->width($pt);

height (type => Num);

The height of the image.

$img->height($pt);

align (type => Str);

Align the image - left|center|right

$img->align('right');

Methods

The following methods can be called from a Mxpress::PDF::Plugin::Image Object.

add

Add an image to the current Mxpress::PDF::Page.

$img->add($image_fh, $type, %image_attrs)

or

$img->add($image_file_path, %image_attrs)

Annotation

Mxpress::PDF::Plugin::Annotation extends Mxpress::PDF::Plugin and is for adding annotations to a Mxpress::PDF::Page.

You can pass default attributes when instantiating the file object.

Mxpress::PDF->add_file($filename,
	annotation => { %annotation_attrs },
);

or when calling the objects add method.

$file->annotation->add(
	%annotation_attrs
);

my $annotation = $annotation->annotation;

Attributes

The following attributes can be configured for a Mxpress::PDF::Plugin::Annotation object, they are all optional.

$annotation->$attrs();

type (type => Num)

The type of annotation text|file|.

$annotation->type;

w (type => Num)

The width of the annotation.

$annotation->w;

h (type => Num)

The hieght of the annotation.

$annotation->h;

open (type => Bool)

Toggle whether annotation is open.

$annotation->open;

Methods

The following methods can be called from a Mxpress::PDF::Plugin::Annotation Object.

add

Add an annotation to the current Mxpress::PDF::Page.

$annotation->add('add some text', %annotation_attrs)

AUTHOR

LNATION, <thisusedtobeanemail at gmail.com>

BUGS

Please report any bugs or feature requests to bug-mxpress-pdf at rt.cpan.org, or through the web interface at https://rt.cpan.org/NoAuth/ReportBug.html?Queue=Mxpress-PDF. I will be notified, and then you'll automatically be notified of progress on your bug as I make changes.

SUPPORT

You can find documentation for this module with the perldoc command.

perldoc Mxpress::PDF

You can also look for information at:

ACKNOWLEDGEMENTS

LICENSE AND COPYRIGHT

This software is Copyright (c) 2020 by LNATION.

This is free software, licensed under:

The Artistic License 2.0 (GPL Compatible)