Click here to Skip to main content
Rate this: bad
good
Please Sign up or sign in to vote.
See more: XML Java PDF
Hey!
 
Does anyone know how to get formatted text via FOP into the PDF? I'm trying to find a bug and have not much of a clue about FOP.
 
I have a dummy text out of multiple paragraphs like:
Li Europan lingues es membres del sam familie.
 
Lor separat existentie es un myth.
 
Por scientie, musica, sport etc, litot Europa usa li sam vocabular.
 
Li lingues differe solmen in li grammatica, li pronunciation e li plu commun vocabules.
 
Omnicos directe al desirabilite de un nov lingua franca: On refusa continuar payar custosi traductores.
and my output looks like:
Li Europan lingues es membres del sam
familie.    Lor separat existentie es un myth.    Por scientie, musica, sport etc,
litot Europa usa li sam vocabular.    Li lingues differe solmen in li grammatica, li
pronunciation e li plu commun vocabules.    Omnicos directe al desirabilite de un nov
lingua franca: On refusa continuar payar custosi traductores.    At solmen va esser necessi
far uniform grammatica, pronunciation e plu sommun paroles.    Ma quande lingues coalesce,
li grammatica del resultant lingue es plu simplic e regulari quam ti del coalescent
lingues.    Li nov lingua franca va esser plu simplic e regulari quam li existent Europan
lingues.    It va esser tam simplic quam Occidental in fact, it va esser Occidental.    A
un Angleso it va semblar
 
You can see clearly that the linke breaks are missing.
 
my XSLT looks like this:
<xsl:template name="Body">
	<fo:flow flow-name="xsl-region-body">
	<fo:block 
		xsl:use-attribute-sets="body-font" 
		margin-left="2pt" 
		margin-right="2pt"
	>
		<fo:block font-size="80%" white-space-collapse="false">
			<xsl:value-of select="text" /> 
		</fo:block>
	</fo:block>
		<fo:block id="endofdoc" />
	</fo:flow>
</xsl:template>
 
Why don't I get the line breaks? do I have to modify the text first(HTML style) to get the paragraphs?
Posted 26-Jan-12 3:33am
TorstenH.33.9K
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 1

Post your question at the FOP mailing list:
http://xmlgraphics.apache.org/fop/maillist.html[^]
 
You're more likely to get a good reply there.
 
Best regards
Espen Harlinn
  Permalink  
Comments
TorstenH. at 26-Jan-12 9:30am
   
That is a mighty strange resource - that I have already tried to search on. Seems like I'm the only one who is missing his line breaks (or the only one who has a longer text to print).
Espen Harlinn at 26-Jan-12 9:34am
   
Try opening your output in http://www.scintilla.org/SciTE.html
It might be that the output file only contains \n and not \r\n at the end of the lines.
 
TorstenH. at 26-Jan-12 9:42am
   
hmm, there is a "\r\n\r\n" sequence between the paragraphs. I already tried to convert it by String operations - like making it "" and so on - but then I just get those tags in the output.
Seems to me like I'm missing some setting. How about HTML tags? would those help?
Espen Harlinn at 26-Jan-12 9:45am
   
I'm no expert on FOP - used it once several years ago, and found the mailing list helpful - the questions I had at that time was already answered on the list.
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 2

<fo:block font-size="80%" linefeed-treatment="preserve">
   <xsl:value-of select="text" />
</fo:block>
 
the linefeed-treatment="preserve" does the trick.
  Permalink  

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
0 OriginalGriff 365
1 Sergey Alexandrovich Kryukov 319
2 CPallini 275
3 DamithSL 214
4 Maciej Los 185
0 OriginalGriff 5,455
1 DamithSL 4,457
2 Maciej Los 3,885
3 Kornfeld Eliyahu Peter 3,480
4 Sergey Alexandrovich Kryukov 3,115


Advertise | Privacy | Mobile
Web03 | 2.8.141216.1 | Last Updated 30 Jan 2012
Copyright © CodeProject, 1999-2014
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100