You are viewing a plain text version of this content. The canonical link for it is here.
Posted to fop-users@xmlgraphics.apache.org by "Hahn Kurt (CHA)" <ku...@etat.ge.ch> on 2002/06/21 08:43:31 UTC

keep line-breaks in PDF

I'm generating a document from a DB which contains fields of up to 2000
characters In those fields,any line-break is stored, and if I look at my
XSL-FO in a text-editor, I see that all the line-breaks are still there.
They're of the form: &#13;. If process the document through FOP (the
contents are displayed in table cells), Acrobat seems to ignore the
line-breaks completely. 
Does FOP strip away the  &#13;? Or do I have to use another line-break
character?

Kurt

Re: keep line-breaks in PDF

Posted by "J.Pietschmann" <j3...@yahoo.de>.
Hahn Kurt (CHA) wrote:
> I'm generating a document from a DB which contains fields of up to 2000
> characters In those fields,any line-break is stored, and if I look at my
> XSL-FO in a text-editor, I see that all the line-breaks are still there.
> They're of the form: &#13;. If process the document through FOP (the
> contents are displayed in table cells), Acrobat seems to ignore the
> line-breaks completely. 
> Does FOP strip away the  &#13;? Or do I have to use another line-break
> character?

If the data is reparsed, the XML parser is oblieged to
normalize a CR (U+000D) to LF (U+000A) (if you write &#13;
instead of putting a CR into the text you get a CR delivered
to FOP). If you are passing the data in-memory, FOP will see
the CR.
After this, linefeeds are possibly converted to spaces,
according to the value of linefeed-treatment in effect
  http://www.w3.org/TR/xsl/slice7.html#linefeed-treatment
and then white space is collapsed, controlled by the
values of white-space-treatment and white-space-collapse

If you want to have your line breaks preserved, you
should set linefeed-treatment to preserve. Unfortunately,
FOP doesn't implement this. You can set white-space-collapse
to false, which will not only keep runs of spaces but also
the linefeeds intact (which is actually a bug).
If you want to have white space collapsed, you can
- do this at a transformation level
- use a transformation which transforms each run of characters
   between two line bbreaks into a separate fo:block
- translate the CR to &#x2028; (Unicode LINE SEPARATOR) which
   is apparently treated specially

HTH
J.Pietschmann