NAME
Mxpress::PDF - PDF
VERSION
Version 0.28
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,
padding => 5,
},
subtitle => {
font => {
colour => '#0ff',
},
margin_bottom => 3,
padding => 5,
},
subsubtitle => {
font => {
colour => '#f0f',
},
padding => 5,
margin_bottom => 3
},
text => {
font => { colour => '#fff' },
margin_bottom => 3,
padding => 5,
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
);
my $default = $pdf->text->font;
my $bold = Mxpress::PDF->font($pdf, colour => '#fff', family => 'Times-Bold');
my $italic = Mxpress::PDF->font($pdf, colour => '#fff', family => 'Times-Italic');
$pdf->text->add('default text,');
$pdf->text->add('bold text,', font => $bold, concat => \1);
$pdf->text->add('italic text,', font => $italic, concat => \1);
$pdf->text->add('default text.', font => $default, concat => \1);
$pdf->list->add([
'First',
'Second',
'Third'
], type => 'number');
$pdf->border->start(type => 'dots');
for (0 .. 100) {
$pdf->toc->add(
[qw/title subtitle subsubtitle/]->[int(rand(3))] => $gen_text->(4)
)->text->add( $gen_text->(1000) );
}
$pdf->border->end;
$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);
header
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);
footer
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);
border
Returns a new Mxpress::PDF::Plugin::Border Object. This object is for drawing borders.
my $border = Mxpress::PDF->border($file, %line_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->circle($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::Subtitle 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);
h1
Returns a new Mxpress::PDF::Plugin::Text::H1 Object. This object aids with writing 'heading' text to a pdf page.
my $h1 = Mxpress::PDF->h1($file, %h1_args);
h2
Returns a new Mxpress::PDF::Plugin::Text::H2 Object. This object aids with writing 'heading' text to a pdf page.
my $h1 = Mxpress::PDF->h2($file, %h2_args);
h3
Returns a new Mxpress::PDF::Plugin::Text::H3 Object. This object aids with writing 'heading' text to a pdf page.
my $h1 = Mxpress::PDF->h3($file, %h3_args);
h4
Returns a new Mxpress::PDF::Plugin::Text::H4 Object. This object aids with writing 'heading' text to a pdf page.
my $h1 = Mxpress::PDF->h2($file, %h4_args);
h5
Returns a new Mxpress::PDF::Plugin::Text::H5 Object. This object aids with writing 'heading' text to a pdf page.
my $h1 = Mxpress::PDF->h2($file, %h5_args);
h6
Returns a new Mxpress::PDF::Plugin::Text::H6 Object. This object aids with writing 'heading' text to a pdf page.
my $h1 = Mxpress::PDF->h2($file, %h6_args);
list
Returns a new Mxpress::PDF::Plugin::List Object. This object aids with writing lists to a pdf page.
my $text = Mxpress::PDF->list($file, %list_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, %annotation_args);
form
Returns a new Mxpress::PDF::Plugin::Form Object. This object is for managing the AcroForm..
my $form = Mxpress::PDF->form($file, %form_args);
input
Returns a new Mxpress::PDF::Plugin::Field::Input Object. This object aids with adding fillable text fields to a pdf page.
my $input = Mxpress::PDF->input($file, %input_args);
textarea
Returns a new Mxpress::PDF::Plugin::Field::Input::Textarea Object. This object aids with adding fillable milti line text fields to a pdf page.
my $textarea = Mxpress::PDF->textarea($file, %textarea_args);
select
Returns a new Mxpress::PDF::Plugin::Field::Select Object. This object aids with adding select fields to a pdf page.
my $select = Mxpress::PDF->select($file, %select_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 (is => 'rw', type => Str);
The file name of the pdf
$file->file_name;
pdf (is => 'rw', type => Object);
A PDF::API2 Object.
$file->pdf;
pages (is => 'rw', type => ArrayRef);
A list of Mxpress::PDF::Page objects.
$file->pages;
page (is => 'rw', type => Object);
An open Mxpress::PDF::Page object.
$file->page;
onsave_cbs (is => 'rw', type => ArrayRef);
An array of arrays that define cbs, triggered when $file->save() is called.
[
[$plugin, $method_name, @%args]
]
font (is => 'rw', type => Object)
A Mxpress:PDF::Plugin::Font Object.
$file->font->load;
border (is => 'rw', type => Object)
A Mxpress:PDF::Plugin::Border Object.
$file->border->start;
...
$file->border->end;
line (is => 'rw', type => Object)
A Mxpress::PDF::Plugin::Shape::Line Object.
$file->line->add;
box (is => 'rw', 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;
h1
A Mxpress::PDF::Plugin::H1 Object.
$file->h1->add;
h2
A Mxpress::PDF::Plugin::H2 Object.
$file->h2->add;
h3
A Mxpress::PDF::Plugin::H3 Object.
$file->h3->add;
h4
A Mxpress::PDF::Plugin::H4 Object.
$file->h4->add;
h5
A Mxpress::PDF::Plugin::H5 Object.
$file->h5->add;
h6
A Mxpress::PDF::Plugin::H6 Object.
$file->h6->add;
text
A Mxpress::PDF::Plugin::Text Object
$file->text->add;
list
A Mxpress::PDF::Plugin::List Object.
$file->list->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 (is => 'rw', type => Str);
The page size of the pdf, default is A4.
$page->page_size('A4');
background (is => 'rw', type => Str);
The background colour of the page.
$page->background('#000');
num (is => 'rw', type => Num, required => 1);
The page number.
$page->num;
current (is => 'rw', type => Object);
The current PDF::API2::Page Object.
$page->current;
columns (is => 'rw', type => Num);
The number of columns configured for the page, default is 1.
$page->columns(5);
column (is => 'rw', type => Num);
The current column that is being generated, default is 1.
$page->column(2);
rows (is => 'rw', type => Num);
The number of rows configured for the page, default is 1.
$page->rows(5);
row (is => 'rw', type => Num);
The number of rows configured for the page, default is 1.
$page->row(2);
is_rotated (is => 'rw', type => Num);
Is the page rotated (portrait/landscape).
$page->is_rotated;
x (is => 'rw', type => Num);
The current x coordinate.
$page->x($x);
y (is => 'rw', type => Num);
The current y coordinate.
$page->y($y);
w (is => 'rw', type => Num);
The available page width.
$page->w($w);
h (is => 'rw', type => Num);
The available page height.
$page->h($h);
full (is => 'rw', type => Bool);
Disable any column/row configuration and render full width/height.
$page->full(\1);
padding (is => 'rw', type => Num);
Add padding to the page (mm).
$page->padding($mm);
margin_top (is => 'rw', type => Num);
Add margin to the top of the page (mm).
$page->margin_top($mm);
margin_bottom (is => 'rw', type => Num);
Add margin to the bottom of the page (mm).
$page->margin_bottom($mm);
onsave_cbs (is => 'rw', type => ArrayRef);
Callbacks that will be triggered when $file->save is called.
$page->onsave_cbs([
[$plugin, $method_name, @%args]
]);
header (is => 'rw', type => HashRef|Object);
A Mxpress::PDF::Page::Component::Header Object.
$page->header;
footer (is => 'rw', type => HashRef|Object);
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 (is => 'rw', type => Str);
Alignment for the page number
show_page_num => 'right'
page_num_text (is => 'rw', type => Str);
Text to display around the page number.
page_num_text => 'Page {num}'
active (is => 'rw', 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 (is => 'rw', type => Str);
Alignment for the page number
show_page_num => 'right'
page_num_text (is => 'rw', type => Str);
Text to display around the page number.
page_num_text => 'Page {num}'
active (is => 'rw', 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 (is => 'rw', type => Str);
Alignment for the page number
show_page_num => 'right'
page_num_text (is => 'rw', type => Str);
Text to display around the page number.
page_num_text => 'Page {num}'
active (is => 'rw', 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 (is => 'rw', type => Str);
The font colour.
size (is => 'rw', type => Num);
The font size.
family (is => 'rw', type => Str);
The font family.
loaded (is => 'rw', type => HashRef);
Loaded hashref of PDF::API2 fonts.
line_height ( is => 'rw', 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?)
Border
Mxpress::PDF::Plugin::Border extends Mxpress::PDF::Plugin::Shape::Line and is for aiding with drawing borders on a Mxpress::PDF::Page.
You can pass default attributes when instantiating the file object.
Mxpress::PDF->add_file($filename,
border => { %border_attrs },
);
or when calling the objects start method.
$file->border->start(
%border_attrs
);
Attributes
The following attributes can be configured for a Mxpress::PDF::Plugin::Border object, they are all optional.
$line->$attr();
fill_colour (is => 'rw', type => Str);
The colour of the line.
$line->fill_colour('#000');
border_top (is => 'rw', type => ArrayRef);
The position of the top border line
$line->border_top([$x, $y]);
Methods
The following methods can be called from a Mxpress::PDF::Plugin::Border Object.
start
Start the border this will track the current position of the pdf.
$border->start;
end
Stop the border, this will render the border to the page.
$border->end;
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 (is => 'rw', type => Str);
The colour of the line.
$line->fill_colour('#000');
position (is => 'rw', type => ArrayRef);
The position of the line
$line->position([$x, $y]);
end_position (is => 'rw', type => ArrayRef);
$line->end_position([$x, $y]);
type (is => 'rw', type => Str);
Sets the type of line style.
- solid
-
The default which is a solid line.
- dots
-
A line built out of dots, equivelant to setting dash as:
[1, 1]
- dashed
-
A line built out of dashes, equivelant to setting dash as:
[5, 5]
dash (is => 'rw', type => ArrayRef);
The arguments represent alternating dash and gap lengths.
[10, 10]
join (is => 'rw', type => Num);
Sets the style of join to be used at corners of a path.
- 0 = Miter Join
-
The outer edges of the stroke extend until they meet, up to the limit specified below. If the limit would be surpassed, a bevel join is used instead.
- 1 = Round Join
-
A circle with a diameter equal to the linewidth is drawn around the corner point, producing a rounded corner.
- 2 = Bevel Join
-
A triangle is drawn to fill in the notch between the two strokes.
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 (is => 'rw', type => Str);
The background colour of the box.
$box->fill('#000');
position (is => 'rw', 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 (is => 'rw', type => Str);
The background colour of the circle.
$circle->fill_colour('#000');
radius (is => 'rw', type => Num);
The radius of the circle. (mm)
$circle->radius($num);
position (is => 'rw', 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 (is => 'rw', type => Str);
The background colour of the pie.
$pie->fill_colour('#000');
radius (is => 'rw', type => Num);
The radius of the pie.
$pie->radius($num);
start (is => 'rw', type => Num);
Start percent of the pie.
$pie->start(180)
end (is => 'rw', type => Num);
End percent of the pie.
$pie->end(90);
position (is => 'rw', 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 (is => 'rw', type => Str);
The background colour of the ellipse.
$ellipse->fill_colour('#000');
radius (is => 'rw', type => Num);
The radius of the ellispe.
$ellispse->radius($r);
start (is => 'rw', type => Num);
Start percent of the ellipse
$ellipse->start($p)
end (is => 'rw', type => Num);
End percent of the ellipse.
$ellipse->end($p);
position (is => 'rw', 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 (is => 'rw', type => Object);
An Mxpress::PDF::Plugin::Font object.
$text->font(Mxpress::PDF->font($file, %font_args));
paragraph_space (is => 'rw', type => Num);
Configure the spacing between paragraphs.
$text->paragraph_space($mm);
paragraphs_to_columns (is => 'rw', 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 (is => 'rw', type => Num);
Indent the first line when rendering given text.
$text->first_line_indent($mm);
first_paragraph_indent (is => 'rw', type => Num);
Indent the first line when rendering given text.
$text->first_paragraph_indent($mm);
align (is => 'rw', type => Str); #enum
Align the text on each line. (left|justify|center|right)
$text->align('justify');
margin_bottom (is => 'rw', type => Num);
Set a bottom margin to be added after text has been rendered.
$text->margin($mm);
indent (is => 'rw', type => Num);
Set an indent for the block of text.
$text->indent($mm);
pad (is => 'rw', type => Str);
Pad the passed text to fit the available space, default is undefined.
$text->pad('.');
pad_end (is => 'rw', type => Str);
Append a string to the padded text.
$text->pad_end('!');
concat (is => 'rw', type => Bool);
Concatenate the text to the end of the last line/text segmant.
$text->concat(!!1);
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
);
H1
Mxpress::PDF::Plugin::H1 extends Mxpress::PDF::Plugin::Text and is for aiding with adding headings to a Mxpress::PDF::Page.
You can pass default attributes when instantiating the file object.
Mxpress::PDF->add_file($filename,
h1 => { %heading_attrs },
);
or when calling the objects add method.
$file->h1->add(
%heading_attrs
);
H2
Mxpress::PDF::Plugin::H2 extends Mxpress::PDF::Plugin::Text and is for aiding with adding headings to a Mxpress::PDF::Page.
You can pass default attributes when instantiating the file object.
Mxpress::PDF->add_file($filename,
h2 => { %heading_attrs },
);
or when calling the objects add method.
$file->h2->add(
%heading_attrs
);
H3
Mxpress::PDF::Plugin::H3 extends Mxpress::PDF::Plugin::Text and is for aiding with adding headings to a Mxpress::PDF::Page.
You can pass default attributes when instantiating the file object.
Mxpress::PDF->add_file($filename,
h3 => { %heading_attrs },
);
or when calling the objects add method.
$file->h3->add(
%heading_attrs
);
H4
Mxpress::PDF::Plugin::H4 extends Mxpress::PDF::Plugin::Text and is for aiding with adding headings to a Mxpress::PDF::Page.
You can pass default attributes when instantiating the file object.
Mxpress::PDF->add_file($filename,
h4 => { %heading_attrs },
);
or when calling the objects add method.
$file->h4->add(
%heading_attrs
);
H5
Mxpress::PDF::Plugin::H5 extends Mxpress::PDF::Plugin::Text and is for aiding with adding headings to a Mxpress::PDF::Page.
You can pass default attributes when instantiating the file object.
Mxpress::PDF->add_file($filename,
h5 => { %heading_attrs },
);
or when calling the objects add method.
$file->h5->add(
%heading_attrs
);
H6
Mxpress::PDF::Plugin::H6 extends Mxpress::PDF::Plugin::Text and is for aiding with adding headings to a Mxpress::PDF::Page.
You can pass default attributes when instantiating the file object.
Mxpress::PDF->add_file($filename,
h6 => { %heading_attrs },
);
or when calling the objects add method.
$file->h6->add(
%heading_attrs
);
List
Mxpress::PDF::Plugin::List extends Mxpress::PDF::Plugin::Text and is for aiding with adding lists to a Mxpress::PDF::Page.
You can pass default attributes when instantiating the file object.
Mxpress::PDF->add_file($filename,
list => { %list_attrs },
);
or when calling the objects add method.
$file->list->add(
%list_attrs
);
Attributes
The following attributes can be configured for a Mxpress::PDF::Plugin::List object, they are all optional.
$list->$attr();
type (is => 'rw', type => Str);
The type of list that will be rendered. The current options are either bullet, for a bullet point list, or number, for a number ordered list.
$file->list->type('number');
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 (is => 'rw', type => Num);
The current count of toc links
$file->toc->count;
indent (is => 'rw', type => Num);
The indent used for each level, default is 5.
$file->toc->indent(0);
levels (is => 'rw', 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 (is => 'rw', type => Num);
The line height offset when rendering the table of contents.
$file->toc_line_offset($mm);
font (is => 'rw', 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 (is => 'rw', type => Object);
The PDF::API2 Outline object.
$outline->outline;
x (is => 'rw', type => Num);
The x coordinates of the outline.
$outline->x($x);
y (is => 'rw', type => Num);
The y coordinates of the outline.
$outline->y($y);
title (is => 'rw', type => Str);
The title text used to render in the table of contents.
$outline->title($text);
page (is => 'rw', type => Object);
The linked Mxpress::PDF::Page object.
$ouline->page();
level (is => 'rw', type => Num);
The level of the outline.
$ouline->level(1);
children (is => 'rw', 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 (is => 'rw', type => Num);
The width of the image.
$img->width($pt);
height (is => 'rw', type => Num);
The height of the image.
$img->height($pt);
align (is => 'rw', 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 (is => 'rw', type => Num)
The type of annotation text|file|.
$annotation->type;
w (is => 'rw', type => Num)
The width of the annotation.
$annotation->w;
h (is => 'rw', type => Num)
The hieght of the annotation.
$annotation->h;
open (is => 'rw', 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)
Form
Mxpress::PDF::Plugin::Form extends Mxpress::PDF::Plugin and provides access to the PDF AcroForm.
Field
Mxpress::PDF::Plugin::Form::Field extends Mxpress::PDF::Plugin::Text and is the base class for Form 'Fields'.
Input
Mxpress::PDF::Plugin::Form::Field::Input extends Mxpress::PDF::Plugin::Form::Field and is for adding fillable text fields to a Mxpress::PDF::Page
You can pass default attributes when instantiating the file object.
Mxpress::PDF->add_file($filename,
field => { %text_attrs },
);
or when calling the objects add method.
$file->input->add(
%input_attrs
);
my $input = $pdf->input
Methods
The following methods can be called from a Mxpress::PDF::Plugin::Form::Field::Input Object.
add
Add a text field to the current Mxpress::PDF::Page.
$input->add('First Name:', %input_attrs)
Textarea
Mxpress::PDF::Plugin::Form::Field::Input::Textarea extends Mxpress::PDF::Plugin::Form::Field::Input and is for adding fillable multiline textarea fields to a Mxpress::PDF::Page
You can pass default attributes when instantiating the file object.
Mxpress::PDF->add_file($filename,
textarea => { %text_attrs },
);
or when calling the objects add method.
$file->textarea->add(
%textarea_attrs
);
my $textarea = $pdf->textarea
Methods
The following methods can be called from a Mxpress::PDF::Plugin::Form::Field::Input::Textarea Object.
add
Add a text field to the current Mxpress::PDF::Page.
$textarea->add('A Textarea:', lines => 10)
Select
Mxpress::PDF::Plugin::Form::Field::Select extends Mxpress::PDF::Plugin::Form::Field and is for adding interactive select fields to a Mxpress::PDF::Page
You can pass default attributes when instantiating the file object.
Mxpress::PDF->add_file($filename,
select => { %select_attrs },
);
or when calling the objects add method.
$file->select->add(
%select_attrs
);
my $select = $pdf->select;
Methods
The following methods can be called from a Mxpress::PDF::Plugin::Form::Field::Select Object.
add
Add a text field to the current Mxpress::PDF::Page.
$select->add('A Textarea:', options => [qw/a b c/]);
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:
RT: CPAN's request tracker (report bugs here)
AnnoCPAN: Annotated CPAN documentation
CPAN Ratings
Search CPAN
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)