Text formatting issues

First and foremost thanks for all the help I've received on this
board, especially Gunnar who keeps this place running!

I've come a long way in my code and am trying to format some text and
then put it into a nice pdf file. My problem is putting the formatted
text into the pdf and for it to display correctly. I am just trying to
justify the text and then set the margins. I can put the text in the
pdf and it looks like it is trying to justify it but it won't wrap to
the next line. I've looked at the documentation for both the
Text::Autoformat and PDF::API2 modules but can't seem to figure it

I have 2 questions: 1. What am I doing wrong in that the text will
appear fine when I "print" it but that it won't appear correctly in
the pdf file? 2. Also, if the text is more than 1 page, how can I get
it to automatically create a new page and continue onto the newly
created page?

My code:


use warnings;

use LWP::Simple;
use HTML::TokeParser;
use PDF::API2;
use Text::Autoformat;

# Print out the subtitle

my $oldtext = "trying to test if this sentence will be formatted the
correct way when it appears in the pdf file. For some reason I just
can't seem to get this to work. Well, maybe I can find help to get
this working. If I could get it to work it would really make my kitty

my $newtext = autoformat $oldtext, { left=>8, right=>70, justify =>
'full' };
print $newtext;

#----create the pdf file----->
my $file = "This PDF";
my $pdf = PDF::API2->new( -file => "$file.pdf" );
my $page = $pdf->page;
$page->mediabox ('A4');
$page->cropbox (7.5,7.5,97.5,120.5);
my %font = (
Helvetica => {
Bold => $pdf->corefont( 'Helvetica-Bold', -encoding =>
'latin1' ),
Roman => $pdf->corefont( 'Helvetica', -encoding =>
'latin1' ),
Italic => $pdf->corefont( 'Helvetica-Oblique', -encoding =>
'latin1' ),
Times => {
Bold => $pdf->corefont( 'Times-Bold', -encoding =>
'latin1' ),
Roman => $pdf->corefont( 'Times', -encoding =>
'latin1' ),
Italic => $pdf->corefont( 'Times-Italic', -encoding =>
'latin1' ),

my $main_text = $page->text;
$main_text->font( $font{'Times'}{'Roman'}, 2 );
$main_text->translate( 5, 100 );



Relevant Pages

  • Re: I sent my resume using words and receiver can not open file
    ... I would advise asking the recipient what format they prefer. ... Tech Editor for "Microsoft Publisher 2007 For Dummies" ... Anybody can view a PDF file using a free ... If the people trying to open your .docx file ...
  • Re: Tricks to impress Windows users
    ... A .pdf file is a cross platform portable document ... documents amongst themselves .doc format *is* std. ... Education, education, education my arse. ...
  • Re: Text formatting issues
    ... then put it into a nice pdf file. ... Note also that I've set the font point size to 12 (you had 2 ... which flows the text into a 2in high rectangle. ... You need to do a lot of arithmetic to format the text as you want. ...
  • Re: Trouble opening a figure
    ... If you want to be able to open a figure using a figure file in MATLAB, it MUST have been written using the FIG format. ... It is strongly encouraged for that file to have the extension ..fig. ... The appropriate tool to open that file is a PDF file viewer ... I see that the Tips section of the reference page for SAVEAS could be misleading; I'll ask the documentation staff to clarify that. ...
  • Re: Splitting/Combing data question
    ... Acrobat Distiller to export the PDF file to a different format and use ... > The Import Wizard allows a line at which to commence import. ... > Regards and Thanks. ...