Open tbrowder opened 1 year ago
Is the affect supposed to be the same as \:valign\
It's similar, but :baseline
is always a constant shift within a line
test.pdf
. But :valign
depends on the number of lines of text, as in the following example, which uses :width` to break the text across multiple lines and shifts the paragraphs as a whole.
use PDF::Lite;
my PDF::Lite $pdf .= new;
my $page = $pdf.add-page;
my $x = 10;
for <center top bottom> -> $valign {
$page.text: {
.text-position = $x, 150;
.print: "A multi line paragraph of $valign aligned text", :$valign, :width(100);
$x += 150;
}
}
$pdf.save-as: "test.pdf";
Great example, David. Thanks.
Starting with PDF::Content release 0.70, I've toned down :valign
to only affect the text flow of multiple line text boxes. It has no affect now on a single line of text, which is now only be shifted with :baseline
.
I made this change after realizing that both :baseline
and :valign
were "fighting over" the first line of text, allowing it to be moved by up to two lines, so that the text box could be positioned up to a full line above or below the current text position, which seems surprising.
Also not well documented yet. By default the x position is the baseline of the font. There is a
:baseline
option on the .print and .say methods and on text-box objects.:baseline<top>
, will cause the height to be taken into account.