/usr/local/perl/lib/site_perl/5.8.5/PDF/API2/Content.pm |
Returns a new content object (called from $page->text/gfx).
Example:
$co->transform( -translate => [$x,$y], -rotate => $rot, -scale => [$sx,$sy], -skew => [$sa,$sb], )
Examples:
$co->fillcolor('blue'); # blue $co->strokecolor('#FF0000'); # red $co->fillcolor('%FFF000000'); # cyan
Per default this has a 72dpi resolution, so if you want an image to have a 150 or 300dpi resolution, you should specify a scale of 72/150 (or 72/300) or adjust width/height accordingly.
Note: This is relative to text-space.
Example:
$txt->transform_rel( -translate => [$x,$y], -rotate => $rot, -scale => [$sx,$sy], -skew => [$sa,$sb], )
Only use fontset if you know what you are doing, there is no super-secret failsave!
Options
-underline=>[2,1,4,2]
will draw a double underline
with the lower twice as thick as the upper).
If thickness is a reference to an array, the first value is the thickness
and the second value is the color of the line (ie.,
-underline=>[2,[1,'red'],4,[2,'#0000ff']]
will draw a ``red'' and a
``blue'' line).
You can also use the string 'auto'
for either or both distance and thickness
values to auto-magically calculate best values from the font-definition.
Apply the text within the rectangle and return any leftover text.
Options
Example:
$txt->font($font,$fontsize); $txt->lead($lead); $txt->translate($x,$y); $overflow = $txt->paragraph( 'long paragraph here ...', $width, $y+$lead-$bottom_margin );
Split paragraphs by newline and loop over them, reassemble leftovers when box is full and apply the text within the rectangle and return any leftover text.
Example:
$t = $page->gfx; $t->textlabel(300,700,$myfont,20,'Page Header', -rotate => -30, -color => '#FF0000', -hspace => 120, -align => 'center', ); $t->textlabel(500,500,$myfont,20,'Page Header', -rotate => 30, -color => '#0000FF', -hspace => 80, -align => 'right', ); =cut
sub textlabel { my ($self,$x,$y,$font,$size,$text,%opts,$wht) = @_; my %trans_opts=( -translate => [$x,$y] ); my %text_state=(); $trans_opts{-rotate} = $opts{-rotate} if($opts{-rotate});
my $wastext = $self->{' apiistext'}; if($wastext) { %text_state=$self->textstate; $self->textend; } $self->save; $self->textstart; $self->transform(%trans_opts); $self->fillcolor(ref($opts{-color}) ? @{$opts{-color}} : $opts{-color}) if($opts{-color}); $self->strokecolor(ref($opts{-strokecolor}) ? @{$opts{-strokecolor}} : $opts{-strokecolor}) if($opts{-strokecolor});
$self->font($font,$size);
$self->charspace($opts{-charspace}) if($opts{-charspace}); $self->hspace($opts{-hspace}) if($opts{-hspace}); $self->wordspace($opts{-wordspace}) if($opts{-wordspace}); $self->render($opts{-render}) if($opts{-render});
if($opts{-right} || $opts{-align}=~/^r/i) { $wht = $self->text_right($text,%opts); } elsif($opts{-center} || $opts{-align}=~/^c/i) { $wht = $self->text_center($text,%opts); } else { $wht = $self->text($text,%opts); } $self->textend; $self->restore; if($wastext) { $self->textstart; $self->textstate(%text_state); } return($wht); }
sub resource { my ($self, $type, $key, $obj, $force) = @_; if($self->{' apipage'}) { # we are a content stream on a page. return( $self->{' apipage'}->resource($type, $key, $obj, $force) ); } else { # we are a self-contained content stream. $self->{Resources}||=PDFDict();
my $dict=$self->{Resources}; $dict->realise if(ref($dict)=~/Objind$/);
$dict->{$type}||= PDFDict(); $dict->{$type}->realise if(ref($dict->{$type})=~/Objind$/); unless (defined $obj) { return($dict->{$type}->{$key} || undef); } else { if($force) { $dict->{$type}->{$key}=$obj; } else { $dict->{$type}->{$key}||=$obj; } return($dict); } } }
1;
__END__
alfred reibenschuh
/usr/local/perl/lib/site_perl/5.8.5/PDF/API2/Content.pm |