pdfbox-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Thad Humphries <thad.humphr...@gmail.com>
Subject Re: Examples of word-wrapping
Date Sat, 18 May 2019 12:05:47 GMT
On Fri, May 17, 2019 at 1:26 PM Tilman Hausherr <THausherr@t-online.de>

> Am 17.05.2019 um 15:54 schrieb Christopher Schultz:
> > It occurs to me that my code is doing more work than necessary to
> > print paragraphs, and that maybe manual word-wrapping is not
> > necessary. Are there any examples that show how to print a paragraph
> > of text without having to compute the width of text and manually chop
> > things up into lines? Or is that part of the price of PDF?
> There is no feature in PDF that does automatic word wrap. Yes you have
> to do it yourself.
> There is a class in the PDFBox source code, PlainTextFormatter, that can
> also do it, but it was designed for form fields. It is used in
> AppearanceGeneratorHelper. You'd have to copy  the code, it is not public.
> Tilman

About a year ago I converted PDF code from iText to PDFBox. One issue to
resolve was wordwrap. This snippet from Stack Overflow was very helpful:

"Hell hath no limits, nor is circumscrib'd In one self-place; but where we
are is hell, And where hell is, there must we ever be" --Christopher
Marlowe, *Doctor Faustus* (v. 111-13)

  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message