Create/Page.pm

filter: Statementstmt 54.7% 178 / 325 Branchbran 24.5% 29 / 118 Conditioncond 34.0% 16 / 47 MC/DCmcdc 0.0% 0 / 28 Subroutinesub 76.1% 32 / 42 Podpod 93.9% 31 / 33 totaltotal 48.2% 286 / 593 CC 84 SCAR 46.7
CC
84
Cov
46%
text
342.0
block_text
272.0
printnl
132.0
CRAP 106.6
« Image/JPEG.pm ↑ Summary Image/GIF.pm »
1 package PDF::Create::Page;
2  
3 18 our $VERSION = '1.29';
4  
5 =encoding utf8
6  
7 =head1 NAME
8  
9 PDF::Create::Page - PDF pages tree for PDF::Create
10  
11 =head1 VERSION
12  
13 Version 1.29
14  
15 =cut
16  
17 18 ▶use 5.006;
Subroutine BEGIN: called CC=1 SCAR=0.0
18 18 ▶use strict; use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: called CC=1 SCAR=0.0
19  
20 18 ▶use Carp;
Subroutine BEGIN: called CC=1 SCAR=0.0
21 18 ▶use FileHandle;
Subroutine BEGIN: called CC=1 SCAR=0.0
22 18 ▶use Data::Dumper;
Subroutine BEGIN: called CC=1 SCAR=0.0
23 18 ▶use POSIX qw(setlocale LC_NUMERIC);
Subroutine BEGIN: called CC=1 SCAR=0.0
24 18 ▶use Scalar::Util qw(weaken);
Subroutine BEGIN: called CC=1 SCAR=0.0
25  
26 18 our $DEBUG = 0;
27  
28 18 my $font_widths = &init_widths;
29 # Global variable for text function
30 18 my $ptext = '';
31  
32 =head1 DESCRIPTION
33  
34 B<FOR INTERNAL USE ONLY>
35  
36 =cut
37  
38 sub new {
39 59 ▶ my ($this) = @_;
Subroutine new: called CC=2 SCAR=7.1
Pod undocumented
40  
41 59 ▶ my $class = ref($this) || $this;
Condition33%1/3
ref $this || $this
l!l&&r!l&&!r
0590
MC/DC0%0/2
ref $this || $this
ref $this $this
Truth table33%1/3
A || B
A= ref $thisB= $this
ABresult
1X1
011
000
42 59 my $self = {};
43 59 bless $self, $class;
44 59 $self->{'Kids'} = [];
45 59 $self->{'Content'} = [];
46  
47 59 return $self;
48 }
49  
50 =head1 METHODS
51  
52 =head2 add($id, $name)
53  
54 Adds a page to the PDF document.
55  
56 =cut
57  
58 sub add {
59 36 ▶ my ($self, $id, $name) = @_;
Subroutine add: called CC=1 SCAR=0.0
Pod documented
60  
61 36 my $page = PDF::Create::Page->new();
62 36 $page->{'pdf'} = $self->{'pdf'};
63 36 weaken $page->{pdf};
64 36 $page->{'Parent'} = $self;
65 36 weaken $page->{Parent};
66 36 $page->{'id'} = $id;
67 36 $page->{'name'} = $name;
68 36 push @{$self->{'Kids'}}, $page;
69  
70 36 return $page;
71 }
72  
73 =head2 count()
74  
75 Returns page count.
76  
77 =cut
78  
79 sub count {
80 71 ▶ my ($self) = @_;
Subroutine count: called CC=3 SCAR=11.0
Pod documented
81  
82 71 my $c = 0;
83 71 ▶ $c++ unless scalar @{$self->{'Kids'}};
Branch: 1 branch
BranchTrueFalseTotal
unless scalar @{$self->{"Kids"};} 37 34 71
84 71 foreach my $page (@{$self->{'Kids'}}) {
85 48 $c += $page->count;
86 }
87  
88 71 return $c;
89 }
90  
91 =head2 kids()
92  
93 Returns ref to a list of page ids.
94  
95 =cut
96  
97 sub kids {
98 23 ▶ my ($self) = @_;
Subroutine kids: called CC=1 SCAR=0.0
Pod documented
99  
100 23 my $t = [];
101 23 map { push @$t, $_->{'id'} } @{$self->{'Kids'}};
102  
103 23 return $t;
104 }
105  
106 =head2 list()
107  
108 Returns page list.
109  
110 =cut
111  
112 sub list {
113 42 ▶ my ($self) = @_;
Subroutine list: called CC=3 SCAR=11.0
Pod documented
114  
115 42 my @l;
116 42 foreach my $e (@{$self->{'Kids'}}) {
117 30 my @t = $e->list;
118 30 push @l, $e;
119 30 ▶ push @l, @t if scalar @t;
Branch: 1 branch
BranchTrueFalseTotal
if scalar @t 11 19 30
120 }
121  
122 42 return @l;
123 }
124  
125 =head2 new_page()
126  
127 Return new page.
128  
129 =cut
130  
131 sub new_page {
132 20 ▶ my ($self, @params) = @_;
Subroutine new_page: called CC=1 SCAR=0.0
Pod documented
133  
134 20 return $self->{'pdf'}->new_page('Parent' => $self, @params);
135 }
136  
137 #
138 #
139 # Drawing functions
140  
141 =head2 moveto($x, $y)
142  
143 Moves the current point to (x, y), omitting any connecting line segment.
144  
145  
146 =cut
147  
148 sub moveto {
149 6 ▶ my ($self, $x, $y) = @_;
Subroutine moveto: called CC=1 SCAR=0.0
Pod documented
150  
151 6 $self->{'pdf'}->page_stream($self);
152 6 $self->{'pdf'}->add("$x $y m");
153 }
154  
155 =head2 lineto($x, $y)
156  
157 Appends a straight line segment from the current point to (x, y).
158  
159 =cut
160  
161 sub lineto {
162 366 ▶ my ($self, $x, $y) = @_;
Subroutine lineto: called CC=1 SCAR=0.0
Pod documented
163  
164 366 $self->{'pdf'}->page_stream($self);
165 366 $self->{'pdf'}->add("$x $y l");
166 }
167  
168 =head2 curveto($x1, $y1, $x2, $y2, $x3, $y3)
169  
170 Appends a Bezier curve to the path. The curve extends from the current point to
171 (x3 ,y3) using (x1 ,y1) and (x2 ,y2) as the Bezier control points.The new current
172 point is (x3 ,y3).
173  
174 =cut
175  
176 sub curveto {
177 4 ▶ my ($self, $x1, $y1, $x2, $y2, $x3, $y3) = @_;
Subroutine curveto: called CC=1 SCAR=0.0
Pod documented
178  
179 4 $self->{'pdf'}->page_stream($self);
180 4 $self->{'pdf'}->add("$x1 $y1 $x2 $y2 $x3 $y3 c");
181 }
182  
183 =head2 rectangle($x, $y, $w, $h)
184  
185 Adds a rectangle to the current path.
186  
187 =cut
188  
189 sub rectangle {
190 0 ▶ my ($self, $x, $y, $w, $h) = @_;
Subroutine rectangle: not called CC=1 SCAR=6.9
Pod documented
191  
192 0 $self->{'pdf'}->page_stream($self);
193 0 $self->{'pdf'}->add("$x $y $w $h re");
194 }
195  
196 =head2 closepath()
197  
198 Closes the current subpath by appending a straight line segment from the current
199 point to the starting point of the subpath.
200  
201 =cut
202  
203 sub closepath {
204 0 ▶ my ($self) = @_;
Subroutine closepath: not called CC=1 SCAR=6.9
Pod documented
205  
206 0 $self->{'pdf'}->page_stream($self);
207 0 $self->{'pdf'}->add("h");
208 }
209  
210 =head2 newpath()
211  
212 Ends the path without filling or stroking it.
213  
214 =cut
215  
216 sub newpath {
217 5 ▶ my ($self) = @_;
Subroutine newpath: called CC=1 SCAR=0.0
Pod documented
218  
219 5 $self->{'pdf'}->page_stream($self);
220 5 $self->{'pdf'}->add("n");
221 }
222  
223 =head2 stroke()
224  
225 Strokes the path.
226  
227 =cut
228  
229 sub stroke {
230 6 ▶ my ($self) = @_;
Subroutine stroke: called CC=1 SCAR=0.0
Pod documented
231  
232 6 $self->{'pdf'}->page_stream($self);
233 6 $self->{'pdf'}->add("S");
234 }
235  
236 =head2 closestroke()
237  
238 Closes and strokes the path.
239  
240 =cut
241  
242 sub closestroke {
243 0 ▶ my ($self) = @_;
Subroutine closestroke: not called CC=1 SCAR=6.9
Pod documented
244  
245 0 $self->{'pdf'}->page_stream($self);
246 0 $self->{'pdf'}->add("s");
247 }
248  
249 =head2 fill()
250  
251 Fills the path using the non-zero winding number rule.
252  
253 =cut
254  
255 sub fill {
256 1 ▶ my ($self) = @_;
Subroutine fill: called CC=1 SCAR=0.0
Pod documented
257  
258 1 $self->{'pdf'}->page_stream($self);
259 1 $self->{'pdf'}->add("f");
260 }
261  
262 =head2 fill2()
263  
264 Fills the path using the even-odd rule.
265  
266 =cut
267  
268 sub fill2 {
269 0 ▶ my ($self) = @_;
Subroutine fill2: not called CC=1 SCAR=6.9
Pod documented
270  
271 0 $self->{'pdf'}->page_stream($self);
272 0 $self->{'pdf'}->add("f*");
273 }
274  
275 =head2 line($x1, $y1, $x2, $y2)
276  
277 Draw a line between ($x1, $y1) and ($x2, $y2). Combined moveto / lineto / stroke
278 command.
279  
280 =cut
281  
282 sub line {
283 56 ▶ my ($self, $x1, $y1, $x2, $y2) = @_;
Subroutine line: called CC=1 SCAR=0.0
Pod documented
284  
285 56 $self->{'pdf'}->page_stream($self);
286 56 $self->{'pdf'}->add("$x1 $y1 m $x2 $y2 l S");
287 }
288  
289 =head2 set_width($w)
290  
291 Set the width of subsequent lines to C<w> points.
292  
293 =cut
294  
295 sub set_width {
296 6 ▶ my ($self, $w) = @_;
Subroutine set_width: called CC=1 SCAR=0.0
Pod documented
297  
298 6 $self->{'pdf'}->page_stream($self);
299 6 $self->{'pdf'}->add("$w w");
300 }
301  
302 #
303 #
304 # Color functions
305  
306 =head2 setgray($value)
307  
308 Sets the color space to DeviceGray and sets the gray tint to use for filling paths.
309  
310 =cut
311  
312 sub setgray {
313 0 ▶ my ($self, $val) = @_;
Subroutine setgray: not called CC=1 SCAR=6.9
Pod documented
314  
315 0 $self->{'pdf'}->page_stream($self);
316 0 $self->{'pdf'}->add("$val g");
317 }
318  
319 =head2 setgraystroke($value)
320  
321 Sets the color space to DeviceGray and sets the gray tint to use for stroking paths.
322  
323 =cut
324  
325 sub setgraystroke {
326 0 ▶ my ($self, $val) = @_;
Subroutine setgraystroke: not called CC=1 SCAR=6.9
Pod documented
327  
328 0 $self->{'pdf'}->page_stream($self);
329 0 $self->{'pdf'}->add("$val G");
330 }
331  
332 =head2 setrgbcolor($r, $g, $b)
333  
334 Sets the fill colors used for normal text or filled objects.
335  
336 =cut
337  
338 sub setrgbcolor {
339 1 ▶ my ($self, $r, $g, $b) = @_;
Subroutine setrgbcolor: called CC=1 SCAR=0.0
Pod documented
340  
341 1 $self->{'pdf'}->page_stream($self);
342 1 $self->{'pdf'}->add("$r $g $b rg");
343 }
344  
345 =head2 setrgbcolorstroke($r, $g, $b)
346  
347 Set the color of the subsequent drawing operations. Valid r, g, and b values are
348 each between 0.0 and 1.0, inclusive.
349  
350 Each color ranges from 0.0 to 1.0, i.e., darkest red (0.0) to brightest red(1.0).
351 The same holds for green and blue. These three colors mix additively to produce
352 the colors between black (0.0, 0.0, 0.0) and white (1.0, 1.0, 1.0).
353  
354 PDF distinguishes between the stroke and fill operations and provides separate
355 color settings for each.
356  
357 =cut
358  
359 sub setrgbcolorstroke {
360 4 ▶ my ($self, $r, $g, $b) = @_;
Subroutine setrgbcolorstroke: called CC=2 SCAR=7.0
Pod documented
361  
362 4 ▶ croak "Error setting colors, need three values" if !defined $b;
Branch: 1 branch
BranchTrueFalseTotal
unless defined $b 0 4 4
363 4 $self->{'pdf'}->page_stream($self);
364 4 $self->{'pdf'}->add("$r $g $b RG");
365 }
366  
367 #
368 #
369 # Text functions
370  
371 =head2 text(%params)
372  
373 Renders the text. Parameters are explained as below:
374  
375 +--------+------------------------------------------------------------------+
376 | Key | Description |
377 +--------+------------------------------------------------------------------+
378 | start | The start marker, add directive BT |
379 | end | The end marker, add directive ET |
380 | text | Text to add to the pdf |
381 | F | Font index to be used, add directive /F<font_index> |
382 | Tf | Font size for the text, add directive <font_size> Tf |
383 | Ts | Text rise (super/subscript), add directive <mode> Ts |
384 | Tr | Text rendering mode, add directive <mode> Tr |
385 | TL | Text leading, add directive <number> TL |
386 | Tc | Character spacing, add directive <number> Tc |
387 | Tw | Word spacing, add directive <number> Tw |
388 | Tz | Horizontal scaling, add directive <number> Tz |
389 | Td | Move to, add directive <x> <y> Td |
390 | TD | Move to and set TL, add directive <x> <y> TD |
391 | rot | Move to and rotate (<r> <x> <y>), add directive |
392 | | <cos(r)>, <sin(r)>, <sin(r)>, <cos(r)>, <x>, <y> Tm |
393 | T* | Add new line. |
394 +--------+------------------------------------------------------------------+
395  
396 =cut
397  
398 sub text {
399 0 ▶ my ($self, %params) = @_;
Subroutine text: not called CC=18 SCAR=58.3
Pod documented
400  
401 0 PDF::Create::debug( 2, "text(%params):" );
402  
403 0 my @directives = ();
404  
405 0 ▶ if (defined $params{'start'}) { push @directives, "BT"; }
Branch: 1 branch
BranchTrueFalseTotal
if (defined $params{"start"}) 0 0 0
406  
407 # Font index
408 0 ▶ if (defined $params{'F'}) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $params{"F"}) 0 0 0
409 0 push @directives, "/F$params{'F'}";
410 0 $self->{'pdf'}->uses_font($self, $params{'F'});
411 }
412 # Font size
413 0 ▶ if (defined $params{'Tf'}) { push @directives, "$params{'Tf'} Tf"; }
Branch: 1 branch
BranchTrueFalseTotal
if (defined $params{"Tf"}) 0 0 0
414 # Text Rise (Super/Subscript)
415 0 ▶ if (defined $params{'Ts'}) { push @directives, "$params{'Ts'} Ts"; }
Branch: 1 branch
BranchTrueFalseTotal
if (defined $params{"Ts"}) 0 0 0
416 # Rendering Mode
417 0 ▶ if (defined $params{'Tr'}) { push @directives, "$params{'Tr'} Tr"; }
Branch: 1 branch
BranchTrueFalseTotal
if (defined $params{"Tr"}) 0 0 0
418 # Text Leading
419 0 ▶ if (defined $params{'TL'}) { push @directives, "$params{'TL'} TL"; }
Branch: 1 branch
BranchTrueFalseTotal
if (defined $params{"TL"}) 0 0 0
420 # Character spacing
421 0 ▶ if (defined $params{'Tc'}) { push @directives, "$params{'Tc'} Tc"; }
Branch: 1 branch
BranchTrueFalseTotal
if (defined $params{"Tc"}) 0 0 0
422 # Word Spacing
423 0 ▶ if (defined $params{'Tw'}) { push @directives, "$params{'Tw'} Tw"; }
Branch: 1 branch
BranchTrueFalseTotal
if (defined $params{"Tw"}) 0 0 0
424 # Horizontal Scaling
425 0 ▶ if (defined $params{'Tz'}) { push @directives, "$params{'Tz'} Tz"; }
Branch: 1 branch
BranchTrueFalseTotal
if (defined $params{"Tz"}) 0 0 0
426 # Moveto
427 0 ▶ if (defined $params{'Td'}) { push @directives, "$params{'Td'} Td"; }
Branch: 1 branch
BranchTrueFalseTotal
if (defined $params{"Td"}) 0 0 0
428 # Moveto and set TL
429 0 ▶ if (defined $params{'TD'}) { push @directives, "$params{'TD'} TD"; }
Branch: 1 branch
BranchTrueFalseTotal
if (defined $params{"TD"}) 0 0 0
430  
431 # Moveto and rotateOA
432 0 my $pi = atan2(1, 1) * 4;
433 0 my $piover180 = $pi / 180;
434 0 ▶ if (defined $params{'rot'}) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $params{"rot"}) 0 0 0
435 0 my ($r, $x, $y) = split( /\s+/, $params{'rot'}, 3 );
436 0 ▶ $x = 0 unless ($x > 0);
Branch: 1 branch
BranchTrueFalseTotal
unless $x > 0 0 0 0
437 0 ▶ $y = 0 unless ($y > 0);
Branch: 1 branch
BranchTrueFalseTotal
unless $y > 0 0 0 0
438 0 my $cos = cos($r * $piover180);
439 0 my $sin = sin($r * $piover180);
440 0 push @directives, sprintf("%.5f %.5f -%.5f %.5f %s %s Tm", $cos, $sin, $sin, $cos, $x, $y);
441 }
442  
443 # New line
444 0 ▶ if (defined $params{'T*'}) { push @directives, "T*"; }
Branch: 1 branch
BranchTrueFalseTotal
if (defined $params{"T*"}) 0 0 0
445  
446 0 ▶ if (defined $params{'text'}) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $params{"text"}) 0 0 0
447 0 $params{'text'} =~ s|([()])|\\$1|g;
448 0 push @directives, "($params{'text'}) Tj";
449 }
450  
451 0 ▶ if (defined $params{'end'}) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $params{"end"}) 0 0 0
452 0 push @directives, "ET";
453 0 $ptext = join(' ', @directives);
454 0 $self->{'pdf'}->page_stream($self);
455 0 $self->{'pdf'}->add($ptext);
456 }
457  
458 0 PDF::Create::debug( 3, "text(): $ptext" );
459  
460 0 1;
461 }
462  
463 =head2 string($font, $size, $x, $y, $text $alignment)
464  
465 Add text to the current page using the font object at the given size and position.
466 The point (x, y) is the bottom left corner of the rectangle containing the text.
467  
468 The optional alignment can be 'r' for right-alignment and 'c' for centered.
469  
470 Example :
471  
472 my $f1 = $pdf->font(
473 'Subtype' => 'Type1',
474 'Encoding' => 'WinAnsiEncoding',
475 'BaseFont' => 'Helvetica'
476 );
477  
478 $page->string($f1, 20, 306, 396, "some text");
479  
480 =cut
481  
482 sub string {
483 10 ▶ my ($self, $font, $size, $x, $y, $string, $align,
Subroutine string: called CC=8 SCAR=22.1
Pod documented
484 $char_spacing, $word_spacing) = @_;
485  
486 10 ▶ $align = 'L' unless defined $align;
Branch: 1 branch
BranchTrueFalseTotal
unless defined $align 6 4 10
487  
488 10 ▶ if (uc($align) eq "R") {
Branch: 2 branches
BranchTrueFalseTotal
if (uc $align eq 'R') { } 1 9 10
elsif (uc $align eq 'C') { } 2 7 9
489 1 $x -= $size * $self->string_width($font, $string);
490 } elsif (uc($align) eq "C") {
491 2 $x -= $size * $self->string_width($font, $string) / 2;
492 }
493  
494 10 my @directives = (
495 'BT',
496 "/F$font",
497 "$size Tf",
498 );
499  
500 10 ▶ if (defined $char_spacing && $char_spacing =~ m/[0-9]+\.?[0-9]*/) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $char_spacing and $char_spacing =~ /[0-9]+\.?[0-9]*/) 0 10 10
Condition33%1/3
defined $char_spacing and $char_spacing =~ /[0-9]+\.?[0-9]*/
!ll&&!rl&&r
1000
MC/DC0%0/2
defined $char_spacing and $char_spacing =~ /[0-9]+\.?[0-9]*/
defined $char_spacing $char_spacing =~ /[0-9]+\.?[0-9]*/
Truth table33%1/3
A and B
A= defined $char_spacingB= $char_spacing =~ /[0-9]+\.?[0-9]*/
ABresult
0X0
100
111
501 0 push @directives, sprintf("%s Tc", $char_spacing);
502 }
503  
504 10 ▶ if (defined $word_spacing && $word_spacing =~ m/[0-9]+\.?[0-9]*/) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $word_spacing and $word_spacing =~ /[0-9]+\.?[0-9]*/) 0 10 10
Condition33%1/3
defined $word_spacing and $word_spacing =~ /[0-9]+\.?[0-9]*/
!ll&&!rl&&r
1000
MC/DC0%0/2
defined $word_spacing and $word_spacing =~ /[0-9]+\.?[0-9]*/
defined $word_spacing $word_spacing =~ /[0-9]+\.?[0-9]*/
Truth table33%1/3
A and B
A= defined $word_spacingB= $word_spacing =~ /[0-9]+\.?[0-9]*/
ABresult
0X0
100
111
505 0 push @directives, sprintf("%s Tw", $word_spacing);
506 }
507  
508 10 $string =~ s|([()])|\\$1|g;
509  
510 10 push @directives,
511 "$x $y Td",
512 "($string) Tj",
513 'ET';
514  
515 10 $self->{'pdf'}->page_stream($self);
516 10 $self->{'pdf'}->uses_font($self, $font);
517 10 $self->{'pdf'}->add(join(' ', @directives));
518 }
519  
520 =head2 string_underline($font, $size, $x, $y, $text, $alignment)
521  
522 Draw a line for underlining.The parameters are the same as for the string function
523 but only the line is drawn. To draw an underlined string you must call both,string
524 and string_underline. To change the color of your text use the C<setrgbcolor()>.
525 It returns the length of the string. So its return value can be used directly for
526 the bounding box of an annotation.
527  
528 Example :
529  
530 $page->string($f1, 20, 306, 396, "some underlined text");
531  
532 $page->string_underline($f1, 20, 306, 396, "some underlined text");
533  
534 =cut
535  
536 sub string_underline {
537 6 ▶ my ($self, $font, $size, $x, $y, $string, $align) = @_;
Subroutine string_underline: called CC=4 SCAR=13.9
Pod documented
538  
539 6 ▶ $align = 'L' unless defined $align;
Branch: 1 branch
BranchTrueFalseTotal
unless defined $align 2 4 6
540 6 my $len1 = $self->string_width($font, $string) * $size;
541 6 my $len2 = $len1 / 2;
542 6 ▶ if (uc($align) eq "R") {
Branch: 2 branches
BranchTrueFalseTotal
if (uc $align eq 'R') { } 1 5 6
elsif (uc $align eq 'C') { } 2 3 5
543 1 $self->line($x - $len1, $y - 1, $x, $y - 1);
544 } elsif (uc($align) eq "C") {
545 2 $self->line($x - $len2, $y - 1, $x + $len2, $y - 1);
546 } else {
547 3 $self->line($x, $y - 1, $x + $len1, $y - 1);
548 }
549  
550 6 return $len1;
551 }
552  
553 =head2 stringl($font, $size, $x, $y $text)
554  
555 Same as C<string()>.
556  
557 =cut
558  
559 sub stringl {
560 11 ▶ my ($self, $font, $size, $x, $y, $string) = @_;
Subroutine stringl: called CC=1 SCAR=0.0
Pod documented
561  
562 11 $self->{'pdf'}->page_stream($self);
563 11 $self->{'pdf'}->uses_font($self, $font);
564 11 $string =~ s|([()])|\\$1|g;
565 11 $self->{'pdf'}->add("BT /F$font $size Tf $x $y Td ($string) Tj ET");
566 }
567  
568 =head2 stringr($font, $size, $x, $y, $text)
569  
570 Same as C<string()> but right aligned (alignment 'r').
571  
572 =cut
573  
574 sub stringr {
575 1 ▶ my ($self, $font, $size, $x, $y, $string) = @_;
Subroutine stringr: called CC=1 SCAR=0.0
Pod documented
576  
577 1 $self->{'pdf'}->page_stream($self);
578 1 $self->{'pdf'}->uses_font($self, $font);
579 1 $x -= $size * $self->string_width($font, $string);
580 1 $string =~ s|([()])|\\$1|g;
581 1 $self->{'pdf'}->add(" BT /F$font $size Tf $x $y Td ($string) Tj ET");
582 }
583  
584 =head2 stringc($font, $size, $x, $y, $text)
585  
586 Same as C<string()> but centered (alignment 'c').
587  
588 =cut
589  
590 sub stringc {
591 61 ▶ my ($self, $font, $size, $x, $y, $string) = @_;
Subroutine stringc: called CC=1 SCAR=0.0
Pod documented
592  
593 61 $self->{'pdf'}->page_stream($self);
594 61 $self->{'pdf'}->uses_font($self, $font);
595 61 $x -= $size * $self->string_width($font, $string) / 2;
596 61 $string =~ s|([()])|\\$1|g;
597 61 $self->{'pdf'}->add(" BT /F$font $size Tf $x $y Td ($string) Tj ET");
598 }
599  
600 =head2 string_width($font, $text)
601  
602 Return the size of the text using the given font in default user space units.This
603 does not contain the size of the font yet, to get the length you must multiply by
604 the font size.
605  
606 =cut
607  
608 sub string_width {
609 71 ▶ my ($self, $font, $string) = @_;
Subroutine string_width: called CC=4 SCAR=14.0
Pod documented
610  
611 71 ▶ croak 'No string given' unless defined $string;
Branch: 1 branch
BranchTrueFalseTotal
unless defined $string 0 71 71
612  
613 71 my $fname = $self->{'pdf'}{'fonts'}{$font}{'BaseFont'}[1];
614 71 ▶ croak('Unknown font: ' . $fname) unless defined $$font_widths{$fname}[ ord "M" ];
Branch: 1 branch
BranchTrueFalseTotal
unless defined $font_widths->{$fname}[77] 0 71 71
615  
616 71 my $w = 0;
617 71 for my $c ( split '', $string ) {
618 1391 $w += $$font_widths{$fname}[ ord $c ];
619 }
620  
621 71 return $w / 1000;
622 }
623  
624 =head2 printnl($text, $font, $size, $x, $y)
625  
626 Similar to C<string()> but parses the string for newline and prints each part on
627 a separate line. Lines spacing is the same as the font-size.Returns the number of
628 lines.
629  
630 Note the different parameter sequence.The first call should specify all parameters,
631 font is the absolute minimum, a warning will be given for the missing y position
632 and 800 will be assumed. All subsequent invocations can omit all but the string
633 parameters.
634  
635 ATTENTION:There is no provision for changing pages.If you run out of space on the
636 current page this will draw the string(s) outside the page and it will be invisble.
637  
638 =cut
639  
640 sub printnl {
641 0 ▶ my ($self, $s, $font, $size, $x, $y) = @_;
Subroutine printnl: not called CC=11 SCAR=48.8
Pod documented
642  
643 0 ▶ $self->{'current_font'} = $font if defined $font;
Branch: 1 branch
BranchTrueFalseTotal
if defined $font 0 0 0
644 0 ▶ croak 'No font found !' if !defined $self->{'current_font'};
Branch: 1 branch
BranchTrueFalseTotal
unless defined $self->{"current_font"} 0 0 0
645  
646 # set up current_x/y used in stringml
647 0 ▶ $self->{'current_y'} = $y if defined $y;
Branch: 1 branch
BranchTrueFalseTotal
if defined $y 0 0 0
648 0 ▶ carp 'No starting position given, using 800' if !defined $self->{'current_y'};
Branch: 1 branch
BranchTrueFalseTotal
unless defined $self->{"current_y"} 0 0 0
649 0 ▶ $self->{'current_y'} = 800 if !defined $self->{'current_y'};
Branch: 1 branch
BranchTrueFalseTotal
unless defined $self->{"current_y"} 0 0 0
650 0 ▶ $self->{'current_x'} = $x if defined $x;
Branch: 1 branch
BranchTrueFalseTotal
if defined $x 0 0 0
651 0 ▶ $self->{'current_x'} = 20 if !defined $self->{'current_x'};
Branch: 1 branch
BranchTrueFalseTotal
unless defined $self->{"current_x"} 0 0 0
652 0 ▶ $self->{'current_size'} = $size if defined $size;
Branch: 1 branch
BranchTrueFalseTotal
if defined $size 0 0 0
653 0 ▶ $self->{'current_size'} = 12 if !defined $self->{'current_size'};
Branch: 1 branch
BranchTrueFalseTotal
unless defined $self->{"current_size"} 0 0 0
654  
655 # print the line(s)
656 0 my $n = 0;
657 0 for my $line ( split '\n', $s ) {
658 0 $n++;
659 0 $self->string($self->{'current_font'}, $self->{'current_size'}, $self->{'current_x'}, $self->{'current_y'}, $line);
660 0 $self->{'current_y'} = $self->{'current_y'} - $self->{'current_size'};
661 }
662  
663 0 return $n;
664 }
665  
666 =head2 block_text(\%params)
667  
668 Add block of text to the page. Parameters are explained as below:
669  
670 +------------+--------------------------------------------------------------+
671 | Key | Description |
672 +------------+--------------------------------------------------------------+
673 | page | Object of type PDF::Create::Page |
674 | font | Font index to be used. |
675 | text | Text block to be used. |
676 | font_size | Font size for the text. |
677 | text_color | Text color as arrayref i.e. [r, g, b] |
678 | line_width | Line width (in points) |
679 | start_y | First row number (in points) when adding new page. |
680 | end_y | Last row number (in points) when to add new page. |
681 | x | x co-ordinate to start the text. |
682 | y | y co-ordinate to start the text. |
683 | para_space_factor | Gap between paragraphs. Default 1.5 times font size. |
684 +------------+--------------------------------------------------------------+
685  
686 use strict; use warnings;
687 use PDF::Create;
688  
689 my $pdf = PDF::Create->new('filename'=>"$0.pdf", 'Author'=>'MANWAR', 'Title'=>'Create::PDF');
690 my $root = $pdf->new_page('MediaBox' => $pdf->get_page_size('A4'));
691 my $page = $root->new_page;
692 my $font = $pdf->font('BaseFont' => 'Helvetica');
693  
694 $page->rectangle(30, 780, 535, 40);
695 $page->setrgbcolor(0,1,0);
696 $page->fill;
697  
698 $page->setrgbcolorstroke(1,0,0);
699 $page->line(30, 778, 565, 778);
700  
701 $page->setrgbcolor(0,0,1);
702 $page->string($font, 15, 102, 792, 'MANWAR - PDF::Create');
703  
704 my $text = qq{
705 Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. It has survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged. It was popularised in the 1960s with the release of Letraset sheets containing Lorem Ipsum passages, and more recently with desktop publishing software like Aldus PageMaker including versions of Lorem Ipsum. Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book.
706 It has survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged. It was popularised in the 1960s with the release of Letraset sheets containing Lorem Ipsum passages, and more recently with desktop publishing software like Aldus PageMaker including versions of Lorem Ipsum. Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book.
707 };
708  
709 $page->block_text({
710 page => $page,
711 font => $font,
712 text => $text,
713 font_size => 6,
714 text_color => [0,0,1],
715 line_width => 535,
716 start_y => 780,
717 end_y => 60,
718 'x' => 30,
719 'y' => 770,
720 });
721  
722 $pdf->close;
723  
724 =cut
725  
726 sub block_text {
727 0 ▶ my ($self, $params) = @_;
Subroutine block_text: not called CC=16 SCAR=56.1
Pod documented
728  
729 0 ▶ croak "ERROR: parameters to method block_text() should be hashref.\n"
Branch: 1 branch
BranchTrueFalseTotal
unless defined $params and ref $params eq "HASH" 0 0 0
Condition0%0/3
defined $params and ref $params eq "HASH"
!ll&&!rl&&r
000
MC/DC0%0/2
defined $params and ref $params eq "HASH"
defined $params ref $params eq "HASH"
Truth table0%0/3
A and B
A= defined $paramsB= ref $params eq "HASH"
ABresult
0X0
100
111
730 unless (defined $params && (ref($params) eq 'HASH'));
731  
732 0 my $page = $params->{page};
733 0 my $font = $params->{font};
734 0 my $text = $params->{text};
735 0 my $font_size = $params->{font_size};
736 0 my $text_color = $params->{text_color};
737 0 my $line_width = $params->{line_width};
738 0 my $start_y = $params->{start_y};
739 0 my $end_y = $params->{end_y};
740 0 my $x = $params->{x};
741 0 my $y = $params->{y};
742 0 my $one_space = $page->string_width($font, ' ') * $font_size;
743  
744 0 my $para_space_factor = 1.5;
745 $para_space_factor = $params->{para_space_factor}
746 if (exists $params->{para_space_factor}
747 0 ▶ && defined $params->{para_space_factor});
Branch: 1 branch
BranchTrueFalseTotal
if exists $params->{"para_space_factor"} and defined $params->{"para_space_factor"} 0 0 0
Condition0%0/3
exists $params->{"para_space_factor"} and defined $params->{"para_space_factor"}
!ll&&!rl&&r
000
MC/DC0%0/2
exists $params->{"para_space_factor"} and defined $params->{"para_space_factor"}
exists $params->{"para_space_factor"} defined $params->{"para_space_factor"}
Truth table0%0/3
A and B
A= exists $params->{"para_space_factor"}B= defined $params->{"para_space_factor"}
ABresult
0X0
100
111
748  
749 0 my @lines = ();
750 0 foreach my $block (split /\n/, $text) {
751 0 my @words = split(/ /, $block);
752 0 my $para_last_line = 0;
753  
754 0 ▶ while (@words) {
Branch: 1 branch
BranchTrueFalseTotal
if (@words) 0 0 0
755 0 my $num_words = 1;
756 0 my $string_width = 0;
757 0 my $space_width = undef;
758  
759 0 while (1) {
760 0 $string_width = $font_size * $page->string_width(
761 $font, _get_text(\@words, $num_words));
762  
763 # Shorter, try one more word
764 0 ▶ if ($string_width + $one_space < $line_width) {
Branch: 1 branch
BranchTrueFalseTotal
if ($string_width + $one_space < $line_width) 0 0 0
765 0 ▶ if (scalar(@words) > $num_words) {
Branch: 1 branch
BranchTrueFalseTotal
if (scalar @words > $num_words) 0 0 0
766 0 $num_words++;
767 0 next;
768 }
769 }
770  
771 0 ▶ last if ($num_words == 1);
Branch: 1 branch
BranchTrueFalseTotal
if $num_words == 1 0 0 0
772  
773 # Longer, chop a word off, then space accordingly
774 0 $para_last_line = scalar(@words) == $num_words;
775 0 ▶ if ($string_width + $one_space > $line_width || $para_last_line) {
Branch: 1 branch
BranchTrueFalseTotal
if ($string_width + $one_space > $line_width or $para_last_line) 0 0 0
Condition0%0/3
$string_width + $one_space > $line_width or $para_last_line
l!l&&r!l&&!r
000
MC/DC0%0/2
$string_width + $one_space > $line_width or $para_last_line
$string_width + $one_space > $line_width $para_last_line
Truth table0%0/3
A or B
A= $string_width + $one_space > $line_widthB= $para_last_line
ABresult
1X1
011
000
776 0 ▶ unless ($para_last_line) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($para_last_line) 0 0 0
777 0 $num_words--;
778 }
779  
780 0 $string_width = $font_size * $page->string_width(
781 $font, _get_text(\@words, $num_words));
782  
783 0 $space_width = ($line_width - $string_width) / $num_words;
784 0 last;
785 }
786 }
787  
788 0 my %text_param = (
789 start => 1,
790 Tw => $space_width,
791 F => $font,
792 Tf => $font_size,
793 Td => "$x $y",
794 text => _get_text(\@words, $num_words),
795 end => 1,
796 );
797  
798 0 ▶ if ($para_last_line) {
Branch: 1 branch
BranchTrueFalseTotal
if ($para_last_line) 0 0 0
799 0 delete $text_param{Tw};
800 }
801  
802 0 $page->text(%text_param);
803  
804 0 ▶ if ($y <= $end_y) {
Branch: 1 branch
BranchTrueFalseTotal
if ($y <= $end_y) { } 0 0 0
805 0 $y = $start_y;
806 0 $page = $page->{'Parent'}->new_page();
807 0 $page->setrgbcolor(@$text_color);
808 }
809 else {
810 0 $y -= int($font_size * 1.5);
811 0 ▶ if ($para_last_line) {
Branch: 1 branch
BranchTrueFalseTotal
if ($para_last_line) 0 0 0
812 0 $y -= int($font_size * $para_space_factor);
813 }
814 }
815  
816 0 splice(@words, 0, $num_words);
817 }
818 }
819 }
820  
821 =head2 image(%params)
822  
823 Inserts an image. Parameters can be:
824  
825 +----------------+----------------------------------------------------------+
826 | Key | Description |
827 +----------------+----------------------------------------------------------+
828 | | |
829 | image | Image id returned by PDF::image (required). |
830 | | |
831 | xpos, ypos | Position of image (required). |
832 | | |
833 | xalign, yalign | Alignment of image.0 is left/bottom, 1 is centered and 2 |
834 | | is right, top. |
835 | | |
836 | xscale, yscale | Scaling of image. 1.0 is original size. |
837 | | |
838 | rotate | Rotation of image.0 is no rotation,2*pi is 360° rotation.|
839 | | |
840 | xskew, yskew | Skew of image. |
841 | | |
842 +----------------+----------------------------------------------------------+
843  
844 Example jpeg image:
845  
846 # include a jpeg image with scaling to 20% size
847 my $jpg = $pdf->image("image.jpg");
848  
849 $page->image(
850 'image' => $jpg,
851 'xscale' => 0.2,
852 'yscale' => 0.2,
853 'xpos' => 350,
854 'ypos' => 400
855 );
856  
857 =cut
858  
859 sub image {
860 2 ▶ my ($self, %params) = @_;
Subroutine image: called CC=22 SCAR=39.9
Pod documented
861  
862 # Switch to the 'C' locale, we need printf floats with a '.', not a ','
863 2 my $savedLocale = setlocale(LC_NUMERIC);
864 2 setlocale(LC_NUMERIC,'C');
865  
866 2 ▶ my $img = $params{'image'} || "1.2";
Condition50%1/2
$params{'image'} || '1.2'
l!l
20
MC/DC0%0/1
$params{'image'} || '1.2'
$params{'image'}
Truth table50%1/2
A
A= $params{'image'}
Aresult
11
00
867 2 my $image = $img->{num};
868 2 ▶ my $xpos = $params{'xpos'} || 0;
Condition50%1/2
$params{'xpos'} || 0
l!l
20
MC/DC0%0/1
$params{'xpos'} || 0
$params{'xpos'}
Truth table50%1/2
A
A= $params{'xpos'}
Aresult
11
00
869 2 ▶ my $ypos = $params{'ypos'} || 0;
Condition50%1/2
$params{'ypos'} || 0
l!l
20
MC/DC0%0/1
$params{'ypos'} || 0
$params{'ypos'}
Truth table50%1/2
A
A= $params{'ypos'}
Aresult
11
00
870 2 ▶ my $xalign = $params{'xalign'} || 0;
Condition50%1/2
$params{'xalign'} || 0
l!l
02
MC/DC0%0/1
$params{'xalign'} || 0
$params{'xalign'}
Truth table50%1/2
A
A= $params{'xalign'}
Aresult
11
00
871 2 ▶ my $yalign = $params{'yalign'} || 0;
Condition50%1/2
$params{'yalign'} || 0
l!l
02
MC/DC0%0/1
$params{'yalign'} || 0
$params{'yalign'}
Truth table50%1/2
A
A= $params{'yalign'}
Aresult
11
00
872 2 ▶ my $xscale = $params{'xscale'} || 1;
Condition50%1/2
$params{'xscale'} || 1
l!l
20
MC/DC0%0/1
$params{'xscale'} || 1
$params{'xscale'}
Truth table50%1/2
A
A= $params{'xscale'}
Aresult
11
00
873 2 ▶ my $yscale = $params{'yscale'} || 1;
Condition50%1/2
$params{'yscale'} || 1
l!l
20
MC/DC0%0/1
$params{'yscale'} || 1
$params{'yscale'}
Truth table50%1/2
A
A= $params{'yscale'}
Aresult
11
00
874 2 ▶ my $rotate = $params{'rotate'} || 0;
Condition50%1/2
$params{'rotate'} || 0
l!l
02
MC/DC0%0/1
$params{'rotate'} || 0
$params{'rotate'}
Truth table50%1/2
A
A= $params{'rotate'}
Aresult
11
00
875 2 ▶ my $xskew = $params{'xskew'} || 0;
Condition50%1/2
$params{'xskew'} || 0
l!l
02
MC/DC0%0/1
$params{'xskew'} || 0
$params{'xskew'}
Truth table50%1/2
A
A= $params{'xskew'}
Aresult
11
00
876 2 ▶ my $yskew = $params{'yskew'} || 0;
Condition50%1/2
$params{'yskew'} || 0
l!l
02
MC/DC0%0/1
$params{'yskew'} || 0
$params{'yskew'}
Truth table50%1/2
A
A= $params{'yskew'}
Aresult
11
00
877  
878 2 $xscale *= $img->{width};
879 2 $yscale *= $img->{height};
880  
881 2 ▶ if ($xalign == 1) {
Branch: 2 branches
BranchTrueFalseTotal
if ($xalign == 1) { } 0 2 2
elsif ($xalign == 2) { } 0 2 2
882 0 $xpos -= $xscale / 2;
883 } elsif ($xalign == 2) {
884 0 $xpos -= $xscale;
885 }
886  
887 2 ▶ if ($yalign == 1) {
Branch: 2 branches
BranchTrueFalseTotal
if ($yalign == 1) { } 0 2 2
elsif ($yalign == 2) { } 0 2 2
888 0 $ypos -= $yscale / 2;
889 } elsif ($yalign == 2) {
890 0 $ypos -= $yscale;
891 }
892  
893 2 $self->{'pdf'}->page_stream($self);
894 2 $self->{'pdf'}->uses_xobject( $self, $image );
895 2 $self->{'pdf'}->add("q\n");
896  
897 # TODO: image: Merge position with rotate
898 2 ▶ $self->{'pdf'}->add("1 0 0 1 $xpos $ypos cm\n")
Branch: 1 branch
BranchTrueFalseTotal
if $xpos or $ypos 2 0 2
Condition33%1/3
$xpos or $ypos
l!l&&r!l&&!r
200
MC/DC0%0/2
$xpos or $ypos
$xpos $ypos
Truth table33%1/3
A or B
A= $xposB= $ypos
ABresult
1X1
011
000
899 if ($xpos || $ypos);
900  
901 2 ▶ if ($rotate) {
Branch: 1 branch
BranchTrueFalseTotal
if ($rotate) 0 2 2
902 0 my $sinth = sin($rotate);
903 0 my $costh = cos($rotate);
904 0 $self->{'pdf'}->add("$costh $sinth -$sinth $costh 0 0 cm\n");
905 }
906 2 ▶ if ($xscale || $yscale) {
Branch: 1 branch
BranchTrueFalseTotal
if ($xscale or $yscale) 2 0 2
Condition33%1/3
$xscale or $yscale
l!l&&r!l&&!r
200
MC/DC0%0/2
$xscale or $yscale
$xscale $yscale
Truth table33%1/3
A or B
A= $xscaleB= $yscale
ABresult
1X1
011
000
907 2 $self->{'pdf'}->add("$xscale 0 0 $yscale 0 0 cm\n");
908 }
909 2 ▶ if ($xskew || $yskew) {
Branch: 1 branch
BranchTrueFalseTotal
if ($xskew or $yskew) 0 2 2
Condition33%1/3
$xskew or $yskew
l!l&&r!l&&!r
002
MC/DC0%0/2
$xskew or $yskew
$xskew $yskew
Truth table33%1/3
A or B
A= $xskewB= $yskew
ABresult
1X1
011
000
910 0 my $tana = sin($xskew) / cos($xskew);
911 0 my $tanb = sin($yskew) / cos($xskew);
912 0 $self->{'pdf'}->add("1 $tana $tanb 1 0 0 cm\n");
913 }
914 2 $self->{'pdf'}->add("/Image$image Do\n");
915 2 $self->{'pdf'}->add("Q\n");
916  
917 # Switch to the 'C' locale, we need printf floats with a '.', not a ','
918 2 setlocale(LC_NUMERIC,$savedLocale);
919 }
920  
921 # Table with font widths for the supported fonts.
922 sub init_widths
923 {
924 18 ▶ { 'Courier' => [ 599, 599, 599, 599, 599, 599, 599, 599, 599, 599, 599, 599, 599, 599, 599, 599, 599, 599, 599, 599,
Subroutine init_widths: called CC=1 SCAR=0.0
Pod undocumented
925 599, 599, 599, 599, 599, 599, 599, 599, 599, 599, 599, 599, 599, 599, 599, 599, 599, 599, 599, 599,
926 599, 599, 599, 599, 599, 599, 599, 599, 599, 599, 599, 599, 599, 599, 599, 599, 599, 599, 599, 599,
927 599, 599, 599, 599, 599, 599, 599, 599, 599, 599, 599, 599, 599, 599, 599, 599, 599, 599, 599, 599,
928 599, 599, 599, 599, 599, 599, 599, 599, 599, 599, 599, 599, 599, 599, 599, 599, 599, 599, 599, 599,
929 599, 599, 599, 599, 599, 599, 599, 599, 599, 599, 599, 599, 599, 599, 599, 599, 599, 599, 599, 599,
930 599, 599, 599, 599, 599, 599, 599, 599, 599, 599, 599, 599, 599, 599, 599, 599, 599, 599, 599, 599,
931 599, 599, 599, 599, 599, 599, 599, 599, 599, 599, 599, 599, 599, 599, 599, 599, 599, 599, 599, 599,
932 599, 599, 599, 599, 599, 599, 599, 599, 599, 599, 599, 599, 599, 599, 599, 599, 599, 599, 599, 599,
933 599, 599, 599, 599, 599, 599, 599, 599, 599, 599, 599, 599, 599, 599, 599, 599, 599, 599, 599, 599,
934 599, 599, 599, 599, 599, 599, 599, 599, 599, 599, 599, 599, 599, 599, 599, 599, 599, 599, 599, 599,
935 599, 599, 599, 599, 599, 599, 599, 599, 599, 599, 599, 599, 599, 599, 599, 599, 599, 599, 599, 599,
936 599, 599, 599, 599, 599, 599, 599, 599, 599, 599, 599, 599, 599, 599, 599, 599 ],
937 'Courier-Bold' => [ 599, 599, 599, 599, 599, 599, 599, 599, 599, 599, 599, 599, 599, 599, 599, 599, 599, 599, 599, 599,
938 599, 599, 599, 599, 599, 599, 599, 599, 599, 599, 599, 599, 599, 599, 599, 599, 599, 599, 599, 599,
939 599, 599, 599, 599, 599, 599, 599, 599, 599, 599, 599, 599, 599, 599, 599, 599, 599, 599, 599, 599,
940 599, 599, 599, 599, 599, 599, 599, 599, 599, 599, 599, 599, 599, 599, 599, 599, 599, 599, 599, 599,
941 599, 599, 599, 599, 599, 599, 599, 599, 599, 599, 599, 599, 599, 599, 599, 599, 599, 599, 599, 599,
942 599, 599, 599, 599, 599, 599, 599, 599, 599, 599, 599, 599, 599, 599, 599, 599, 599, 599, 599, 599,
943 599, 599, 599, 599, 599, 599, 599, 599, 599, 599, 599, 599, 599, 599, 599, 599, 599, 599, 599, 599,
944 599, 599, 599, 599, 599, 599, 599, 599, 599, 599, 599, 599, 599, 599, 599, 599, 599, 599, 599, 599,
945 599, 599, 599, 599, 599, 599, 599, 599, 599, 599, 599, 599, 599, 599, 599, 599, 599, 599, 599, 599,
946 599, 599, 599, 599, 599, 599, 599, 599, 599, 599, 599, 599, 599, 599, 599, 599, 599, 599, 599, 599,
947 599, 599, 599, 599, 599, 599, 599, 599, 599, 599, 599, 599, 599, 599, 599, 599, 599, 599, 599, 599,
948 599, 599, 599, 599, 599, 599, 599, 599, 599, 599, 599, 599, 599, 599, 599, 599, 599, 599, 599, 599,
949 599, 599, 599, 599, 599, 599, 599, 599, 599, 599, 599, 599, 599, 599, 599, 599 ],
950 'Courier-BoldOblique' => [ 599, 599, 599, 599, 599, 599, 599, 599, 599, 599, 599, 599, 599, 599, 599, 599, 599, 599,
951 599, 599, 599, 599, 599, 599, 599, 599, 599, 599, 599, 599, 599, 599, 599, 599, 599, 599,
952 599, 599, 599, 599, 599, 599, 599, 599, 599, 599, 599, 599, 599, 599, 599, 599, 599, 599,
953 599, 599, 599, 599, 599, 599, 599, 599, 599, 599, 599, 599, 599, 599, 599, 599, 599, 599,
954 599, 599, 599, 599, 599, 599, 599, 599, 599, 599, 599, 599, 599, 599, 599, 599, 599, 599,
955 599, 599, 599, 599, 599, 599, 599, 599, 599, 599, 599, 599, 599, 599, 599, 599, 599, 599,
956 599, 599, 599, 599, 599, 599, 599, 599, 599, 599, 599, 599, 599, 599, 599, 599, 599, 599,
957 599, 599, 599, 599, 599, 599, 599, 599, 599, 599, 599, 599, 599, 599, 599, 599, 599, 599,
958 599, 599, 599, 599, 599, 599, 599, 599, 599, 599, 599, 599, 599, 599, 599, 599, 599, 599,
959 599, 599, 599, 599, 599, 599, 599, 599, 599, 599, 599, 599, 599, 599, 599, 599, 599, 599,
960 599, 599, 599, 599, 599, 599, 599, 599, 599, 599, 599, 599, 599, 599, 599, 599, 599, 599,
961 599, 599, 599, 599, 599, 599, 599, 599, 599, 599, 599, 599, 599, 599, 599, 599, 599, 599,
962 599, 599, 599, 599, 599, 599, 599, 599, 599, 599, 599, 599, 599, 599, 599, 599, 599, 599,
963 599, 599, 599, 599, 599, 599, 599, 599, 599, 599, 599, 599, 599, 599, 599, 599, 599, 599,
964 599, 599, 599, 599 ],
965 'Courier-Oblique' => [ 599, 599, 599, 599, 599, 599, 599, 599, 599, 599, 599, 599, 599, 599, 599, 599, 599, 599, 599, 599,
966 599, 599, 599, 599, 599, 599, 599, 599, 599, 599, 599, 599, 599, 599, 599, 599, 599, 599, 599, 599,
967 599, 599, 599, 599, 599, 599, 599, 599, 599, 599, 599, 599, 599, 599, 599, 599, 599, 599, 599, 599,
968 599, 599, 599, 599, 599, 599, 599, 599, 599, 599, 599, 599, 599, 599, 599, 599, 599, 599, 599, 599,
969 599, 599, 599, 599, 599, 599, 599, 599, 599, 599, 599, 599, 599, 599, 599, 599, 599, 599, 599, 599,
970 599, 599, 599, 599, 599, 599, 599, 599, 599, 599, 599, 599, 599, 599, 599, 599, 599, 599, 599, 599,
971 599, 599, 599, 599, 599, 599, 599, 599, 599, 599, 599, 599, 599, 599, 599, 599, 599, 599, 599, 599,
972 599, 599, 599, 599, 599, 599, 599, 599, 599, 599, 599, 599, 599, 599, 599, 599, 599, 599, 599, 599,
973 599, 599, 599, 599, 599, 599, 599, 599, 599, 599, 599, 599, 599, 599, 599, 599, 599, 599, 599, 599,
974 599, 599, 599, 599, 599, 599, 599, 599, 599, 599, 599, 599, 599, 599, 599, 599, 599, 599, 599, 599,
975 599, 599, 599, 599, 599, 599, 599, 599, 599, 599, 599, 599, 599, 599, 599, 599, 599, 599, 599, 599,
976 599, 599, 599, 599, 599, 599, 599, 599, 599, 599, 599, 599, 599, 599, 599, 599, 599, 599, 599, 599,
977 599, 599, 599, 599, 599, 599, 599, 599, 599, 599, 599, 599, 599, 599, 599, 599 ],
978 'Helvetica' => [ 277, 277, 277, 277, 277, 277, 277, 277, 277, 277, 277, 277, 277, 277, 277, 277, 277, 277,
979 277, 277, 277, 277, 277, 277, 277, 277, 277, 277, 277, 277, 277, 277, 277, 277, 354, 555,
980 555, 888, 666, 220, 332, 332, 388, 583, 277, 332, 277, 277, 555, 555, 555, 555, 555, 555,
981 555, 555, 555, 555, 277, 277, 583, 583, 583, 555, 1014, 666, 666, 721, 721, 666, 610, 777,
982 721, 277, 499, 666, 555, 832, 721, 777, 666, 777, 721, 666, 610, 721, 666, 943, 666, 666,
983 610, 277, 277, 277, 468, 555, 221, 555, 555, 499, 555, 555, 277, 555, 555, 221, 221, 499,
984 221, 832, 555, 555, 555, 555, 332, 499, 277, 555, 499, 721, 499, 499, 499, 333, 259, 333,
985 583, 277, 277, 277, 277, 277, 277, 277, 277, 277, 277, 277, 277, 277, 277, 277, 277, 277,
986 277, 277, 277, 277, 277, 277, 277, 277, 277, 277, 277, 277, 277, 277, 277, 277, 277, 332,
987 555, 555, 166, 555, 555, 555, 555, 190, 332, 555, 332, 332, 499, 499, 277, 555, 555, 555,
988 277, 277, 536, 349, 221, 332, 332, 555, 999, 999, 277, 610, 277, 332, 332, 332, 666, 332,
989 332, 332, 332, 277, 332, 332, 277, 332, 332, 332, 999, 277, 277, 277, 277, 277, 777, 277,
990 277, 277, 277, 277, 721, 277, 277, 610, 277, 999, 277, 369, 555, 277, 277, 277, 555, 777,
991 999, 364, 277, 277, 277, 277, 277, 888, 277, 277, 277, 277, 555, 277, 221, 610, 943, 610,
992 555, 277, 277, 277 ],
993 'Helvetica-Bold' => [ 277, 277, 277, 277, 277, 277, 277, 277, 277, 277, 277, 277, 277, 277, 277, 277, 277, 277, 277, 277,
994 277, 277, 277, 277, 277, 277, 277, 277, 277, 277, 277, 277, 277, 332, 473, 555, 555, 888, 721, 277,
995 332, 332, 388, 583, 277, 332, 277, 277, 555, 555, 555, 555, 555, 555, 555, 555, 555, 555, 332, 332,
996 583, 583, 583, 610, 974, 721, 721, 721, 721, 666, 610, 777, 721, 277, 555, 721, 610, 832, 721, 777,
997 666, 777, 721, 666, 610, 721, 666, 943, 666, 666, 610, 332, 277, 332, 583, 555, 277, 555, 610, 555,
998 610, 555, 332, 610, 610, 277, 277, 555, 277, 888, 610, 610, 610, 610, 388, 555, 332, 610, 555, 777,
999 555, 555, 499, 388, 279, 388, 583, 277, 277, 277, 277, 277, 277, 277, 277, 277, 277, 277, 277, 277,
1000 277, 277, 277, 277, 277, 277, 277, 277, 277, 277, 277, 277, 277, 277, 277, 277, 277, 277, 277, 277,
1001 277, 332, 555, 555, 166, 555, 555, 555, 555, 237, 499, 555, 332, 332, 610, 610, 277, 555, 555, 555,
1002 277, 277, 555, 349, 277, 499, 499, 555, 999, 999, 277, 610, 277, 332, 332, 332, 721, 332, 332, 332,
1003 332, 277, 332, 332, 277, 332, 332, 332, 999, 277, 277, 277, 277, 277, 777, 277, 277, 277, 277, 277,
1004 721, 277, 277, 610, 277, 999, 277, 369, 555, 277, 277, 277, 610, 777, 999, 364, 277, 277, 277, 277,
1005 277, 888, 277, 277, 277, 277, 610, 277, 277, 610, 943, 610, 610, 277, 277, 277 ],
1006 'Helvetica-BoldOblique' => [ 277, 277, 277, 277, 277, 277, 277, 277, 277, 277, 277, 277, 277, 277, 277, 277, 277, 277,
1007 277, 277, 277, 277, 277, 277, 277, 277, 277, 277, 277, 277, 277, 277, 277, 332, 473, 555,
1008 555, 888, 721, 277, 332, 332, 388, 583, 277, 332, 277, 277, 555, 555, 555, 555, 555, 555,
1009 555, 555, 555, 555, 332, 332, 583, 583, 583, 610, 974, 721, 721, 721, 721, 666, 610, 777,
1010 721, 277, 555, 721, 610, 832, 721, 777, 666, 777, 721, 666, 610, 721, 666, 943, 666, 666,
1011 610, 332, 277, 332, 583, 555, 277, 555, 610, 555, 610, 555, 332, 610, 610, 277, 277, 555,
1012 277, 888, 610, 610, 610, 610, 388, 555, 332, 610, 555, 777, 555, 555, 499, 388, 279, 388,
1013 583, 277, 277, 277, 277, 277, 277, 277, 277, 277, 277, 277, 277, 277, 277, 277, 277, 277,
1014 277, 277, 277, 277, 277, 277, 277, 277, 277, 277, 277, 277, 277, 277, 277, 277, 277, 332,
1015 555, 555, 166, 555, 555, 555, 555, 237, 499, 555, 332, 332, 610, 610, 277, 555, 555, 555,
1016 277, 277, 555, 349, 277, 499, 499, 555, 999, 999, 277, 610, 277, 332, 332, 332, 721, 332,
1017 332, 332, 332, 277, 332, 332, 277, 332, 332, 332, 999, 277, 277, 277, 277, 277, 777, 277,
1018 277, 277, 277, 277, 721, 277, 277, 610, 277, 999, 277, 369, 555, 277, 277, 277, 610, 777,
1019 999, 364, 277, 277, 277, 277, 277, 888, 277, 277, 277, 277, 610, 277, 277, 610, 943, 610,
1020 610, 277, 277, 277 ],
1021 'Helvetica-Oblique' => [ 277, 277, 277, 277, 277, 277, 277, 277, 277, 277, 277,
1022 277, 277, 277, 277, 277, 277, 277, 277, 277, 277, 277,
1023 277, 277, 277, 277, 277, 277, 277, 277, 277, 277, 277,
1024 277, 354, 555, 555, 888, 666, 221, 332, 332, 388, 583,
1025 277, 332, 277, 277, 555, 555, 555, 555, 555, 555, 555,
1026 555, 555, 555, 277, 277, 583, 583, 583, 555, 1014, 666,
1027 666, 721, 721, 666, 610, 777, 721, 277, 499, 666, 555,
1028 832, 721, 777, 666, 777, 721, 666, 610, 721, 666, 943,
1029 666, 666, 610, 277, 277, 277, 468, 555, 221, 555, 555,
1030 499, 555, 555, 277, 555, 555, 221, 221, 499, 221, 832,
1031 555, 555, 555, 555, 332, 499, 277, 555, 499, 721, 499,
1032 499, 499, 333, 259, 333, 583, 277, 277, 277, 277, 277,
1033 277, 277, 277, 277, 277, 277, 277, 277, 277, 277, 277,
1034 277, 277, 277, 277, 277, 277, 277, 277, 277, 277, 277,
1035 277, 277, 277, 277, 277, 277, 277, 332, 555, 555, 166,
1036 555, 555, 555, 555, 190, 332, 555, 332, 332, 499, 499,
1037 277, 555, 555, 555, 277, 277, 536, 349, 221, 332, 332,
1038 555, 999, 999, 277, 610, 277, 332, 332, 332, 666, 332,
1039 332, 332, 332, 277, 332, 332, 277, 332, 332, 332, 999,
1040 277, 277, 277, 277, 277, 777, 277, 277, 277, 277, 277,
1041 721, 277, 277, 610, 277, 999, 277, 369, 555, 277, 277,
1042 277, 555, 777, 999, 364, 277, 277, 277, 277, 277, 888,
1043 277, 277, 277, 277, 555, 277, 221, 610, 943, 610, 555,
1044 277, 277, 277 ],
1045 'Times-Bold' => [ 249, 249, 249, 249, 249, 249, 249, 249, 249, 249, 249, 249, 249, 249, 249, 249, 249, 249, 249, 249,
1046 249, 249, 249, 249, 249, 249, 249, 249, 249, 249, 249, 249, 249, 332, 554, 499, 499, 999, 832, 332,
1047 332, 332, 499, 569, 249, 332, 249, 277, 499, 499, 499, 499, 499, 499, 499, 499, 499, 499, 332, 332,
1048 569, 569, 569, 499, 929, 721, 666, 721, 721, 666, 610, 777, 777, 388, 499, 777, 666, 943, 721, 777,
1049 610, 777, 721, 555, 666, 721, 721, 999, 721, 721, 666, 332, 277, 332, 580, 499, 332, 499, 555, 443,
1050 555, 443, 332, 499, 555, 277, 332, 555, 277, 832, 555, 499, 555, 555, 443, 388, 332, 555, 499, 721,
1051 499, 499, 443, 393, 219, 393, 519, 249, 249, 249, 249, 249, 249, 249, 249, 249, 249, 249, 249, 249,
1052 249, 249, 249, 249, 249, 249, 249, 249, 249, 249, 249, 249, 249, 249, 249, 249, 249, 249, 249, 249,
1053 249, 332, 499, 499, 166, 499, 499, 499, 499, 277, 499, 499, 332, 332, 555, 555, 249, 499, 499, 499,
1054 249, 249, 539, 349, 332, 499, 499, 499, 999, 999, 249, 499, 249, 332, 332, 332, 721, 332, 332, 332,
1055 332, 249, 332, 332, 249, 332, 332, 332, 999, 249, 249, 249, 249, 249, 777, 249, 249, 249, 249, 249,
1056 721, 249, 249, 555, 249, 999, 249, 299, 499, 249, 249, 249, 666, 777, 999, 329, 249, 249, 249, 249,
1057 249, 721, 249, 249, 249, 277, 499, 249, 277, 499, 721, 555, 555, 249, 249, 249 ],
1058 'Times-BoldItalic' => [ 249, 249, 249, 249, 249, 249, 249, 249, 249, 249, 249, 249, 249, 249, 249, 249, 249, 249, 249, 249,
1059 249, 249, 249, 249, 249, 249, 249, 249, 249, 249, 249, 249, 249, 388, 554, 499, 499, 832, 777, 332,
1060 332, 332, 499, 569, 249, 332, 249, 277, 499, 499, 499, 499, 499, 499, 499, 499, 499, 499, 332, 332,
1061 569, 569, 569, 499, 831, 666, 666, 666, 721, 666, 666, 721, 777, 388, 499, 666, 610, 888, 721, 721,
1062 610, 721, 666, 555, 610, 721, 666, 888, 666, 610, 610, 332, 277, 332, 569, 499, 332, 499, 499, 443,
1063 499, 443, 332, 499, 555, 277, 277, 499, 277, 777, 555, 499, 499, 499, 388, 388, 277, 555, 443, 666,
1064 499, 443, 388, 347, 219, 347, 569, 249, 249, 249, 249, 249, 249, 249, 249, 249, 249, 249, 249, 249,
1065 249, 249, 249, 249, 249, 249, 249, 249, 249, 249, 249, 249, 249, 249, 249, 249, 249, 249, 249, 249,
1066 249, 388, 499, 499, 166, 499, 499, 499, 499, 277, 499, 499, 332, 332, 555, 555, 249, 499, 499, 499,
1067 249, 249, 499, 349, 332, 499, 499, 499, 999, 999, 249, 499, 249, 332, 332, 332, 666, 332, 332, 332,
1068 332, 249, 332, 332, 249, 332, 332, 332, 999, 249, 249, 249, 249, 249, 721, 249, 249, 249, 249, 249,
1069 721, 249, 249, 499, 249, 943, 249, 265, 499, 249, 249, 249, 610, 721, 943, 299, 249, 249, 249, 249,
1070 249, 721, 249, 249, 249, 277, 499, 249, 277, 499, 721, 499, 555, 249, 249, 249 ],
1071 'Times-Italic' => [ 249, 249, 249, 249, 249, 249, 249, 249, 249, 249, 249, 249, 249, 249, 249, 249, 249, 249, 249, 249,
1072 249, 249, 249, 249, 249, 249, 249, 249, 249, 249, 249, 249, 249, 332, 419, 499, 499, 832, 777, 332,
1073 332, 332, 499, 674, 249, 332, 249, 277, 499, 499, 499, 499, 499, 499, 499, 499, 499, 499, 332, 332,
1074 674, 674, 674, 499, 919, 610, 610, 666, 721, 610, 610, 721, 721, 332, 443, 666, 555, 832, 666, 721,
1075 610, 721, 610, 499, 555, 721, 610, 832, 610, 555, 555, 388, 277, 388, 421, 499, 332, 499, 499, 443,
1076 499, 443, 277, 499, 499, 277, 277, 443, 277, 721, 499, 499, 499, 499, 388, 388, 277, 499, 443, 666,
1077 443, 443, 388, 399, 274, 399, 540, 249, 249, 249, 249, 249, 249, 249, 249, 249, 249, 249, 249, 249,
1078 249, 249, 249, 249, 249, 249, 249, 249, 249, 249, 249, 249, 249, 249, 249, 249, 249, 249, 249, 249,
1079 249, 388, 499, 499, 166, 499, 499, 499, 499, 213, 555, 499, 332, 332, 499, 499, 249, 499, 499, 499,
1080 249, 249, 522, 349, 332, 555, 555, 499, 888, 999, 249, 499, 249, 332, 332, 332, 610, 332, 332, 332,
1081 332, 249, 332, 332, 249, 332, 332, 332, 888, 249, 249, 249, 249, 249, 721, 249, 249, 249, 249, 249,
1082 721, 249, 249, 499, 249, 888, 249, 275, 499, 249, 249, 249, 555, 721, 943, 309, 249, 249, 249, 249,
1083 249, 666, 249, 249, 249, 277, 499, 249, 277, 499, 666, 499, 499, 249, 249, 249 ],
1084 'Times-Roman' => [ 249, 249, 249, 249, 249, 249, 249, 249, 249, 249, 249, 249, 249, 249, 249, 249, 249, 249, 249, 249,
1085 249, 249, 249, 249, 249, 249, 249, 249, 249, 249, 249, 249, 249, 332, 407, 499, 499, 832, 777, 332,
1086 332, 332, 499, 563, 249, 332, 249, 277, 499, 499, 499, 499, 499, 499, 499, 499, 499, 499, 277, 277,
1087 563, 563, 563, 443, 920, 721, 666, 666, 721, 610, 555, 721, 721, 332, 388, 721, 610, 888, 721, 721,
1088 555, 721, 666, 555, 610, 721, 721, 943, 721, 721, 610, 332, 277, 332, 468, 499, 332, 443, 499, 443,
1089 499, 443, 332, 499, 499, 277, 277, 499, 277, 777, 499, 499, 499, 499, 332, 388, 277, 499, 499, 721,
1090 499, 499, 443, 479, 199, 479, 540, 249, 249, 249, 249, 249, 249, 249, 249, 249, 249, 249, 249, 249,
1091 249, 249, 249, 249, 249, 249, 249, 249, 249, 249, 249, 249, 249, 249, 249, 249, 249, 249, 249, 249,
1092 249, 332, 499, 499, 166, 499, 499, 499, 499, 179, 443, 499, 332, 332, 555, 555, 249, 499, 499, 499,
1093 249, 249, 452, 349, 332, 443, 443, 499, 999, 999, 249, 443, 249, 332, 332, 332, 721, 332, 332, 332,
1094 332, 249, 332, 332, 249, 332, 332, 332, 999, 249, 249, 249, 249, 249, 721, 249, 249, 249, 249, 249,
1095 721, 249, 249, 499, 249, 888, 249, 275, 443, 249, 249, 249, 610, 721, 888, 309, 249, 249, 249, 249,
1096 249, 666, 249, 249, 249, 277, 499, 249, 277, 499, 721, 499, 499, 249, 249, 249 ],
1097 'Symbol' => [ 250, 250, 250, 250, 250, 250, 250, 250, 250, 250, 250, 250, 250, 250, 250, 250, 250, 250, 250, 250,
1098 250, 250, 250, 250, 250, 250, 250, 250, 250, 250, 250, 250, 250, 333, 713, 500, 549, 833, 778, 439,
1099 333, 333, 500, 549, 250, 549, 250, 278, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 278, 278,
1100 549, 549, 549, 444, 549, 722, 667, 722, 612, 611, 763, 603, 722, 333, 631, 722, 686, 889, 722, 722,
1101 768, 741, 556, 592, 611, 690, 439, 768, 645, 795, 611, 333, 863, 333, 658, 500, 500, 631, 549, 549,
1102 494, 439, 521, 411, 603, 329, 603, 549, 549, 576, 521, 549, 549, 521, 549, 603, 439, 576, 713, 686,
1103 493, 686, 494, 480, 200, 480, 549, 250, 250, 250, 250, 250, 250, 250, 250, 250, 250, 250, 250, 250,
1104 250, 250, 250, 250, 250, 250, 250, 250, 250, 250, 250, 250, 250, 250, 250, 250, 250, 250, 250, 250,
1105 250, 620, 247, 549, 167, 713, 500, 753, 753, 753, 753, 1042, 987, 603, 987, 603, 400, 549, 411, 549,
1106 549, 713, 494, 460, 549, 549, 549, 549, 1000, 603, 1000, 658, 823, 686, 795, 987, 768, 768, 823, 768,
1107 768, 713, 713, 713, 713, 713, 713, 713, 768, 713, 790, 790, 890, 823, 549, 250, 713, 603, 603, 1042,
1108 987, 603, 987, 603, 494, 329, 790, 790, 786, 713, 384, 384, 384, 384, 384, 384, 494, 494, 494, 494,
1109 250, 329, 274, 686, 686, 686, 384, 384, 384, 384, 384, 384, 494, 494, 494, 250 ],
1110 };
1111 }
1112  
1113 #
1114 #
1115 # PRIVATE METHODS
1116  
1117 sub _get_text ($$) {
1118 0 ▶ my ($words, $num_words) = @_;
Subroutine _get_text: not called CC=2 SCAR=17.9
1119  
1120 0 ▶ if (scalar @$words < $num_words) { die @_ };
Branch: 1 branch
BranchTrueFalseTotal
if (scalar @$words < $num_words) 0 0 0
1121  
1122 0 return join(' ', map { $$words[$_] } (0..($num_words-1)));
1123 }
1124  
1125 =head1 AUTHORS
1126  
1127 Fabien Tassin
1128  
1129 GIF and JPEG-support: Michael Gross (info@mdgrosse.net)
1130  
1131 Maintenance since 2007: Markus Baertschi (markus@markus.org)
1132  
1133 =head1 REPOSITORY
1134  
1135 L<https://github.com/manwar/pdf-create>
1136  
1137 =head1 COPYRIGHT
1138  
1139 Copyright 1999-2001,Fabien Tassin.All rights reserved.It may be used and modified
1140 freely, but I do request that this copyright notice remain attached to the file.
1141 You may modify this module as you wish,but if you redistribute a modified version,
1142 please attach a note listing the modifications you have made.
1143  
1144 Copyright 2007 Markus Baertschi
1145  
1146 Copyright 2010 Gary Lieberman
1147  
1148 =head1 LICENSE
1149  
1150 This is free software; you can redistribute it and / or modify it under the same
1151 terms as Perl 5.6.0.
1152  
1153 =cut
1154  
1155 18 1;
« Image/JPEG.pm ↑ Summary Image/GIF.pm »