Re: First time using Perl & PDF::API2

[email protected] (Daniel Kasak)
Newsgroups perl.beginners
Organization NUS Consulting
Message-ID <[email protected]>
On Tue, 2008-05-27 at 07:10 -0700, ChrisC wrote:

> Hi!,
> 
> Not sure if using PDF::API2 is  a good choice or not.  Little to no
> doc.

Yeah it's very powerful, and *very* poorly documented. What's worse, one
of the best tutorials ( http://rick.measham.id.au/pdf-api2/ ) has a big
photo of John f'n Howard in it. There's no need to immortalise that war
criminal.

> In the "sub paging " I create the next page, but the
> script does not print in the next page.  Do I have to tell it to print
> on page 2?  If so how?

For each page, you have to set up page dimensions, create new text and
graphics objects, eg:

# Set page dimensions
$page->mediabox( $self->{page_width}, $self->{page_height} );

# Create a new txt object for the page
$self->{txt} = $page->text;

# Set y to the top of the page
$self->{y} = $self->{page_height} - $self->{upper_margin};

# Create a new gfx object for our lines
$self->{line} = $page->gfx;

> How do I add an image, jpg etc.

$gfx->image(
    $image,                     # The image
    $img_x_pos,                 # X
    $img_y_pos,                 # Y
    $imgdata->{scale_ratio}     # scale
);

You might want to look at my project, PDF::ReportWriter. It uses
PDF::API2 to produce reports. It simplifies things considerably, does
page breaking for you, grouping, etc. You can also use it just to render
text ( keep calling $report->render_data with new text ). I use it for
everything from Access-like reports to producing mail-merge letters ( it
does alignment, justification, etc as well ).

I would point you to my webpage, but I accidentally lost everything
during a server upgrade, so you'll have to get it from CPAN. You can
either use it directly, or view the source to see how to use PDF::API2.

Let me know if you have any other questions, feature requests, etc.

Dan

--
Daniel Kasak
IT Developer
NUS Consulting Group
Level 5, 77 Pacific Highway
North Sydney, NSW, Australia 2060
T: (+61) 2 9922-7676 / F: (+61) 2
9922 7989
email: [email protected]
website:
http://www.nusconsulting.com.au
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.