Skip to content

Conversation

@methodofaction
Copy link
Contributor

Nothing you wouldn't add yourself in a couple of minutes, just wanted to explain some things that I tried which didn't work out:

  1. Ideally we wouldn't have widows (stray words at the end of a multi-line string) but the text would be redistributed among the available lines.
this is a very long string
which will not fit in a single 
line.

It should be distributed like this:

this is a very long 
string which will not 
fit in a single line

In CSS, this can be accomplished through text-wrap: balance. Unfortunately Prince does not support it.

  1. I believe text-overflow: ellipsis will do more harm than unbalanced watermark lines. If you have the need of displaying text in a large obvious format you most likely want it displayed in full. Still, it would be a good practice to set a character limit on the input itself.

  2. There's an official fittext script but...

Textfitting in Prince relies on the multipass feature, which formats the document several times. Between each run, a script can modify the document to improve layout. These scripts do amazing things in Prince, but will not work in browsers.

Sounds computationally expensive and we can't preview how it will look without generating the PDF.

  1. There's -prince-text-wrap: heading but this will only avoid widows and also can't be previewed until you generate the PDF.

All in all, I think the best we can do is assign a class depending on string length, as you suggested.

Base automatically changed from pt-training-mode to main September 25, 2025 13:14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants