Builder/Lite.pm

filter: Statementstmt 29.7% 49 / 165 Branchbran 21.4% 3 / 14 Conditioncond 0.0% 0 / 9 MC/DCmcdc 0.0% 0 / 6 Subroutinesub 28.0% 14 / 50 Podpod 100% 41 / 41 totaltotal 37.5% 107 / 285 CC 12 SCAR 18.5
CC
12
Cov
28%
saveas
36.0
print
12.0
text
6.0
CRAP 6.3
« Builder/Basic/PDF/String.pm ↑ Summary Builder/Resource/ColorSpace/Indexed/WebColor.pm »
1 package PDF::Builder::Lite;
2  
3 2 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 2 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
5  
6 2 our $VERSION = '3.028'; # VERSION
7 2 our $LAST_UPDATE = '3.026'; # manually update whenever code is changed
8 # NOTE that this sub-package has not been tested and is not well documented!
9 # It is possible that it will be deprecated and removed.
10  
11 BEGIN {
12  
13 2 ▶ use PDF::Builder;
Subroutine BEGIN: called CC=1 SCAR=0.0
14 2 ▶ use PDF::Builder::Util;
Subroutine BEGIN: called CC=1 SCAR=0.0
15 2 ▶ use PDF::Builder::Basic::PDF::Utils;
Subroutine BEGIN: called CC=1 SCAR=0.0
16  
17 2 ▶ use POSIX qw( ceil floor );
Subroutine BEGIN: called CC=1 SCAR=0.0
18 2 ▶ use Scalar::Util qw(blessed);
Subroutine BEGIN: called CC=1 SCAR=0.0
19  
20 2 ▶ use vars qw( $hasWeakRef );
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: not called CC=1 SCAR=0.0
21  
22 }
23  
24 =head1 NAME
25  
26 PDF::Builder::Lite - Lightweight PDF creation methods (UNMAINTAINED)
27  
28 =head1 SYNOPSIS
29  
30 $pdf = PDF::Builder::Lite->new();
31 $pdf->page(595,842);
32 $img = $pdf->image('some.jpg');
33 $font = $pdf->corefont('Times-Roman');
34 $font = $pdf->ttfont('TimesNewRoman.ttf');
35  
36 =head1 DESCRIPTION
37  
38 =======================================================================
39  
40 This class is unmaintained (since 2007) and should not be used in new code. It
41 combines many of the methods from L<PDF::Builder> and L<PDF::Builder::Content>
42 into a single class but isn't really otherwise any easier to use.
43  
44 There have been many improvements and clarifications made to the rest of the
45 distribution that aren't reflected here, so the term "Lite" no longer applies.
46 It remains solely for compatibility with existing legacy code.
47  
48 B<As it is unmaintained, we I<strongly> suggest that you not use "Lite". If
49 you have old applications that make use of it, we suggest that you consider
50 upgrading them to use current, supported, PDF::Builder facilities. Although
51 we try to maintain backwards compatibility for calls made by "Lite", there is
52 no guarantee that something may break when called by "Lite"!>
53  
54 =======================================================================
55  
56 =head1 METHODS
57  
58 =head2 new
59  
60 $pdf = PDF::Builder::Lite->new(%opts)
61  
62 $pdf = PDF::Builder::Lite->new()
63  
64 =cut
65  
66 3 ▶sub new {
Subroutine new: called CC=1 SCAR=0.0
Pod documented
67 3 my ($class, %opts) = @_;
68  
69 3 my $self = {};
70 3 bless($self, $class);
71 3 $self->{'api'} = PDF::Builder->new(%opts);
72  
73 3 return $self;
74 }
75  
76 =head2 page
77  
78 $pdf->page()
79  
80 $pdf->page($width,$height)
81  
82 $pdf->page($llx,$lly, $urx,$ury)
83  
84 =over
85  
86 Opens a new page.
87  
88 =back
89  
90 =cut
91  
92 1 ▶sub page {
Subroutine page: called CC=2 SCAR=7.0
Pod documented
93 1 my $self = shift();
94 1 $self->{'page'} = $self->{'api'}->page();
95 1 ▶ $self->{'page'}->mediabox(@_) if $_[0];
Branch: 1 branch
BranchTrueFalseTotal
if $_[0] 0 1 1
96 1 $self->{'gfx'} = $self->{'page'}->gfx();
97 # $self->{'gfx'}->compressFlate();
98 1 return $self;
99 }
100  
101 =head2 mediabox
102  
103 $pdf->mediabox($w,$h)
104  
105 $pdf->mediabox($llx,$lly, $urx,$ury)
106  
107 =over
108  
109 Sets the global mediabox.
110  
111 =back
112  
113 =cut
114  
115 1 ▶sub mediabox {
Subroutine mediabox: called CC=2 SCAR=7.4
Pod documented
116 1 my ($self, $x1,$y1, $x2,$y2) = @_;
117 1 ▶ if (defined $x2) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $x2) { } 0 1 1
118 0 $self->{'api'}->mediabox($x1,$y1, $x2,$y2);
119 } else {
120 1 $self->{'api'}->mediabox($x1,$y1);
121 }
122 1 return $self;
123 }
124  
125 =head2 saveas
126  
127 $pdf->saveas($file)
128  
129 =over
130  
131 Saves the document (may B<not> be modified later) and
132 deallocates the PDF structures.
133  
134 If C<$file> is just a hyphen '-', the stringified copy is returned, otherwise
135 the file is saved, and C<$self> is returned (for chaining calls).
136  
137 =back
138  
139 =cut
140  
141 1 ▶sub saveas {
Subroutine saveas: called CC=7 SCAR=35.8
Pod documented
142 1 my ($self, $file) = @_;
143  
144 1 ▶ if ($file eq '-') {
Branch: 1 branch
BranchTrueFalseTotal
if ($file eq '-') { } 1 0 1
145 1 return $self->{'api'}->to_string();
146 } else {
147 0 $self->{'api'}->saveas($file);
148 0 return $self;
149 }
150 # is the following code ever reached? - Phil
151 #$self->{'api'}->end();
152 0 foreach my $k (keys %{$self}) {
153 0 ▶ if (blessed($k) and $k->can('release')) {
Branch: 2 branches
BranchTrueFalseTotal
if (builtin::blessed($k) and $k->can('release')) { } 0 0 0
elsif (builtin::blessed($k) and $k->can('end')) { } 0 0 0
Condition0%0/3
builtin::blessed($k) and $k->can("release")
!ll&&!rl&&r
000
MC/DC0%0/2
builtin::blessed($k) and $k->can("release")
builtin::blessed($k) $k->can("release")
Truth table0%0/3
A and B
A= builtin::blessed($k)B= $k->can("release")
ABresult
0X0
100
111
154 0 $k->release(1);
155 ▶ } elsif (blessed($k) and $k->can('end')) {
Condition0%0/3
builtin::blessed($k) and $k->can("end")
!ll&&!rl&&r
000
MC/DC0%0/2
builtin::blessed($k) and $k->can("end")
builtin::blessed($k) $k->can("end")
Truth table0%0/3
A and B
A= builtin::blessed($k)B= $k->can("end")
ABresult
0X0
100
111
156 0 $k->end();
157 }
158 0 $self->{$k} = undef;
159 0 delete($self->{$k});
160 }
161 0 return;
162 }
163  
164 =head2 corefont
165  
166 $font = $pdf->corefont($fontname)
167  
168 =over
169  
170 Returns a new or existing Adobe core font object.
171  
172 B<Examples:>
173  
174 $font = $pdf->corefont('Times-Roman');
175 $font = $pdf->corefont('Times-Bold');
176 $font = $pdf->corefont('Helvetica');
177 $font = $pdf->corefont('ZapfDingbats');
178  
179 =back
180  
181 =cut
182  
183 4 ▶sub corefont {
Subroutine corefont: called CC=1 SCAR=0.0
Pod documented
184 4 my ($self, $name, @opts) = @_;
185  
186 4 my $obj = $self->{'api'}->corefont($name, @opts);
187 4 return $obj;
188 }
189  
190 =head2 ttfont
191  
192 $font = $pdf->ttfont($ttfile)
193  
194 =over
195  
196 Returns a new or existing TrueType font object.
197  
198 B<Examples:>
199  
200 $font = $pdf->ttfont('TimesNewRoman.ttf');
201 $font = $pdf->ttfont('/fonts/Univers-Bold.ttf');
202 $font = $pdf->ttfont('../Democratica-SmallCaps.ttf');
203  
204 =back
205  
206 =cut
207  
208 0 ▶sub ttfont {
Subroutine ttfont: not called CC=1 SCAR=6.9
Pod documented
209 0 my ($self, $file, @opts) = @_;
210  
211 0 return $self->{'api'}->ttfont($file, @opts);
212 }
213  
214 =head2 psfont
215  
216 $font = $pdf->psfont($ps_file, %options)
217  
218 $font = $pdf->psfont($ps_file)
219  
220 =over
221  
222 Returns a new Type1 (PS) font object.
223  
224 B<Examples:>
225  
226 $font = $pdf->psfont('TimesRoman.pfa', 'afmfile' => 'TimesRoman.afm', 'encode' => 'latin1');
227 $font = $pdf->psfont('/fonts/Univers.pfb', 'pfmfile' => '/fonts/Univers.pfm', 'encode' => 'latin2');
228  
229 =back
230  
231 =cut
232  
233 0 ▶sub psfont {
Subroutine psfont: not called CC=1 SCAR=6.9
Pod documented
234 0 my ($self, @args) = @_;
235  
236 0 return $self->{'api'}->psfont(@args);
237 }
238  
239 #=head2 color
240 #
241 # @color = $pdf->color($colornumber [, $lightdark ])
242 #
243 # @color = $pdf->color($basecolor [, $lightdark ])
244 #
245 #=over
246 #
247 #Returns a color.
248 #
249 #B<Examples:>
250 #
251 # @color = $pdf->color(0); # 50% grey
252 # @color = $pdf->color(0,+4); # 10% grey
253 # @color = $pdf->color(0,-3); # 80% grey
254 # @color = $pdf->color('yellow'); # yellow, fully saturated
255 # @color = $pdf->color('red',+1); # red, +10% white
256 # @color = $pdf->color('green',-2); # green, +20% black
257 #
258 #=back
259 #
260 #=cut
261 #
262 #sub color {
263 # my $self = shift();
264 #
265 # return $self->{'api'}->businesscolor(@_);
266 #}
267  
268 =head2 create_egs
269  
270 $egs = $pdf->create_egs()
271  
272 =over
273  
274 Returns a new extended-graphics-state object.
275  
276 B<Examples:>
277  
278 $egs = $pdf->create_egs();
279  
280 =back
281  
282 =cut
283  
284 1 ▶sub create_egs {
Subroutine create_egs: called CC=1 SCAR=0.0
Pod documented
285 1 my ($self) = @_;
286  
287 1 return $self->{'api'}->egstate();
288 }
289  
290 =head2 image_jpeg
291  
292 $img = $pdf->image_jpeg($file)
293  
294 =over
295  
296 Returns a new JPEG image object.
297  
298 =back
299  
300 =cut
301  
302 0 ▶sub image_jpeg {
Subroutine image_jpeg: not called CC=1 SCAR=6.9
Pod documented
303 0 my ($self, $file) = @_;
304  
305 0 return $self->{'api'}->image_jpeg($file);
306 }
307  
308 =head2 image_png
309  
310 $img = $pdf->image_png($file)
311  
312 =over
313  
314 Returns a new PNG image object.
315  
316 =back
317  
318 =cut
319  
320 0 ▶sub image_png {
Subroutine image_png: not called CC=1 SCAR=6.9
Pod documented
321 0 my ($self, $file) = @_;
322  
323 0 return $self->{'api'}->image_png($file);
324 }
325  
326 =head2 image_tiff
327  
328 $img = $pdf->image_tiff($file, %opts)
329  
330 $img = $pdf->image_tiff($file)
331  
332 =over
333  
334 Returns a new TIFF image object.
335  
336 =back
337  
338 =cut
339  
340 0 ▶sub image_tiff {
Subroutine image_tiff: not called CC=1 SCAR=6.9
Pod documented
341 0 my ($self, $file, @opts) = @_;
342  
343 0 return $self->{'api'}->image_tiff($file, @opts);
344 }
345  
346 =head2 image_pnm
347  
348 $img = $pdf->image_pnm($file)
349  
350 =over
351  
352 Returns a new PNM image object.
353  
354 =back
355  
356 =cut
357  
358 0 ▶sub image_pnm {
Subroutine image_pnm: not called CC=1 SCAR=6.9
Pod documented
359 0 my ($self, $file) = @_;
360  
361 0 return $self->{'api'}->image_pnm($file);
362 }
363  
364 =head2 savestate
365  
366 $pdf->savestate()
367  
368 =over
369  
370 Saves the state of the page.
371  
372 =back
373  
374 =cut
375  
376 0 ▶sub savestate {
Subroutine savestate: not called CC=1 SCAR=6.9
Pod documented
377 0 my $self = shift();
378  
379 0 return $self->{'gfx'}->save();
380 }
381  
382 =head2 restorestate
383  
384 $pdf->restorestate()
385  
386 =over
387  
388 Restores the state of the page.
389  
390 =back
391  
392 =cut
393  
394 0 ▶sub restorestate {
Subroutine restorestate: not called CC=1 SCAR=6.9
Pod documented
395 0 my $self = shift();
396  
397 0 return $self->{'gfx'}->restore();
398 }
399  
400 =head2 egstate
401  
402 $pdf->egstate($egs)
403  
404 =over
405  
406 Sets extended-graphics state.
407  
408 =back
409  
410 =cut
411  
412 0 ▶sub egstate {
Subroutine egstate: not called CC=1 SCAR=6.9
Pod documented
413 0 my $self = shift();
414  
415 0 $self->{'gfx'}->egstate(@_);
416 0 return $self;
417 }
418  
419 =head2 fillcolor
420  
421 $pdf->fillcolor($color)
422  
423 =over
424  
425 Sets the fill color. See C<strokecolor> for color names and specifications.
426  
427 =back
428  
429 =cut
430  
431 0 ▶sub fillcolor {
Subroutine fillcolor: not called CC=1 SCAR=6.9
Pod documented
432 0 my $self = shift();
433  
434 0 $self->{'gfx'}->fillcolor(@_);
435 0 return $self;
436 }
437  
438 =head2 strokecolor
439  
440 $pdf->strokecolor($color)
441  
442 =over
443  
444 Sets the stroke color.
445  
446 B<Defined color-names are:>
447  
448 aliceblue, antiquewhite, aqua, aquamarine, azure, beige, bisque, black, blanchedalmond,
449 blue, blueviolet, brown, burlywood, cadetblue, chartreuse, chocolate, coral, cornflowerblue,
450 cornsilk, crimson, cyan, darkblue, darkcyan, darkgoldenrod, darkgray, darkgreen, darkgrey,
451 darkkhaki, darkmagenta, darkolivegreen, darkorange, darkorchid, darkred, darksalmon,
452 darkseagreen, darkslateblue, darkslategray, darkslategrey, darkturquoise, darkviolet,
453 deeppink, deepskyblue, dimgray, dimgrey, dodgerblue, firebrick, floralwhite, forestgreen,
454 fuchsia, gainsboro, ghostwhite, gold, goldenrod, gray, grey, green, greenyellow, honeydew,
455 hotpink, indianred, indigo, ivory, khaki, lavender, lavenderblush, lawngreen, lemonchiffon,
456 lightblue, lightcoral, lightcyan, lightgoldenrodyellow, lightgray, lightgreen, lightgrey,
457 lightpink, lightsalmon, lightseagreen, lightskyblue, lightslategray, lightslategrey,
458 lightsteelblue, lightyellow, lime, limegreen, linen, magenta, maroon, mediumaquamarine,
459 mediumblue, mediumorchid, mediumpurple, mediumseagreen, mediumslateblue, mediumspringgreen,
460 mediumturquoise, mediumvioletred, midnightblue, mintcream, mistyrose, moccasin, navajowhite,
461 navy, oldlace, olive, olivedrab, orange, orangered, orchid, palegoldenrod, palegreen,
462 paleturquoise, palevioletred, papayawhip, peachpuff, peru, pink, plum, powderblue, purple,
463 red, rosybrown, royalblue, saddlebrown, salmon, sandybrown, seagreen, seashell, sienna,
464 silver, skyblue, slateblue, slategray, slategrey, snow, springgreen, steelblue, tan, teal,
465 thistle, tomato, turquoise, violet, wheat, white, whitesmoke, yellow, yellowgreen
466  
467 or the rgb-hex-notation:
468  
469 #rgb, #rrggbb, #rrrgggbbb and #rrrrggggbbbb
470  
471 or the cmyk-hex-notation:
472  
473 %cmyk, %ccmmyykk, %cccmmmyyykkk and %ccccmmmmyyyykkkk
474  
475 or the hsl-hex-notation:
476  
477 &hsl, &hhssll, &hhhssslll and &hhhhssssllll
478  
479 or the hsv-hex-notation:
480  
481 !hsv, !hhssvv, !hhhsssvvv and !hhhhssssvvvv
482  
483 =back
484  
485 =cut
486  
487 0 ▶sub strokecolor {
Subroutine strokecolor: not called CC=1 SCAR=6.9
Pod documented
488 0 my $self = shift();
489  
490 0 $self->{'gfx'}->strokecolor(@_);
491 0 return $self;
492 }
493  
494 =head2 linedash
495  
496 $pdf->linedash(@dash)
497  
498 =over
499  
500 Sets the line dash pattern.
501  
502 =back
503  
504 =cut
505  
506 0 ▶sub linedash {
Subroutine linedash: not called CC=1 SCAR=6.9
Pod documented
507 0 my ($self, @a) = @_;
508 0 $self->{'gfx'}->linedash(@a);
509 0 return $self;
510 }
511  
512 =head2 linewidth
513  
514 $pdf->linewidth($width)
515  
516 =over
517  
518 Sets the line width.
519  
520 =back
521  
522 =cut
523  
524 0 ▶sub linewidth {
Subroutine linewidth: not called CC=1 SCAR=6.9
Pod documented
525 0 my ($self, $linewidth) = @_;
526  
527 0 $self->{'gfx'}->linewidth($linewidth);
528 0 return $self;
529 }
530  
531 =head2 transform
532  
533 $pdf->transform(%opts)
534  
535 =over
536  
537 Sets transformations (i.e., translate, rotate, scale, skew) in PDF-canonical order.
538  
539 B<Example:>
540  
541 $pdf->transform(
542 'translate' => [$x,$y],
543 'rotate' => $rot,
544 'scale' => [$sx,$sy],
545 'skew' => [$sa,$sb],
546 )
547  
548 =back
549  
550 =cut
551  
552 0 ▶sub transform {
Subroutine transform: not called CC=1 SCAR=6.9
Pod documented
553 0 my ($self, %opt) = @_;
554  
555 0 $self->{'gfx'}->transform(%opt);
556 0 return $self;
557 }
558  
559 =head2 move
560  
561 $pdf->move($x,$y)
562  
563 =over
564  
565 Move to a new drawing location at C[$x,$y].
566  
567 =back
568  
569 =cut
570  
571 0 ▶sub move { # x,y ...
Subroutine move: not called CC=1 SCAR=6.9
Pod documented
572 0 my $self = shift();
573  
574 0 $self->{'gfx'}->move(@_);
575 0 return $self;
576 }
577  
578 =head2 line
579  
580 $pdf->line($x,$y)
581  
582 =over
583  
584 Draw a line to C[$x,$y].
585  
586 =back
587  
588 =cut
589  
590 0 ▶sub line { # x,y ...
Subroutine line: not called CC=1 SCAR=6.9
Pod documented
591 0 my $self = shift();
592  
593 0 $self->{'gfx'}->line(@_);
594 0 return $self;
595 }
596  
597 =head2 curve
598  
599 $pdf->curve($x1,$y1, $x2,$y2, $x3,$y3)
600  
601 =over
602  
603 Draw a Bezier curve with three control points.
604  
605 =back
606  
607 =cut
608  
609 0 ▶sub curve { # x1,y1,x2,y2,x3,y3 ...
Subroutine curve: not called CC=1 SCAR=6.9
Pod documented
610 0 my $self = shift();
611 0 $self->{'gfx'}->curve(@_);
612 0 return $self;
613 }
614  
615 =head2 arc
616  
617 $pdf->arc($xc,$yc, $rx,$ry, $alpha,$beta, $move, $dir)
618  
619 $pdf->arc($xc,$yc, $rx,$ry, $alpha,$beta, $move)
620  
621 =over
622  
623 Draw an arc centered at C[$xc,$yc], with x radius C[$rx] and y radius C[$ry],
624 from C[$alpha] degrees to C[$beta] degrees. If C[$move] is I<true>, do B<not>
625 draw a line to the start of the arc. C[$dir] defaults to 0 for counter-clockwise
626 sweep, and may be set to 1 for a clockwise sweep.
627  
628 =back
629  
630 =cut
631  
632 0 ▶sub arc { # xc,yc, rx,ry, alpha,beta ,move [,dir]
Subroutine arc: not called CC=1 SCAR=6.9
Pod documented
633 0 my $self = shift();
634  
635 0 $self->{'gfx'}->arc(@_);
636 0 return $self;
637 }
638  
639 =head2 ellipse
640  
641 $pdf->ellipse($xc,$yc, $rx,$ry)
642  
643 =over
644  
645 Draw an ellipse centered at C[$xc,$yc], with x radius C[$rx] and y radius C[$ry].
646  
647 =back
648  
649 =cut
650  
651 0 ▶sub ellipse {
Subroutine ellipse: not called CC=1 SCAR=6.9
Pod documented
652 0 my $self = shift();
653  
654 0 $self->{'gfx'}->ellipse(@_);
655 0 return $self;
656 }
657  
658 =head2 circle
659  
660 $pdf->circle($xc,$yc, $r)
661  
662 =over
663  
664 Draw a circle centered at C[$xc,$yc], of radius C[$r].
665  
666 =back
667  
668 =cut
669  
670 0 ▶sub circle {
Subroutine circle: not called CC=1 SCAR=6.9
Pod documented
671 0 my $self = shift();
672  
673 0 $self->{'gfx'}->circle(@_);
674 0 return $self;
675 }
676  
677 =head2 rect
678  
679 $pdf->rect($x,$y, $w,$h)
680  
681 =over
682  
683 Draw a rectangle with lower left corner at C[$x,$y], width (+x) C[$w] and
684 height (+y) C[$h].
685  
686 =back
687  
688 =cut
689  
690 0 ▶sub rect { # x,y, w,h ...
Subroutine rect: not called CC=1 SCAR=6.9
Pod documented
691 0 my $self = shift();
692  
693 0 $self->{'gfx'}->rect(@_);
694 0 return $self;
695 }
696  
697 =head2 rectxy
698  
699 $pdf->rectxy($x1,$y1, $x2,$y2)
700  
701 =over
702  
703 Draw a rectangle with opposite corners C[$x1,$y1] and C[$x2,$y2].
704  
705 =back
706  
707 =cut
708  
709 0 ▶sub rectxy {
Subroutine rectxy: not called CC=1 SCAR=6.9
Pod documented
710 0 my $self = shift();
711  
712 0 $self->{'gfx'}->rectxy(@_);
713 0 return $self;
714 }
715  
716 =head2 poly
717  
718 $pdf->poly($x1,$y1, ..., $xn,$yn)
719  
720 =over
721  
722 Draw a polyline (multiple line segments) starting at (I<move> to) C[$x1,$y1] and
723 continuing on to C[$x2,$y2], ..., C[$xn,$yn].
724  
725 =back
726  
727 =cut
728  
729 0 ▶sub poly {
Subroutine poly: not called CC=1 SCAR=6.9
Pod documented
730 0 my $self = shift();
731  
732 0 $self->{'gfx'}->poly(@_);
733 0 return $self;
734 }
735  
736 =head2 close
737  
738 $pdf->close()
739  
740 =over
741  
742 Close a shape (draw a line back to the beginning).
743  
744 =back
745  
746 =cut
747  
748 0 ▶sub close {
Subroutine close: not called CC=1 SCAR=6.9
Pod documented
749 0 my $self = shift();
750  
751 0 $self->{'gfx'}->close();
752 0 return $self;
753 }
754  
755 =head2 stroke
756  
757 $pdf->stroke()
758  
759 =over
760  
761 Stroke (actually draw) a shape whose path has already been laid out, using
762 the requested C<strokecolor>.
763  
764 =back
765  
766 =cut
767  
768 0 ▶sub stroke {
Subroutine stroke: not called CC=1 SCAR=6.9
Pod documented
769 0 my $self = shift();
770  
771 0 $self->{'gfx'}->stroke();
772 0 return $self;
773 }
774  
775 =head2 fill
776  
777 $pdf->fill()
778  
779 =over
780  
781 Fill in a closed geometry (path), using the requested C<fillcolor>.
782 The I<non-zero winding rule> is used if the path crosses itself.
783  
784 =back
785  
786 =cut
787  
788 0 ▶sub fill { # nonzero winding rule
Subroutine fill: not called CC=1 SCAR=6.9
Pod documented
789 0 my $self = shift();
790  
791 0 $self->{'gfx'}->fill();
792 0 return $self;
793 }
794  
795 =head2 fillstroke
796  
797 $pdf->fillstroke()
798  
799 =over
800  
801 Fill (using C<fillcolor>) I<and> stroke (using C<strokecolor>) a closed path.
802 The I<non-zero winding rule> is used if the path crosses itself.
803  
804 =back
805  
806 =cut
807  
808 0 ▶sub fillstroke { # nonzero winding rule
Subroutine fillstroke: not called CC=1 SCAR=6.9
Pod documented
809 0 my $self = shift();
810  
811 0 $self->{'gfx'}->fillstroke();
812 0 return $self;
813 }
814  
815 =head2 image
816  
817 $pdf->image($imgobj, $x,$y, $w,$h)
818  
819 $pdf->image($imgobj, $x,$y, $scale)
820  
821 $pdf->image($imgobj, $x,$y)
822  
823 =over
824  
825 B<Please Note:> The width/height or scale given
826 is in user-space coordinates, which are subject to
827 transformations which may have been specified beforehand.
828  
829 Per default this has a 72dpi resolution, so if you want an
830 image to have a 150 or 300dpi resolution, you should specify
831 a scale of 72/150 (or 72/300) or adjust width/height accordingly.
832  
833 =back
834  
835 =cut
836  
837 0 ▶sub image {
Subroutine image: not called CC=1 SCAR=6.9
Pod documented
838 0 my $self = shift();
839  
840 0 $self->{'gfx'}->image(@_);
841 0 return $self;
842 }
843  
844 =head2 textstart
845  
846 $pdf->textstart()
847  
848 =over
849  
850 Forces the start of text mode while in graphics.
851  
852 =back
853  
854 =cut
855  
856 0 ▶sub textstart {
Subroutine textstart: not called CC=1 SCAR=6.9
Pod documented
857 0 my $self = shift();
858  
859 0 $self->{'gfx'}->textstart();
860 0 return $self;
861 }
862  
863 =head2 textfont
864  
865 $pdf->textfont($fontobj, $size)
866  
867 =over
868  
869 Define the current font to be an (already defined) font object at the given size.
870  
871 =back
872  
873 =cut
874  
875 0 ▶sub textfont {
Subroutine textfont: not called CC=1 SCAR=6.9
Pod documented
876 0 my $self = shift();
877  
878 0 $self->{'gfx'}->font(@_);
879 0 return $self;
880 }
881  
882 =head2 textleading
883  
884 $txt->textleading($leading)
885  
886 =over
887  
888 Set the baseline-to-baseline "leading" to be used for text lines.
889  
890 =back
891  
892 =cut
893  
894 0 ▶sub textleading {
Subroutine textleading: not called CC=1 SCAR=6.9
Pod documented
895 0 my $self = shift();
896  
897 0 $self->{'gfx'}->leading(@_);
898 0 return $self;
899 }
900  
901 =head2 text
902  
903 $pdf->text($string)
904  
905 =over
906  
907 Applies (writes out) the given text at the current text location, using the
908 already-specified font.
909  
910 =back
911  
912 =cut
913  
914 0 ▶sub text {
Subroutine text: not called CC=2 SCAR=17.9
Pod documented
915 0 my $self = shift();
916  
917 0 ▶ return $self->{'gfx'}->text(@_) || $self;
Condition0%0/3
$self->{'gfx'}->text(@_) || $self
l!l&&r!l&&!r
000
MC/DC0%0/2
$self->{'gfx'}->text(@_) || $self
$self->{'gfx'}->text(@_) $self
Truth table0%0/3
A || B
A= $self->{'gfx'}->text(@_)B= $self
ABresult
1X1
011
000
918 }
919  
920 =head2 nl
921  
922 $pdf->nl()
923  
924 =over
925  
926 Write a newline (drop down to the next line).
927  
928 =back
929  
930 =cut
931  
932 0 ▶sub nl {
Subroutine nl: not called CC=1 SCAR=6.9
Pod documented
933 0 my $self = shift();
934  
935 0 $self->{'gfx'}->nl();
936 0 return $self;
937 }
938  
939 =head2 textend
940  
941 $pdf->textend()
942  
943 =over
944  
945 Force an end to text output and return to graphics.
946  
947 =back
948  
949 =cut
950  
951 0 ▶sub textend {
Subroutine textend: not called CC=1 SCAR=6.9
Pod documented
952 0 my $self = shift();
953  
954 0 $self->{'gfx'}->textend();
955 0 return $self;
956 }
957  
958 =head2 print
959  
960 $pdf->print($font, $size, $x,$y, $rot, $just, $text)
961  
962 =over
963  
964 Convenience wrapper for shortening the textstart..textend sequence.
965  
966 Go into text mode, set the font to the object and size, go to the location,
967 set any rotation, set justification, and write the array of text.
968 Justification is 0 for left, 1 for center, and 2 for right.
969  
970 =back
971  
972 =cut
973  
974 0 ▶sub print {
Subroutine print: not called CC=3 SCAR=24.8
Pod documented
975 0 my $self = shift();
976 0 my ($font, $size, $x,$y, $rot, $just, @text) = @_;
977  
978 0 my $text = join(' ', @text);
979 0 $self->textstart();
980 0 $self->textfont($font, $size);
981 0 $self->transform(
982 'translate' => [$x, $y],
983 'rotate' => $rot,
984 );
985 0 ▶ if ($just==1) {
Branch: 2 branches
BranchTrueFalseTotal
if ($just == 1) { } 0 0 0
elsif ($just == 2) { } 0 0 0
986 0 $self->{'gfx'}->text_center($text);
987 } elsif ($just==2) {
988 0 $self->{'gfx'}->text_right($text);
989 } else {
990 0 $self->text(@text);
991 }
992 0 $self->textend();
993 0 return $self;
994 }
995  
996 2 1;
997  
998 __END__
« Builder/Basic/PDF/String.pm ↑ Summary Builder/Resource/ColorSpace/Indexed/WebColor.pm »