in reply to PDF::API2 paragraph vertical align
I've just had a look at the source code for version 0.73 or PDF::API2, and it looks like the paragraph() method is hard-coded to work downwards from the height that you specify. It works through the provided text from start to end, fitting as much as possible on each line, then repeating with the remaining text.
However, it does tell you how much of the height it used, when called in a list context:
So if you could call this once in a non-outputting fashion - perhaps to a dummy document? - you could adjust your $height, based on the unused space. I would guess:($text_remaining, $height_remaining) = $txt->paragraph('long paragraph + here ...', $width, $height, -align => 'center');
and then call it again, outputting to your real document. It's a bodge, but it looks like the only alternative is to write versions of paragraph(), text_fill_left(), text_fill_right() etc. that only calculate text placement but do not add it to the PDF document. Or is it possible to remove a trial $txt object from the document before re-generating it in the adjusted position? Perhaps some other monk can clarify.$height -= $height_remaining/2; # untested!
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: PDF::API2 paragraph vertical align
by shibu_pu (Acolyte) on Dec 17, 2009 at 05:56 UTC |