line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package PDF::Boxer::Doc; |
2
|
|
|
|
|
|
|
{ |
3
|
|
|
|
|
|
|
$PDF::Boxer::Doc::VERSION = '0.001'; # TRIAL |
4
|
|
|
|
|
|
|
} |
5
|
3
|
|
|
3
|
|
20
|
use Moose; |
|
3
|
|
|
|
|
7
|
|
|
3
|
|
|
|
|
21
|
|
6
|
|
|
|
|
|
|
# ABSTRACT: Hold PDF::API2 stuff |
7
|
|
|
|
|
|
|
|
8
|
3
|
|
|
3
|
|
18474
|
use namespace::autoclean; |
|
3
|
|
|
|
|
35
|
|
|
3
|
|
|
|
|
18
|
|
9
|
|
|
|
|
|
|
|
10
|
3
|
|
|
3
|
|
1908
|
use PDF::API2; |
|
3
|
|
|
|
|
472137
|
|
|
3
|
|
|
|
|
1053
|
|
11
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
has 'file' => ( isa => 'Str', is => 'ro', required => 1 ); |
13
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
has 'pdf' => ( isa => 'Object', is => 'ro', lazy_build => 1 ); |
15
|
|
|
|
|
|
|
sub _build_pdf{ |
16
|
0
|
|
|
0
|
|
|
return PDF::API2->new( -file => shift->file ); |
17
|
|
|
|
|
|
|
} |
18
|
|
|
|
|
|
|
|
19
|
|
|
|
|
|
|
has 'page' => ( isa => 'Object', is => 'rw', lazy_build => 1 ); |
20
|
|
|
|
|
|
|
sub _build_page{ |
21
|
0
|
|
|
0
|
|
|
my ($self) = @_; |
22
|
0
|
|
|
|
|
|
my $page = $self->pdf->page; |
23
|
0
|
|
|
|
|
|
$page->mediabox(0,0,$self->page_width, $self->page_height); |
24
|
|
|
|
|
|
|
# $page->cropbox($self->page_width-10, $self->page_height); |
25
|
0
|
|
|
|
|
|
return $page; |
26
|
|
|
|
|
|
|
} |
27
|
|
|
|
|
|
|
|
28
|
|
|
|
|
|
|
# default to A4 |
29
|
|
|
|
|
|
|
has 'page_width' => ( isa => 'Int', is => 'ro', lazy_build => 1 ); |
30
|
|
|
|
|
|
|
has 'page_height' => ( isa => 'Int', is => 'ro', lazy_build => 1 ); |
31
|
0
|
|
|
0
|
|
|
sub _build_page_width{ 595 } |
32
|
0
|
|
|
0
|
|
|
sub _build_page_height{ 842 } |
33
|
|
|
|
|
|
|
|
34
|
|
|
|
|
|
|
has 'gfx' => ( isa => 'Object', is => 'rw', lazy_build => 1 ); |
35
|
0
|
|
|
0
|
|
|
sub _build_gfx{ shift->page->gfx } |
36
|
|
|
|
|
|
|
|
37
|
|
|
|
|
|
|
has 'text' => ( isa => 'Object', is => 'rw', lazy_build => 1 ); |
38
|
|
|
|
|
|
|
sub _build_text{ |
39
|
0
|
|
|
0
|
|
|
my $txt = shift->page->text; |
40
|
0
|
|
|
|
|
|
$txt->compressFlate; |
41
|
0
|
|
|
|
|
|
return $txt; |
42
|
|
|
|
|
|
|
} |
43
|
|
|
|
|
|
|
|
44
|
|
|
|
|
|
|
has 'fonts' => ( isa => 'HashRef', is => 'ro', lazy_build => 1 ); |
45
|
|
|
|
|
|
|
sub _build_fonts{ |
46
|
0
|
|
|
0
|
|
|
my ($self) = @_; |
47
|
|
|
|
|
|
|
return { |
48
|
0
|
|
|
|
|
|
'Helvetica' => { type => 'corefont', id => 'Helvetica', -encoding => 'latin1' }, |
49
|
|
|
|
|
|
|
'Helvetica-Bold' => { type => 'corefont', id => 'Helvetica-Bold', -encoding => 'latin1' }, |
50
|
|
|
|
|
|
|
'Helvetica-Italic' => { type => 'corefont', id => 'Helvetica-Oblique', -encoding => 'latin1' }, |
51
|
|
|
|
|
|
|
'Times' => { type => 'corefont', id => 'Times', -encoding => 'latin1' }, |
52
|
|
|
|
|
|
|
'Times-Bold' => { type => 'corefont', id => 'Times-Bold', -encoding => 'latin1' }, |
53
|
|
|
|
|
|
|
} |
54
|
|
|
|
|
|
|
} |
55
|
|
|
|
|
|
|
|
56
|
|
|
|
|
|
|
sub font{ |
57
|
0
|
|
|
0
|
0
|
|
my ($self, $name) = @_; |
58
|
0
|
|
|
|
|
|
my $font = $self->fonts->{$name}; |
59
|
0
|
0
|
|
|
|
|
die "cannot find font '$name' in fonts list" unless $font; |
60
|
0
|
0
|
|
|
|
|
return $font unless ref($font) eq 'HASH'; |
61
|
0
|
|
|
|
|
|
my $font_type = delete $font->{type}; |
62
|
0
|
|
|
|
|
|
my $font_id = delete $font->{id}; |
63
|
0
|
|
|
|
|
|
return $self->fonts->{$name} = $self->pdf->$font_type($font_id, %$font); |
64
|
|
|
|
|
|
|
} |
65
|
|
|
|
|
|
|
|
66
|
|
|
|
|
|
|
__PACKAGE__->meta->make_immutable; |
67
|
|
|
|
|
|
|
|
68
|
|
|
|
|
|
|
1; |
69
|
|
|
|
|
|
|
|
70
|
|
|
|
|
|
|
__END__ |
71
|
|
|
|
|
|
|
=pod |
72
|
|
|
|
|
|
|
|
73
|
|
|
|
|
|
|
=head1 NAME |
74
|
|
|
|
|
|
|
|
75
|
|
|
|
|
|
|
PDF::Boxer::Doc - Hold PDF::API2 stuff |
76
|
|
|
|
|
|
|
|
77
|
|
|
|
|
|
|
=head1 VERSION |
78
|
|
|
|
|
|
|
|
79
|
|
|
|
|
|
|
version 0.001 |
80
|
|
|
|
|
|
|
|
81
|
|
|
|
|
|
|
=head1 AUTHOR |
82
|
|
|
|
|
|
|
|
83
|
|
|
|
|
|
|
Jason Galea <lecstor@cpan.org> |
84
|
|
|
|
|
|
|
|
85
|
|
|
|
|
|
|
=head1 COPYRIGHT AND LICENSE |
86
|
|
|
|
|
|
|
|
87
|
|
|
|
|
|
|
This software is copyright (c) 2011 by Jason Galea. |
88
|
|
|
|
|
|
|
|
89
|
|
|
|
|
|
|
This is free software; you can redistribute it and/or modify it under |
90
|
|
|
|
|
|
|
the same terms as the Perl 5 programming language system itself. |
91
|
|
|
|
|
|
|
|
92
|
|
|
|
|
|
|
=cut |
93
|
|
|
|
|
|
|
|