« API3/Compat/API2/Resource/XObject/Image.pm
↑ Summary
API3/Compat/API2/Basic/TTF/Kern/OrderedList.pm »
| 1 | #======================================================================= | ||
| 2 | # ____ ____ _____ _ ____ ___ ____ | ||
| 3 | # | _ \| _ \| ___| _ _ / \ | _ \_ _| |___ \ | ||
| 4 | # | |_) | | | | |_ (_) (_) / _ \ | |_) | | __) | | ||
| 5 | # | __/| |_| | _| _ _ / ___ \| __/| | / __/ | ||
| 6 | # |_| |____/|_| (_) (_) /_/ \_\_| |___| |_____| | ||
| 7 | # | ||
| 8 | # A Perl Module Chain to faciliate the Creation and Modification | ||
| 9 | # of High-Quality "Portable Document Format (PDF)" Files. | ||
| 10 | # | ||
| 11 | # Copyright 1999-2005 Alfred Reibenschuh <areibens@cpan.org>. | ||
| 12 | # | ||
| 13 | #======================================================================= | ||
| 14 | # | ||
| 15 | # This library is free software; you can redistribute it and/or | ||
| 16 | # modify it under the terms of the GNU Lesser General Public | ||
| 17 | # License as published by the Free Software Foundation; either | ||
| 18 | # version 2 of the License, or (at your option) any later version. | ||
| 19 | # | ||
| 20 | # This library is distributed in the hope that it will be useful, | ||
| 21 | # but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
| 22 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | ||
| 23 | # Lesser General Public License for more details. | ||
| 24 | # | ||
| 25 | # You should have received a copy of the GNU Lesser General Public | ||
| 26 | # License along with this library; if not, write to the | ||
| 27 | # Free Software Foundation, Inc., 59 Temple Place - Suite 330, | ||
| 28 | # Boston, MA 02111-1307, USA. | ||
| 29 | # | ||
| 30 | # $Id: Lite.pm,v 2.1 2007/05/08 18:32:09 areibens Exp $ | ||
| 31 | # | ||
| 32 | #======================================================================= | ||
| 33 | |||
| 34 | package PDF::API3::Compat::API2::Lite; | ||
| 35 | |||
| 36 | BEGIN { | ||
| 37 | |||
| 38 | use PDF::API3::Compat::API2; | ||
| 39 | use PDF::API3::Compat::API2::Util; | ||
| 40 | use PDF::API3::Compat::API2::Basic::PDF::Utils; | ||
| 41 | |||
| 42 | use POSIX qw( ceil floor ); | ||
| 43 | |||
| 44 | use vars qw( $VERSION $hasWeakRef ); | ||
| 45 | |||
| 46 | ( $VERSION ) = sprintf '%i.%03i', split(/\./,('$Revision: 2.1 $' =~ /Revision: (\S+)\s/)[0]); # $Date: 2007/05/08 18:32:09 $ | ||
| 47 | |||
| 48 | } | ||
| 49 | |||
| 50 | no warnings qw[ deprecated recursion uninitialized ]; | ||
| 51 | |||
| 52 | |||
| 53 | =head1 NAME | ||
| 54 | |||
| 55 | PDF::API3::Compat::API2::Lite - lite pdf creation | ||
| 56 | |||
| 57 | =head1 SYNOPSIS | ||
| 58 | |||
| 59 | $pdf = PDF::API3::Compat::API2::Lite->new; | ||
| 60 | $pdf->page(595,842); | ||
| 61 | $img = $pdf->image('some.jpg'); | ||
| 62 | $font = $pdf->corefont('Times-Roman'); | ||
| 63 | $font = $pdf->ttfont('TimesNewRoman.ttf'); | ||
| 64 | |||
| 65 | =head1 METHODS | ||
| 66 | |||
| 67 | =head2 PDF::API3::Compat::API2::Lite | ||
| 68 | |||
| 69 | =item $pdf = PDF::API::Lite->new | ||
| 70 | |||
| 71 | =cut | ||
| 72 | |||
| 73 | sub new { | ||
| 74 | my $class=shift(@_); | ||
| 75 | my %opt=@_; | ||
| 76 | my $self={}; | ||
| 77 | bless($self,$class); | ||
| 78 | $self->{api}=PDF::API3::Compat::API2->new(@_); | ||
| 79 | return $self; | ||
| 80 | } | ||
| 81 | |||
| 82 | =item $pdf->page | ||
| 83 | |||
| 84 | =item $pdf->page $width,$height | ||
| 85 | |||
| 86 | =item $pdf->page $llx, $lly, $urx, $ury | ||
| 87 | |||
| 88 | Opens a new page. | ||
| 89 | |||
| 90 | =cut | ||
| 91 | |||
| 92 | sub page { | ||
| 93 | my $self=shift; | ||
| 94 | $self->{page}=$self->{api}->page; | ||
| 95 | $self->{page}->mediabox(@_) if($_[0]); | ||
| 96 | $self->{gfx}=$self->{page}->gfx; | ||
| 97 | # $self->{gfx}->compressFlate; | ||
| 98 | return $self; | ||
| 99 | } | ||
| 100 | |||
| 101 | |||
| 102 | =item $pdf->mediabox $w, $h | ||
| 103 | |||
| 104 | =item $pdf->mediabox $llx, $lly, $urx, $ury | ||
| 105 | |||
| 106 | Sets the global mediabox. | ||
| 107 | |||
| 108 | =cut | ||
| 109 | |||
| 110 | sub mediabox { | ||
| 111 | my ($self,$x1,$y1,$x2,$y2) = @_; | ||
| 112 | if(defined $x2) { | ||
| 113 | $self->{api}->mediabox($x1,$y1,$x2,$y2); | ||
| 114 | } else { | ||
| 115 | $self->{api}->mediabox($x1,$y1); | ||
| 116 | } | ||
| 117 | $self; | ||
| 118 | } | ||
| 119 | |||
| 120 | =item $pdf->saveas $file | ||
| 121 | |||
| 122 | Saves the document (may not be modified later) and | ||
| 123 | deallocates the pdf-structures. | ||
| 124 | |||
| 125 | =cut | ||
| 126 | |||
| 127 | sub saveas { | ||
| 128 | my ($self,$file)=@_; | ||
| 129 | if($file eq '-') { | ||
| 130 | return $self->{api}->stringify; | ||
| 131 | } else { | ||
| 132 | $self->{api}->saveas($file); | ||
| 133 | return $self; | ||
| 134 | } | ||
| 135 | $self->{api}->end; | ||
| 136 | foreach my $k (keys %{$self}) { | ||
| 137 | if(UNIVERSAL::can($k,'release')) { | ||
| 138 | $k->release(1); | ||
| 139 | } elsif(UNIVERSAL::can($k,'end')) { | ||
| 140 | $k->end; | ||
| 141 | } | ||
| 142 | $self->{$k}=undef; | ||
| 143 | delete($self->{$k}); | ||
| 144 | } | ||
| 145 | return undef; | ||
| 146 | } | ||
| 147 | |||
| 148 | |||
| 149 | =item $font = $pdf->corefont $fontname | ||
| 150 | |||
| 151 | Returns a new or existing adobe core font object. | ||
| 152 | |||
| 153 | B<Examples:> | ||
| 154 | |||
| 155 | $font = $pdf->corefont('Times-Roman'); | ||
| 156 | $font = $pdf->corefont('Times-Bold'); | ||
| 157 | $font = $pdf->corefont('Helvetica'); | ||
| 158 | $font = $pdf->corefont('ZapfDingbats'); | ||
| 159 | |||
| 160 | =cut | ||
| 161 | |||
| 162 | sub corefont { | ||
| 163 | my ($self,$name,@opts)=@_; | ||
| 164 | my $obj=$self->{api}->corefont($name,@opts); | ||
| 165 | return $obj; | ||
| 166 | } | ||
| 167 | |||
| 168 | =item $font = $pdf->ttfont $ttfile | ||
| 169 | |||
| 170 | Returns a new or existing truetype font object. | ||
| 171 | |||
| 172 | B<Examples:> | ||
| 173 | |||
| 174 | $font = $pdf->ttfont('TimesNewRoman.ttf'); | ||
| 175 | $font = $pdf->ttfont('/fonts/Univers-Bold.ttf'); | ||
| 176 | $font = $pdf->ttfont('../Democratica-SmallCaps.ttf'); | ||
| 177 | |||
| 178 | =cut | ||
| 179 | |||
| 180 | sub ttfont { | ||
| 181 | my ($self,$file,@opts)=@_; | ||
| 182 | return $self->{api}->ttfont($file,@opts); | ||
| 183 | } | ||
| 184 | |||
| 185 | =item $font = $pdf->psfont $pfb, $afm, $encoding | ||
| 186 | |||
| 187 | Returns a new type1 font object. | ||
| 188 | |||
| 189 | B<Examples:> | ||
| 190 | |||
| 191 | $font = $pdf->psfont('TimesRoman.pfb','TimesRoman.afm','latin1'); | ||
| 192 | $font = $pdf->psfont('/fonts/Univers.pfb','/fonts/Univers.afm','latin2'); | ||
| 193 | |||
| 194 | =cut | ||
| 195 | |||
| 196 | sub psfont { | ||
| 197 | my ($self,@args)=@_; | ||
| 198 | return $self->{api}->psfont(@args); | ||
| 199 | } | ||
| 200 | |||
| 201 | #=item @color = $pdf->color $colornumber [, $lightdark ] | ||
| 202 | # | ||
| 203 | #=item @color = $pdf->color $basecolor [, $lightdark ] | ||
| 204 | # | ||
| 205 | #Returns a color. | ||
| 206 | # | ||
| 207 | #B<Examples:> | ||
| 208 | # | ||
| 209 | # @color = $pdf->color(0); # 50% grey | ||
| 210 | # @color = $pdf->color(0,+4); # 10% grey | ||
| 211 | # @color = $pdf->color(0,-3); # 80% grey | ||
| 212 | # @color = $pdf->color('yellow'); # yellow, fully saturated | ||
| 213 | # @color = $pdf->color('red',+1); # red, +10% white | ||
| 214 | # @color = $pdf->color('green',-2); # green, +20% black | ||
| 215 | # | ||
| 216 | #=cut | ||
| 217 | # | ||
| 218 | #sub color { | ||
| 219 | # my $self=shift @_; | ||
| 220 | # return $self->{api}->businesscolor(@_); | ||
| 221 | #} | ||
| 222 | |||
| 223 | =item $egs = $pdf->create_egs | ||
| 224 | |||
| 225 | Returns a new extended-graphics-state object. | ||
| 226 | |||
| 227 | B<Examples:> | ||
| 228 | |||
| 229 | $egs = $pdf->create_egs; | ||
| 230 | |||
| 231 | =cut | ||
| 232 | |||
| 233 | sub create_egs { | ||
| 234 | my ($self)=@_; | ||
| 235 | return $self->{api}->extgstate; | ||
| 236 | } | ||
| 237 | |||
| 238 | =item $img = $pdf->image_jpeg $file | ||
| 239 | |||
| 240 | Returns a new jpeg-image object. | ||
| 241 | |||
| 242 | =cut | ||
| 243 | |||
| 244 | sub image_jpeg { | ||
| 245 | my ($self,$file)=@_; | ||
| 246 | return $self->{api}->image_jpeg($file); | ||
| 247 | } | ||
| 248 | |||
| 249 | =item $img = $pdf->image_png $file | ||
| 250 | |||
| 251 | Returns a new png-image object. | ||
| 252 | |||
| 253 | =cut | ||
| 254 | |||
| 255 | sub image_png { | ||
| 256 | my ($self,$file)=@_; | ||
| 257 | return $self->{api}->image_png($file); | ||
| 258 | } | ||
| 259 | |||
| 260 | =item $img = $pdf->image_tiff $file | ||
| 261 | |||
| 262 | Returns a new tiff-image object. | ||
| 263 | |||
| 264 | =cut | ||
| 265 | |||
| 266 | sub image_tiff { | ||
| 267 | my ($self,$file)=@_; | ||
| 268 | return $self->{api}->image_tiff($file); | ||
| 269 | } | ||
| 270 | |||
| 271 | =item $img = $pdf->image_pnm $file | ||
| 272 | |||
| 273 | Returns a new pnm-image object. | ||
| 274 | |||
| 275 | =cut | ||
| 276 | |||
| 277 | sub image_pnm { | ||
| 278 | my ($self,$file)=@_; | ||
| 279 | return $self->{api}->image_pnm($file); | ||
| 280 | } | ||
| 281 | |||
| 282 | =item $pdf->savestate | ||
| 283 | |||
| 284 | Saves the state of the page. | ||
| 285 | |||
| 286 | =cut | ||
| 287 | |||
| 288 | sub savestate { | ||
| 289 | my $self=shift @_; | ||
| 290 | $self->{gfx}->save; | ||
| 291 | } | ||
| 292 | |||
| 293 | =item $pdf->restorestate | ||
| 294 | |||
| 295 | Restores the state of the page. | ||
| 296 | |||
| 297 | =cut | ||
| 298 | |||
| 299 | sub restorestate { | ||
| 300 | my $self=shift @_; | ||
| 301 | $self->{gfx}->restore; | ||
| 302 | } | ||
| 303 | |||
| 304 | =item $pdf->egstate $egs | ||
| 305 | |||
| 306 | Sets extended-graphics-state. | ||
| 307 | |||
| 308 | =cut | ||
| 309 | |||
| 310 | sub egstate { | ||
| 311 | my $self=shift @_; | ||
| 312 | $self->{gfx}->egstate(@_); | ||
| 313 | return($self); | ||
| 314 | } | ||
| 315 | |||
| 316 | =item $pdf->fillcolor $color | ||
| 317 | |||
| 318 | Sets fillcolor. | ||
| 319 | |||
| 320 | =cut | ||
| 321 | |||
| 322 | sub fillcolor { | ||
| 323 | my $self=shift @_; | ||
| 324 | $self->{gfx}->fillcolor(@_); | ||
| 325 | return($self); | ||
| 326 | } | ||
| 327 | |||
| 328 | =item $pdf->strokecolor $color | ||
| 329 | |||
| 330 | Sets strokecolor. | ||
| 331 | |||
| 332 | B<Defined color-names are:> | ||
| 333 | |||
| 334 | aliceblue, antiquewhite, aqua, aquamarine, azure, beige, bisque, black, blanchedalmond, | ||
| 335 | blue, blueviolet, brown, burlywood, cadetblue, chartreuse, chocolate, coral, cornflowerblue, | ||
| 336 | cornsilk, crimson, cyan, darkblue, darkcyan, darkgoldenrod, darkgray, darkgreen, darkgrey, | ||
| 337 | darkkhaki, darkmagenta, darkolivegreen, darkorange, darkorchid, darkred, darksalmon, | ||
| 338 | darkseagreen, darkslateblue, darkslategray, darkslategrey, darkturquoise, darkviolet, | ||
| 339 | deeppink, deepskyblue, dimgray, dimgrey, dodgerblue, firebrick, floralwhite, forestgreen, | ||
| 340 | fuchsia, gainsboro, ghostwhite, gold, goldenrod, gray, grey, green, greenyellow, honeydew, | ||
| 341 | hotpink, indianred, indigo, ivory, khaki, lavender, lavenderblush, lawngreen, lemonchiffon, | ||
| 342 | lightblue, lightcoral, lightcyan, lightgoldenrodyellow, lightgray, lightgreen, lightgrey, | ||
| 343 | lightpink, lightsalmon, lightseagreen, lightskyblue, lightslategray, lightslategrey, | ||
| 344 | lightsteelblue, lightyellow, lime, limegreen, linen, magenta, maroon, mediumaquamarine, | ||
| 345 | mediumblue, mediumorchid, mediumpurple, mediumseagreen, mediumslateblue, mediumspringgreen, | ||
| 346 | mediumturquoise, mediumvioletred, midnightblue, mintcream, mistyrose, moccasin, navajowhite, | ||
| 347 | navy, oldlace, olive, olivedrab, orange, orangered, orchid, palegoldenrod, palegreen, | ||
| 348 | paleturquoise, palevioletred, papayawhip, peachpuff, peru, pink, plum, powderblue, purple, | ||
| 349 | red, rosybrown, royalblue, saddlebrown, salmon, sandybrown, seagreen, seashell, sienna, | ||
| 350 | silver, skyblue, slateblue, slategray, slategrey, snow, springgreen, steelblue, tan, teal, | ||
| 351 | thistle, tomato, turquoise, violet, wheat, white, whitesmoke, yellow, yellowgreen | ||
| 352 | |||
| 353 | or the rgb-hex-notation: | ||
| 354 | |||
| 355 | #rgb, #rrggbb, #rrrgggbbb and #rrrrggggbbbb | ||
| 356 | |||
| 357 | or the cmyk-hex-notation: | ||
| 358 | |||
| 359 | %cmyk, %ccmmyykk, %cccmmmyyykkk and %ccccmmmmyyyykkkk | ||
| 360 | |||
| 361 | or the hsl-hex-notation: | ||
| 362 | |||
| 363 | &hsl, &hhssll, &hhhssslll and &hhhhssssllll | ||
| 364 | |||
| 365 | and additionally the hsv-hex-notation: | ||
| 366 | |||
| 367 | !hsv, !hhssvv, !hhhsssvvv and !hhhhssssvvvv | ||
| 368 | |||
| 369 | =cut | ||
| 370 | |||
| 371 | sub strokecolor { | ||
| 372 | my $self=shift @_; | ||
| 373 | $self->{gfx}->strokecolor(@_); | ||
| 374 | return($self); | ||
| 375 | } | ||
| 376 | |||
| 377 | =item $pdf->linedash @dash | ||
| 378 | |||
| 379 | Sets linedash. | ||
| 380 | |||
| 381 | =cut | ||
| 382 | |||
| 383 | sub linedash { | ||
| 384 | my ($self,@a)=@_; | ||
| 385 | $self->{gfx}->linedash(@a); | ||
| 386 | return($self); | ||
| 387 | } | ||
| 388 | |||
| 389 | =item $pdf->linewidth $width | ||
| 390 | |||
| 391 | Sets linewidth. | ||
| 392 | |||
| 393 | =cut | ||
| 394 | |||
| 395 | sub linewidth { | ||
| 396 | my ($self,$linewidth)=@_; | ||
| 397 | $self->{gfx}->linewidth($linewidth); | ||
| 398 | return($self); | ||
| 399 | } | ||
| 400 | |||
| 401 | =item $pdf->transform %opts | ||
| 402 | |||
| 403 | Sets transformations (eg. translate, rotate, scale, skew) in pdf-canonical order. | ||
| 404 | |||
| 405 | B<Example:> | ||
| 406 | |||
| 407 | $pdf->transform( | ||
| 408 | -translate => [$x,$y], | ||
| 409 | -rotate => $rot, | ||
| 410 | -scale => [$sx,$sy], | ||
| 411 | -skew => [$sa,$sb], | ||
| 412 | ) | ||
| 413 | |||
| 414 | =cut | ||
| 415 | |||
| 416 | sub transform { | ||
| 417 | my ($self,%opt)=@_; | ||
| 418 | $self->{gfx}->transform(%opt); | ||
| 419 | return($self); | ||
| 420 | } | ||
| 421 | |||
| 422 | =item $pdf->move $x, $y | ||
| 423 | |||
| 424 | =cut | ||
| 425 | |||
| 426 | sub move { # x,y ... | ||
| 427 | my $self=shift @_; | ||
| 428 | $self->{gfx}->move(@_); | ||
| 429 | return($self); | ||
| 430 | } | ||
| 431 | |||
| 432 | =item $pdf->line $x, $y | ||
| 433 | |||
| 434 | =cut | ||
| 435 | |||
| 436 | sub line { # x,y ... | ||
| 437 | my $self=shift @_; | ||
| 438 | $self->{gfx}->line(@_); | ||
| 439 | return($self); | ||
| 440 | } | ||
| 441 | |||
| 442 | =item $pdf->curve $x1, $y1, $x2, $y2, $x3, $y3 | ||
| 443 | |||
| 444 | =cut | ||
| 445 | |||
| 446 | sub curve { # x1,y1,x2,y2,x3,y3 ... | ||
| 447 | my $self=shift @_; | ||
| 448 | $self->{gfx}->curve(@_); | ||
| 449 | return($self); | ||
| 450 | } | ||
| 451 | |||
| 452 | =item $pdf->arc $x, $y, $a, $b, $alfa, $beta, $move | ||
| 453 | |||
| 454 | =cut | ||
| 455 | |||
| 456 | sub arc { # x,y,a,b,alf,bet[,mov] | ||
| 457 | my $self=shift @_; | ||
| 458 | $self->{gfx}->arc(@_); | ||
| 459 | return($self); | ||
| 460 | } | ||
| 461 | |||
| 462 | =item $pdf->ellipse $x, $y, $a, $b | ||
| 463 | |||
| 464 | =cut | ||
| 465 | |||
| 466 | sub ellipse { | ||
| 467 | my $self=shift @_; | ||
| 468 | $self->{gfx}->ellipse(@_); | ||
| 469 | return($self); | ||
| 470 | } | ||
| 471 | |||
| 472 | =item $pdf->circle $x, $y, $r | ||
| 473 | |||
| 474 | =cut | ||
| 475 | |||
| 476 | sub circle { | ||
| 477 | my $self=shift @_; | ||
| 478 | $self->{gfx}->circle(@_); | ||
| 479 | return($self); | ||
| 480 | } | ||
| 481 | |||
| 482 | =item $pdf->rect $x,$y, $w,$h | ||
| 483 | |||
| 484 | =cut | ||
| 485 | |||
| 486 | sub rect { # x,y,w,h ... | ||
| 487 | my $self=shift @_; | ||
| 488 | $self->{gfx}->rect(@_); | ||
| 489 | return($self); | ||
| 490 | } | ||
| 491 | |||
| 492 | =item $pdf->rectxy $x1,$y1, $x2,$y2 | ||
| 493 | |||
| 494 | =cut | ||
| 495 | |||
| 496 | sub rectxy { | ||
| 497 | my $self=shift @_; | ||
| 498 | $self->{gfx}->rectxy(@_); | ||
| 499 | return($self); | ||
| 500 | } | ||
| 501 | |||
| 502 | =item $pdf->poly $x1,$y1, ..., $xn,$yn | ||
| 503 | |||
| 504 | =cut | ||
| 505 | |||
| 506 | sub poly { | ||
| 507 | my $self=shift @_; | ||
| 508 | $self->{gfx}->poly(@_); | ||
| 509 | return($self); | ||
| 510 | } | ||
| 511 | |||
| 512 | =item $pdf->close | ||
| 513 | |||
| 514 | =cut | ||
| 515 | |||
| 516 | sub close { | ||
| 517 | my $self=shift @_; | ||
| 518 | $self->{gfx}->close; | ||
| 519 | return($self); | ||
| 520 | } | ||
| 521 | |||
| 522 | =item $pdf->stroke | ||
| 523 | |||
| 524 | =cut | ||
| 525 | |||
| 526 | sub stroke { | ||
| 527 | my $self=shift @_; | ||
| 528 | $self->{gfx}->stroke; | ||
| 529 | return($self); | ||
| 530 | } | ||
| 531 | |||
| 532 | =item $pdf->fill | ||
| 533 | |||
| 534 | =cut | ||
| 535 | |||
| 536 | sub fill { # nonzero | ||
| 537 | my $self=shift @_; | ||
| 538 | $self->{gfx}->fill; | ||
| 539 | return($self); | ||
| 540 | } | ||
| 541 | |||
| 542 | =item $pdf->fillstroke | ||
| 543 | |||
| 544 | =cut | ||
| 545 | |||
| 546 | sub fillstroke { # nonzero | ||
| 547 | my $self=shift @_; | ||
| 548 | $self->{gfx}->fillstroke; | ||
| 549 | return($self); | ||
| 550 | } | ||
| 551 | |||
| 552 | =item $pdf->image $imgobj, $x,$y, $w,$h | ||
| 553 | |||
| 554 | =item $pdf->image $imgobj, $x,$y, $scale | ||
| 555 | |||
| 556 | =item $pdf->image $imgobj, $x,$y | ||
| 557 | |||
| 558 | B<Please Note:> The width/height or scale given | ||
| 559 | is in user-space coordinates which is subject to | ||
| 560 | transformations which may have been specified beforehand. | ||
| 561 | |||
| 562 | Per default this has a 72dpi resolution, so if you want an | ||
| 563 | image to have a 150 or 300dpi resolution, you should specify | ||
| 564 | a scale of 72/150 (or 72/300) or adjust width/height accordingly. | ||
| 565 | |||
| 566 | =cut | ||
| 567 | |||
| 568 | sub image { | ||
| 569 | my $self=shift @_; | ||
| 570 | $self->{gfx}->image(@_); | ||
| 571 | return($self); | ||
| 572 | } | ||
| 573 | |||
| 574 | =item $pdf->textstart | ||
| 575 | |||
| 576 | =cut | ||
| 577 | |||
| 578 | sub textstart { | ||
| 579 | my $self=shift @_; | ||
| 580 | $self->{gfx}->textstart; | ||
| 581 | return($self); | ||
| 582 | } | ||
| 583 | |||
| 584 | =item $pdf->textfont $fontobj,$size | ||
| 585 | |||
| 586 | =cut | ||
| 587 | |||
| 588 | sub textfont { | ||
| 589 | my $self=shift @_; | ||
| 590 | $self->{gfx}->font(@_); | ||
| 591 | return($self); | ||
| 592 | } | ||
| 593 | |||
| 594 | =item $txt->textlead $leading | ||
| 595 | |||
| 596 | =cut | ||
| 597 | |||
| 598 | sub textlead { | ||
| 599 | my $self=shift @_; | ||
| 600 | $self->{gfx}->lead(@_); | ||
| 601 | return($self); | ||
| 602 | } | ||
| 603 | |||
| 604 | =item $pdf->text $string | ||
| 605 | |||
| 606 | Applys the given text. | ||
| 607 | |||
| 608 | =cut | ||
| 609 | |||
| 610 | sub text { | ||
| 611 | my $self=shift @_; | ||
| 612 | return $self->{gfx}->text(@_)||$self; | ||
| 613 | } | ||
| 614 | |||
| 615 | =item $pdf->nl | ||
| 616 | |||
| 617 | =cut | ||
| 618 | |||
| 619 | sub nl { | ||
| 620 | my $self=shift @_; | ||
| 621 | $self->{gfx}->nl; | ||
| 622 | return($self); | ||
| 623 | } | ||
| 624 | |||
| 625 | =item $pdf->textend | ||
| 626 | |||
| 627 | =cut | ||
| 628 | |||
| 629 | sub textend { | ||
| 630 | my $self=shift @_; | ||
| 631 | $self->{gfx}->textend; | ||
| 632 | return($self); | ||
| 633 | } | ||
| 634 | |||
| 635 | =item $pdf->print $font, $size, $x, $y, $rot, $just, $text | ||
| 636 | |||
| 637 | Convenience wrapper for shortening the textstart..textend sequence. | ||
| 638 | |||
| 639 | =cut | ||
| 640 | |||
| 641 | sub print { | ||
| 642 | my $self=shift @_; | ||
| 643 | my ($font, $size, $x, $y, $rot, $just, @text)=@_; | ||
| 644 | my $text=join(' ',@text); | ||
| 645 | $self->textstart; | ||
| 646 | $self->textfont($font, $size); | ||
| 647 | $self->transform( | ||
| 648 | -translate=>[$x, $y], | ||
| 649 | -rotate=> $rot, | ||
| 650 | ); | ||
| 651 | if($just==1) { | ||
| 652 | $self->{gfx}->text_center($text); | ||
| 653 | } elsif($just==2) { | ||
| 654 | $self->{gfx}->text_right($text); | ||
| 655 | } else { | ||
| 656 | $self->text(@text); | ||
| 657 | } | ||
| 658 | $self->textend; | ||
| 659 | return($self); | ||
| 660 | } | ||
| 661 | |||
| 662 | 1; | ||
| 663 | |||
| 664 | __END__ |