PDF-API2-Tweaks

 view release on metacpan or  search on metacpan

lib/PDF/API2/Tweaks.pm  view on Meta::CPAN

#! perl

use strict;
use warnings;

use PDF::API2;

package PDF::API2::Tweaks;

=head1 NAME

PDF::API2::Tweaks - Assorted handy additions to PDF::API2.

=head1 SYNOPSIS

PDF::API2::Tweaks provides a number of extensions to PDF::API2.

Most of the extensions deal with producing PDF overlays, to fill in
forms. For example,

    # Open an existing PDF file
    my $pdf = PDF::API2->open($form);

    # Retrieve an existing page
    my $page = $pdf->openpage(1);

    # Add a built-in font to the PDF
    my $font = $pdf->corefont('Helvetica');

    # Setup text context.
    my $text = $page->text();
    $text->font($font, 10);
    $text->fillcolor('#000000');
    $text->strokecolor('#000000');

    # So far, this is all basic PDF::API2.

    # The following Tweaks extension will produce a series of lines,
    # the first one starting at position 100,714 and subsequent lines
    # spaced 16 apart:

    $text->textlist( 100, 714, 16, <<'EOD' );
    Now is the time
    for all good man
    to start using Perl
    EOD

    # Save to a file.
    $pdf->saveas("perl.pdf");

=cut

our $VERSION = 0.09;

=head1 TEXT FUNCTIONS

The following functions operate on PDF::API2::Content::Text objects.
In general, these are obtained by a call to the C<text> method on the
page object.

=cut

package PDF::API2::Content::Text;

use Carp;

sub _isnum {
    $_[0] =~ /^[-+]?\d+(.\d+)?$/;
}

my %rotation_for;			# LEAK!!!

sub translate {			# internal
    my ( $self, $x, $y ) = @_;
    if ( $rotation_for{$self} ) {
	($x, $y) = ($y, $x) if $rotation_for{$self} == 90;
	$self->transform( -translate => [ $x, $y ],
			  -rotate => $rotation_for{$self},



( run in 2.332 seconds using v1.01-cache-2.11-cpan-140bd7fdf52 )