You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@pdfbox.apache.org by Christopher Schultz <ch...@christopherschultz.net> on 2019/05/17 13:54:12 UTC

Examples of word-wrapping

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA256

Hello,

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?

Thanks,
- -chris
-----BEGIN PGP SIGNATURE-----
Comment: Using GnuPG with Thunderbird - https://www.enigmail.net/

iQIzBAEBCAAdFiEEMmKgYcQvxMe7tcJcHPApP6U8pFgFAlzevQQACgkQHPApP6U8
pFiu9Q//YpMB9rLYl69Gm/lFY2kEk10hWt1aDSMxB6sw3xjQAqO05P/2X5JiljoV
YlS1yTbVF9agAxk3l45X4aTubA7ae7oBxNPsIl98AvK3fxzHHlloCNOjc6y2Tdq2
7TxVNEJAqDNaWmHRENaNaqz7I+II3iQTDSu1ycf/MIYCd7sT3SnnlIgzO06E9SNi
a/AiFEgrce5NobfoAt/wZYfTY6ydY+xYWFifZgp3hqWpNBx1BigCvmFs45AnLHm3
rt3Qbsn1Q94m+SivsCMprhVDtNFESgE+5yLrQPtOXVMJrmNKTChgVK4VnDgc8UEz
hN+JFxGtjCuV/SgypWOmv7aar2o10o0AJyhk6zjA0YBTIHaBeqLzIT64sl9I00iv
Cs+Hex8btPvDDycRDIRE76C+ZS1+obdyIf4nbpfEfDQwDjhRHtiGn0M/QXL/se8L
DRz1Vk/8z3IJ26DGulxOb9X1g2GHn7WlPfqZogQMawQtfIBexobWkCZnaQ17ew7R
CXK2pReJ0JZLu6VnmfZWlHEcdQK5ZubSErvBjIO4qMZTzanQUXhTSwRw5vh2hbOG
w3oWvF1DPXTRg+bbsW8UsyaR8CFBpXZg/bE2AjUkXIzoYTujekwe9VGdoufZCqlu
0eGtT9A41PbhilyWh+gA/D2o+dcWTNPWBLrqDYrbfq0TIVYu1fc=
=SUN1
-----END PGP SIGNATURE-----

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@pdfbox.apache.org
For additional commands, e-mail: users-help@pdfbox.apache.org


Re: Examples of word-wrapping

Posted by Thad Humphries <th...@gmail.com>.
On Fri, May 17, 2019 at 1:26 PM Tilman Hausherr <TH...@t-online.de>
wrote:

> 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:
http://stackoverflow.com/a/14107244/1316011

-- 
"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)

Re: Examples of word-wrapping

Posted by Tilman Hausherr <TH...@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



---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@pdfbox.apache.org
For additional commands, e-mail: users-help@pdfbox.apache.org