Help-Site Computer Manuals
Software
Hardware
Programming
Networking
  Algorithms & Data Structures   Programming Languages   Revision Control
  Protocols
  Cameras   Computers   Displays   Keyboards & Mice   Motherboards   Networking   Printers & Scanners   Storage
  Windows   Linux & Unix   Mac

/var/sites/help-site.com/auto/tmp/CPAN/9677/PDF-API2-0.68/lib/PDF/API2/Content.pm

/var/sites/help-site.com/auto/tmp/CPAN/9677/PDF-API2-0.68/lib/PDF/API2/Content.pm


$co = PDF::API2::Content->new @parameters

Returns a new content object (called from $page->text/gfx).

$co->add @content
Adds @content to the object.

$co->save
Saves the state of the object.

$co->restore
Restores the state of the object.

$co->compressFlate
Marks content for compression on output.

$co->flatness $flat
Sets flatness.

$co->linecap $cap
Sets linecap.

$co->linedash @dash
Sets linedash.

$co->linejoin $join
Sets linejoin.

$co->linewidth $width
Sets linewidth.

$co->meterlimit $limit
Sets meterlimit.

$co->matrix $a,$b,$c,$d,$e,$f
Sets matrix transformation.

$co->translate $x,$y
Sets translation transformation.

$co->scale $sx,$sy
Sets scaleing transformation.

$co->skew $sa,$sb
Sets skew transformation.

$co->rotate $rot
Sets rotation transformation.

$co->transform %opts
Sets transformations (eg. translate, rotate, scale, skew) in pdf-canonical order.

Example:


    $co->transform(

        -translate => [$x,$y],

        -rotate    => $rot,

        -scale     => [$sx,$sy],

        -skew      => [$sa,$sb],

    )

$co->fillcolor @colors
$co->strokecolor @colors
Sets fill-/strokecolor, see PDF::API2::Util for a list of possible color specifiers.

Examples:


    $co->fillcolor('blue');       # blue

    $co->strokecolor('#FF0000');  # red

    $co->fillcolor('%FFF000000'); # cyan


GRAPHICS METHODS

$gfx->move $x, $y
$gfx->line $x, $y
$gfx->hline $x
$gfx->vline $y
$gfx->curve $cx1, $cy1, $cx2, $cy2, $x, $y
$gfx->spline $cx1, $cy1, $x, $y
$gfx->arc $x, $y, $a, $b, $alfa, $beta, $move
will draw an arc centered at x,y with minor/major-axis given by a,b from alfa to beta (degrees). move must be set to 1, unless you want to continue an existing path.

$gfx->ellipse $x, $y, $a, $b
$gfx->circle $x, $y, $r
$gfx->bogen $x1, $y1, $x2, $y2, $r, $move, $larc, $span
will draw an arc of a circle from x1,y1 to x2,y2 with radius r. move must be set to 1, unless you want to continue an existing path. larc can be set to 1, if you want to draw the larger instead of the shorter arc. span can be set to 1, if you want to draw the arc on the other side. NOTE: 2*r cannot be smaller than the distance from x1,y1 to x2,y2.

$gfx->pie $x, $y, $a, $b, $alfa, $beta
$gfx->rect $x1,$y1, $w1,$h1, ..., $xn,$yn, $wn,$hn
$gfx->rectxy $x1,$y1, $x2,$y2
$gfx->poly $x1,$y1, ..., $xn,$yn
$gfx->close
$gfx->endpath
$gfx->clip $nonzero
$gfx->stroke
$gfx->fill $nonzero
$gfx->fillstroke $nonzero
$gfx->image $imgobj, $x,$y, $w,$h
$gfx->image $imgobj, $x,$y, $scale
$gfx->image $imgobj, $x,$y
Please Note: The width/height or scale given is in user-space coordinates which is subject to transformations which may have been specified beforehand.

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.

$gfx->formimage $imgobj, $x, $y, $scale
$gfx->formimage $imgobj, $x, $y
Places the X-Object (or XO-Form) at x/y with optional scale.

$gfx->shade $shadeobj, $x1,$y1, $x2,$y2
$gfx->egstate $egsobj
$hyb->textstart
%state = $txt->textstate %state
Sets or gets the current text-object state.

($tx,$ty) = $txt->textpos
Gets the current estimated text position.

Note: This is relative to text-space.

$txt->transform_rel %opts
Sets transformations (eg. translate, rotate, scale, skew) in pdf-canonical order, but relative to the previously set values.

Example:


  $txt->transform_rel(

    -translate => [$x,$y],

    -rotate    => $rot,

    -scale     => [$sx,$sy],

    -skew      => [$sa,$sb],

  )

$txt->font $fontobj,$size
$txt->fontset $fontobj,$size
The fontset method WILL NOT APPLY the font+size to the pdf-stream, but which will later be done by the text-methods.

Only use fontset if you know what you are doing, there is no super-secret failsave!

$spacing = $txt->charspace $spacing
$spacing = $txt->wordspace $spacing
$spacing = $txt->hspace $spacing
$leading = $txt->lead $leading
$rise = $txt->rise $rise
$rendering = $txt->render $rendering
$txt->cr $linesize
takes an optional argument giving a custom leading between lines.

$txt->nl
$txt->distance $dx,$dy
$width = $txt->advancewidth $string [, %textstate]
Returns the width of the string based on all currently set text-attributes or on those overridden by %textstate.

$width = $txt->text $text, %options
Applys text to the content and optionally returns the width of the given text.

Options

-indent
Indent the text by the number of points.

-underline
If this is a scalar, it is the distance, in points, below the baseline where the line is drawn. The line thickness is one point. If it is a reference to an array, each pair is the distance below the baseline and the thickness of the line (ie., -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.

$txt->text_center $text
$txt->text_right $text, %options
$width = $txt->text_justified $text, $width, %options
** DEVELOPER METHOD **

($width,$chunktext) = $txt->text_fill_center $text, $width, %options
** DEVELOPER METHOD **

($width,$chunktext) = $txt->text_fill_right $text, $width
** DEVELOPER METHOD **

($width,$chunktext) = $txt->text_fill_justified $text, $width
** DEVELOPER METHOD **

$overflow_text = $txt->paragraph $text, $width, $height, %options
** DEVELOPER METHOD **

Apply the text within the rectangle and return any leftover text.

Options

-align => $choice
Choice is 'justified', 'right', 'center', 'left' Default is 'left'

-underline => $distance
-underline => [ $distance, $thickness, ... ]
If a scalar, distance below baseline, else array reference with pairs of distance and line thickness.

Example:


    $txt->font($font,$fontsize);

    $txt->lead($lead);

    $txt->translate($x,$y);

    $overflow = $txt->paragraph( 'long paragraph here ...',

                                 $width,

                                 $y+$lead-$bottom_margin );
$overflow_text = $txt->section $text, $width, $height, %options
** DEVELOPER METHOD **

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.

$hyb->textend
$width = $txt->textlabel $x, $y, $font, $size, $text, %options
Applys text with options, but without teststart/end and optionally returns the width of the given 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__


AUTHOR

alfred reibenschuh

Programminig
Wy
Wy
yW
Wy
Programming
Wy
Wy
Wy
Wy