pdfbox-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Maruan Sahyoun <sahy...@fileaffairs.de>
Subject Re: rich text editor to pdf
Date Tue, 06 May 2014 05:37:13 GMT
Hi Moses,

using HTML styled content as a fields value is called Rich Text in PDF terms. This rich text
is applied differently to a field than normal text. At this point in time PDFBox doesn’t
have a high level API to set rich text but you could use the lower level COS model provided
by PDFBox to set the necessary information for the field.

Here is a short example of how rich text is specified inside a field’s properties

/RV (<?xml version="1.0"?><body xmlns="http://www.w3.org/1999/xtml" xmlns:xfa="http://www.xfa.org/schema/xfa-data/1.0/"
xfa:contentType="text/html" xfa:APIVersion="Acrobat:8.0.0" xfa:spec="2.4"> <p style="text-align:left">

<b> <i>

Here is some bold italic text </i>

</b> </p>

<p style= "font-size:16pt">

This text uses default text state parameters but changes the font size to 16. </p>

</body> )

As you can see there are some tags supported which are familiar from HTML as the Rich Text
part is a subset of XHTML. More details of what’s permitted can be found in section
of the ISO 32000-1 specification.

If you do use PDFBox for rendering purposes at this point in time PDFBox wouldn’t be able
to render such Rich Text but use the pure value and some other information of the field to
render the fields content.

Maruan Sahyoun

Am 04.05.2014 um 18:54 schrieb Moses Mosese <mosesm.mosese@gmail.com>:

> Hi,
> I have a requirement to display values that were entered with rich text
> editor (they contain html tags), on pdf document.
> Can pdfbox cater for this?
> Currently i use, *drawString
> <http://pdfbox.apache.org/docs/1.8.4/javadocs/org/apache/pdfbox/pdmodel/edit/PDPageContentStream.html#drawString(java.lang.String)>*
> (String<http://download.oracle.com/javase/1.5.0/docs/api/java/lang/String.html?is-external=true>
> text), to display and it shows html tags as they are.
> Thanks lot,
> Moses

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