in reply to Adjustable pdf text size in API2

You can use the advancewidth( string ) method of the text object to tell you the exact width of a line. It will tell you the width of whatever string of characters you give it as an argument using the current font attributes of the text object. It's important to note that it doesn't matter at all what you've already added to the PDF with that text object. It just measures the string you give it. Here are some bits and pieces of code:
my $page = $pdf->page; my $text = $page->text; my $font_size = 10; my $font = $pdf->corefont( "Times-Roman" ); my $bold = $pdf->corefont( "Times-Bold" ); my $italic = $pdf->corefont( "Times-Italic" ); $text->font( $bold, $font_size ); # ... sub text { my $text = $_[0]; my $x = $_[1]; my $y = $_[2]; my $alignment = $_[3]; my $string = $_[4]; $text->translate( $x, $y ); if ( $alignment eq "right" ) { $text->text_right( $string ); } elsif ( $alignment eq "center" ) { $text->text_center( $string ); } elsif ( $alignment eq "justified" ) { $text->text_justified( $string ); } else { $text->text( $string ); } return $text->advancewidth( $string ); } # End text subroutine
Are you trying to make paragraphs that fit the page, or a section of the page? If you post some of your code, I could offer some ideas.
--
-- GhodMode