Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- use strict;
- use warnings;
- use Document::Writer;
- use Graphics::Color::RGB;
- use Graphics::Primitive::Driver::CairoPango;
- use Layout::Manager::Compass;
- use Layout::Manager::Grid;
- my $doc = Document::Writer->new;
- my $driver = Graphics::Primitive::Driver::CairoPango->new(format => 'pdf');
- my $black = Graphics::Color::RGB->new(red => 0, green => 0, blue => 0);
- my @dim = Document::Writer->get_paper_dimensions('letter');
- my $p = Document::Writer::Page->new(
- color => $black,
- # Landscape!
- width => $dim[1],
- height => $dim[0],
- );
- # Body layout
- $p->body->layout_manager(Layout::Manager::Compass->new);
- # Make the header, pretty much just name
- my $header = Graphics::Primitive::Container->new(
- layout_manager => Layout::Manager::Compass->new()
- );
- $header->add_component(make_text_box('Name'), 'e');
- $p->body->add_component($header, 'n');
- # Demography box
- my $demo_box = Graphics::Primitive::Container->new(
- layout_manager => Layout::Manager::Grid->new(rows => 2, columns => 12)
- );
- $demo_box->add_component(make_text_box('Character Name'), { row => 0, column => 0, width => 2 });
- $demo_box->add_component(make_text_box('Level'), { row => 0, column => 2, width => 1 });
- $demo_box->add_component(make_text_box('Class'), { row => 0, column => 3, width => 2 });
- $demo_box->add_component(make_text_box('Paragon Path'), { row => 0, column => 5, width => 3 });
- $demo_box->add_component(make_text_box('Epic Destiny'), { row => 0, column => 8, width => 3 });
- $demo_box->add_component(make_text_box('Total XP'), { row => 0, column => 11, width => 1 });
- $demo_box->add_component(make_text_box('Race'), { row => 1, column => 0, width => 1 });
- $demo_box->add_component(make_text_box('Size'), { row => 1, column => 1, width => 1 });
- $demo_box->add_component(make_text_box('Age'), { row => 1, column => 2, width => 1 });
- $demo_box->add_component(make_text_box('Gender'), { row => 1, column => 3, width => 1 });
- $demo_box->add_component(make_text_box('Height'), { row => 1, column => 4, width => 1 });
- $demo_box->add_component(make_text_box('Weight'), { row => 1, column => 5, width => 1 });
- $demo_box->add_component(make_text_box('Alignment'), { row => 1, column => 6, width => 1 });
- $demo_box->add_component(make_text_box('Deity'), { row => 1, column => 7, width => 1 });
- $demo_box->add_component(make_text_box('Adventuring Company'), { row => 1, column => 8, width => 3 });
- $demo_box->add_component(make_text_box('RPGA Number'), { row => 1, column => 11, width => 1 });
- $p->body->add_component($demo_box, 'n');
- my $tboxes = $p->find(sub {
- my ($comp, $const) = @_;
- return $comp->class eq 'text-label'
- });
- $tboxes->each(sub {
- my ($comp, $const) = @_;
- $comp->margins->top(14);
- $comp->padding->top(2);
- $comp->margins->left(5);
- $comp->margins->right(5);
- $comp->border->color($black);
- $comp->border->top->width(1);
- $comp->font->size(7);
- $comp->font->family('Arial');
- });
- $doc->add_page_break($driver, $p);
- $doc->draw($driver);
- $driver->write('foo.pdf');
- sub make_text_box {
- my ($text) = @_;
- return Graphics::Primitive::TextBox->new(
- text => $text,
- color => $black,
- class => 'text-label'
- );
- }
Add Comment
Please, Sign In to add comment