CGI/Perl Guide | Learning Center | Forums | Advertise | Login
Site Search: in

  Main Index MAIN
INDEX
Search Posts SEARCH
POSTS
Who's Online WHO'S
ONLINE
Log in LOG
IN

Home: Perl Programming Help: Intermediate:
Need help with PDF generation

 



bpejman
New User

Apr 28, 2009, 9:52 AM

Post #1 of 1 (373 views)
Need help with PDF generation Can't Post

Hi all,

I'm running into a weird problem here and was wondering if anyone has solved this problem. I have a text file that contains the following text:

"This is some text"
"This is yet another text"

If I have multiple white spaces between each word, the alignment is not preserved when I read the string from the text file and write it to a PDF. However, when I view this using a text editor, the alignment is preserved. Meaning, if "s" in the word "some" appears to be right on top of the character "y" in the word "yet", this alignment is lost when I write this to a PDF.

Do you know how I can write strings to a PDF file and maintain the spaces between words just like a regular text file??

Here's the code I'm using to read the text file and write the PDF.


Code
 
use PDF::Create;
my $pdf = new PDF::Create('filename'=>"test.pdf", 'Version'=>1.2,'PageMode'=>'UseOutlines','Author'=>'','Title'=>'',);

my $root = $pdf->new_page('MediaBox'=>[0,0,595, 800]);
my $fontnorm = $pdf->font('Subtype'=>'Type1','Encoding'=>'WinAnsiEncoding','BaseFont'=>'Helvetica');
my $page = $root->new_page;

open (FILE, "<test.txt");

foreach $line (<FILE>)
{
chomp($line);
$page->string($fontnorm, 10, 20, $ypos-=$incr, $line);
}

$pdf->close;
close(FILE);


Any help would be greatly appreciated!

Bobby Pejman

(This post was edited by bpejman on Apr 28, 2009, 10:01 AM)

 
 


Search for (options) Powered by Gossamer Forum v.1.2.0

Web Applications & Managed Hosting Powered by Gossamer Threads
Visit our Mailing List Archives