Search code examples
pdflib

PDFlib - "leading" option of create_textflow


I'm trying to figure out how to add line spacing without adding spacing above the very first line of textflow.

This code:

$text = 'For more information about the Giant Wing Paper Plane see ' .
    'our Web site <underline=true>www.kraxi-systems.com' .
    'the Giant Wing in a thunderstorm as soon as possible.';
$optlist = 'fontname=Helvetica fontsize=12 encoding=unicode leading=400%';
$tf = $p->create_textflow($text, $optlist);
$result = $p->fit_textflow($tf, 28.346, 28.346, 400, 700, 'fitmethod=nofit');
$p->delete_textflow($tf);

results in:

enter image description here

All is good.

Next, I'm increasing the leading option to 400% as:

$optlist = 'fontname=Helvetica fontsize=12 encoding=unicode leading=400%';

And that gives me this:

enter image description here

Question:

How do I keep first paragraph line at the original position and only increase line spacing AFTER it?


Solution

  • checkout the "firstlinedist" option. The default is leading, but you might set this to "ascender" or "capheigt" or any other value.

    Please see PDFlib 9.2 API reference, chapter 5.2, table 5.12 for more details.