This is a library to call from your Perl code to create well-formed paragraph text layouts, using the famed Knuth-Plass (`TeX`) algorithm.
Text::KnuthPlass uses the famed Knuth-Plass line-splitting algorithm (used in TeX and LaTeX) to break up a text string into a properly "shaped" paragraph. Certain rules are followed to not only efficiently pack the paragraph into a minimal number of lines, but also to minimize hyphenation, keep line density fairly constant, and take other measures to ensure that the output is typographically "nice looking". It works with both fixed-width fonts and with proportional (variable-width) fonts, where you supply the font library that calculates word lengths (e.g., PDF::Builder's advancewidth() method). Text::KnuthPlass permits varying line lengths, to allow text to flow around other objects, such as illustrations. It also makes use of (by default) Text::Hyphen, a library to indicate where words can be split (for hyphenation purposes).
See also this blog on Paragraph Shaping for a deeper dive into the subject.
Text::KnuthPlass can run as a pure Perl library, or it can be built and run with XS C code to speed it up.
The documentation can be built from the Perl source, but is provided here for your convenience. The examples can be built by running the Perl sample code in the examples/ directory, but are provided here so you can browse the output to see what example may show what you're looking to do. Then you can look in the Perl code to see how to do it.