line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Text::PDF::Page; |
2
|
|
|
|
|
|
|
|
3
|
1
|
|
|
1
|
|
3
|
use strict; |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
22
|
|
4
|
1
|
|
|
1
|
|
2
|
use vars qw(@ISA); |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
33
|
|
5
|
|
|
|
|
|
|
@ISA = qw(Text::PDF::Pages); |
6
|
|
|
|
|
|
|
# no warnings qw(uninitialized); |
7
|
1
|
|
|
1
|
|
323
|
use Text::PDF::Pages; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
24
|
|
8
|
|
|
|
|
|
|
|
9
|
1
|
|
|
1
|
|
4
|
use Text::PDF::Utils; |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
258
|
|
10
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
=head1 NAME |
12
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
Text::PDF::Page - Represents a PDF page, inherits from L |
14
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
=head1 DESCRIPTION |
16
|
|
|
|
|
|
|
|
17
|
|
|
|
|
|
|
Represents a page of output in PDF. It also keeps track of the content stream, |
18
|
|
|
|
|
|
|
any resources (such as fonts) being switched, etc. |
19
|
|
|
|
|
|
|
|
20
|
|
|
|
|
|
|
Page inherits from Pages due to a number of shared methods. They are really |
21
|
|
|
|
|
|
|
structurally quite different. |
22
|
|
|
|
|
|
|
|
23
|
|
|
|
|
|
|
=head1 INSTANCE VARIABLES |
24
|
|
|
|
|
|
|
|
25
|
|
|
|
|
|
|
A page has various working variables: |
26
|
|
|
|
|
|
|
|
27
|
|
|
|
|
|
|
=over |
28
|
|
|
|
|
|
|
|
29
|
|
|
|
|
|
|
=item curstrm |
30
|
|
|
|
|
|
|
|
31
|
|
|
|
|
|
|
The currently open stream |
32
|
|
|
|
|
|
|
|
33
|
|
|
|
|
|
|
=back |
34
|
|
|
|
|
|
|
|
35
|
|
|
|
|
|
|
=head1 METHODS |
36
|
|
|
|
|
|
|
|
37
|
|
|
|
|
|
|
=head2 Text::PDF::Page->new($pdf, $parent, $index) |
38
|
|
|
|
|
|
|
|
39
|
|
|
|
|
|
|
Creates a new page based on a pages object (perhaps the root object). |
40
|
|
|
|
|
|
|
|
41
|
|
|
|
|
|
|
The page is also added to the parent at this point, so pages are ordered in |
42
|
|
|
|
|
|
|
a PDF document in the order in which they are created rather than in the order |
43
|
|
|
|
|
|
|
they are closed. |
44
|
|
|
|
|
|
|
|
45
|
|
|
|
|
|
|
Only the essential elements in the page dictionary are created here, all others |
46
|
|
|
|
|
|
|
are either optional or can be inherited. |
47
|
|
|
|
|
|
|
|
48
|
|
|
|
|
|
|
The optional index value indicates the index in the parent list that this page |
49
|
|
|
|
|
|
|
should be inserted (so that new pages need not be appended) |
50
|
|
|
|
|
|
|
|
51
|
|
|
|
|
|
|
=cut |
52
|
|
|
|
|
|
|
|
53
|
|
|
|
|
|
|
sub new |
54
|
|
|
|
|
|
|
{ |
55
|
1
|
|
|
1
|
1
|
7
|
my ($class, $pdf, $parent, $index) = @_; |
56
|
1
|
|
|
|
|
2
|
my ($self) = {}; |
57
|
|
|
|
|
|
|
|
58
|
1
|
50
|
|
|
|
3
|
$class = ref $class if ref $class; |
59
|
1
|
|
|
|
|
5
|
$self = $class->SUPER::new($pdf, $parent); |
60
|
1
|
|
|
|
|
3
|
$self->{'Type'} = PDFName('Page'); |
61
|
1
|
|
|
|
|
17
|
delete $self->{'Count'}; |
62
|
1
|
|
|
|
|
4
|
delete $self->{'Kids'}; |
63
|
1
|
|
|
|
|
4
|
$parent->add_page($self, $index); |
64
|
1
|
|
|
|
|
2
|
$self; |
65
|
|
|
|
|
|
|
} |
66
|
|
|
|
|
|
|
|
67
|
|
|
|
|
|
|
|
68
|
|
|
|
|
|
|
=head2 $p->add($str) |
69
|
|
|
|
|
|
|
|
70
|
|
|
|
|
|
|
Adds the string to the currently active stream for this page. If no stream |
71
|
|
|
|
|
|
|
exists, then one is created and added to the list of streams for this page. |
72
|
|
|
|
|
|
|
|
73
|
|
|
|
|
|
|
The slightly cryptic name is an aim to keep it short given the number of times |
74
|
|
|
|
|
|
|
people are likely to have to type it. |
75
|
|
|
|
|
|
|
|
76
|
|
|
|
|
|
|
=cut |
77
|
|
|
|
|
|
|
|
78
|
|
|
|
|
|
|
sub add |
79
|
|
|
|
|
|
|
{ |
80
|
1
|
|
|
1
|
1
|
4
|
my ($self, $str) = @_; |
81
|
1
|
|
|
|
|
48
|
my ($strm) = $self->{' curstrm'}; |
82
|
|
|
|
|
|
|
|
83
|
1
|
50
|
|
|
|
5
|
if (!defined $strm) |
84
|
|
|
|
|
|
|
{ |
85
|
1
|
|
|
|
|
4
|
$strm = Text::PDF::Dict->new; |
86
|
1
|
|
|
|
|
1
|
foreach (@{$self->{' outto'}}) |
|
1
|
|
|
|
|
3
|
|
87
|
1
|
|
|
|
|
3
|
{ $_->new_obj($strm); } |
88
|
1
|
50
|
|
|
|
5
|
$self->{'Contents'} = PDFArray() unless defined $self->{'Contents'}; |
89
|
1
|
50
|
|
|
|
4
|
unless (ref $self->{'Contents'} eq "Text::PDF::Array") |
90
|
0
|
|
|
|
|
0
|
{ $self->{'Contents'} = PDFArray($self->{'Contents'}); } |
91
|
1
|
|
|
|
|
2
|
$self->{'Contents'}->add_elements($strm); |
92
|
1
|
|
|
|
|
1
|
$self->{' curstrm'} = $strm; |
93
|
|
|
|
|
|
|
} |
94
|
|
|
|
|
|
|
|
95
|
1
|
|
|
|
|
2
|
$strm->{' stream'} .= $str; |
96
|
1
|
|
|
|
|
2
|
$self; |
97
|
|
|
|
|
|
|
} |
98
|
|
|
|
|
|
|
|
99
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
=head2 $p->ship_out($pdf) |
101
|
|
|
|
|
|
|
|
102
|
|
|
|
|
|
|
Ships the page out to the given output file context |
103
|
|
|
|
|
|
|
|
104
|
|
|
|
|
|
|
=cut |
105
|
|
|
|
|
|
|
|
106
|
|
|
|
|
|
|
sub ship_out |
107
|
|
|
|
|
|
|
{ |
108
|
0
|
|
|
0
|
1
|
|
my ($self, $pdf) = @_; |
109
|
|
|
|
|
|
|
|
110
|
0
|
|
|
|
|
|
$pdf->ship_out($self); |
111
|
0
|
0
|
|
|
|
|
if (defined $self->{'Contents'}) |
112
|
0
|
|
|
|
|
|
{ $pdf->ship_out($self->{'Contents'}->elementsof); } |
113
|
0
|
|
|
|
|
|
$self; |
114
|
|
|
|
|
|
|
} |
115
|
|
|
|
|
|
|
|
116
|
|
|
|
|
|
|
|