http://www.perlmonks.org?node_id=1062063


in reply to PDF::API2 - Test text that will fit in area

Look at the advancewidth() method in PDF::API2::Content for the width of the text you want to write given the current text object's state, and, for height, I personally just used the rule of thumb that 0.6 x font size (in points) will give me a good-enough approximate height of the text I'm about to write.

Hope that helps.

Replies are listed 'Best First'.
Re^2: PDF::API2 - Test text that will fit in area
by snoopy (Curate) on Nov 12, 2013 at 00:20 UTC
    Seconded.

    Here's a hack to temporarily turn-off output, if you're wanting to pre-compute sizes using one of the higher-level methods such as text_center() or paragraph() - Re: PDF::API2 paragraph vertical align.