Creating new pages automatically with PDF::API2

H

hotkitty

Since no one in the beginners group could answer this I thought I'd
ask it to this group. I am using PDF::API2 to create PDF files from a
bunch of separate text files I have. The issue I am having is that I
am only able to create the first page of each text file and I haven't
been able to figure out how to automatically generate additional pages
if the text document requires it. In the PDF::API2::Simple module,
there is "autoflow", which will generate the additional pages you need
and fill it with the appropriate text. I have the following code and
would appreciate if anyone could guide me to how I can generate multi-
page pdf's (I've omitted some of the code that isn't relevant to
creating the pdf files):

#!/usr/bin/perl

use warnings;

use LWP::Simple;
use HTML::TokeParser;
use PDF::API2;
use Text::Autoformat;
..
..
..
..
..
my $pdffile = '$file';
my $pdf = PDF::API2->new( -file => "$directoryname/$file.pdf");
my $page = $pdf->page;

$page->mediabox('A4');

my $times = $pdf->corefont( 'Times', -encoding => 'latin1');

my $main_text = $page->text;
$main_text->font($times, 14);
$main_text->fillcolor('pearl');
$main_text->lead(16);
$main_text->translate(15, 650);
$main_text->paragraph("@body\n", 575, 144, -align => "justify");



$pdf->save;
$pdf->end;
 
B

Bill H

Since no one in the beginners group could answer this I thought I'd
ask it to this group. I am using PDF::API2 to create PDF files from a
bunch of separate text files I have. The issue I am having is that I
am only able to create the first page of each text file and I haven't
been able to figure out how to automatically generate additional pages
if the text document requires it. In the PDF::API2::Simple module,
there is "autoflow", which will generate the additional pages you need
and fill it with the appropriate text. I have the following code and
would appreciate if anyone could guide me to how I can generate multi-
page pdf's (I've omitted some of the code that isn't relevant to
creating the pdf files):

#!/usr/bin/perl

use warnings;

use LWP::Simple;
use HTML::TokeParser;
use PDF::API2;
use Text::Autoformat;
.
.
.
.
.
my $pdffile = '$file';
my $pdf = PDF::API2->new( -file => "$directoryname/$file.pdf");
my $page = $pdf->page;

$page->mediabox('A4');

 my $times = $pdf->corefont( 'Times', -encoding => 'latin1');

my $main_text = $page->text;
$main_text->font($times, 14);
$main_text->fillcolor('pearl');
$main_text->lead(16);
$main_text->translate(15, 650);
$main_text->paragraph("@body\n", 575, 144, -align => "justify");

$pdf->save;
$pdf->end;

I use PDF:API2 alot. It is easy to create a new page, when you are
done adding to the existing page you just do a new $page = $pdf->$page
and start writing to the second page.

Bill H
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,769
Messages
2,569,582
Members
45,057
Latest member
KetoBeezACVGummies

Latest Threads

Top