Hi,

Your snippet gives me expected output, and *all* LF are taken into
account, comprising those between empty blocks, and those before and
after opening/closing tags.
Note that when LF-treatment is "preserve", embedding multiple fo:block
can give unwanted output, hard to predict or understand.
You should replace empty blocks with explicit LF, that should give a
more readable code.
removing LF before, between and after tags can help too.

As a debug help, you can colorize your fo:blocks (using background-color
for filled blocks or border-after for empty blocks), this will give an
easy-to-understand output, that can help to debug XSL-FO or XSLT.

Le 18/02/2012 01:33, Lal Mohanty a écrit :
> Jonathan Levinson <Jonathan.Levinson <at> intersystems.com> writes:
> 
>>
>> Hi Lal,
>>
>> You create an XSL-FO file by applying the XSLT transformation to your XML.  
> The result is XSL-FO.  You can
>> generate the PDF from XSL-FO directly using FOP, for example:
>>
>> Here is an example:
>>
>> c:\fop\fop.bat -fo COSLinearGradient2.fo -pdf COSLinearGradient21.pdf
>>
>> Winnow your FO file down in size till you reach the minimum FO necessary to 
> show your problem.
>>
>> HTH,
>> Jonathan Levinson
>>
>>> -----Original Message-----
>>> From: Lal Mohanty [mailto:lmohanty <at> yahoo.com]
>>> Sent: Friday, February 17, 2012 4:09 PM
>>>
>>> Pascal Sancho <pascal.sancho <at> takoma.fr> writes:
>>>
>>>>
>>>> Hi,
>>>>
>>>> XSLT snippet is not appropriate to figure what you describe.
>>>> You should a *short* XSL-FO to this thread, that demonstrates the
>>>> issue you are describing.
>>>>
>>>> Le 17/02/2012 01:19, Lal Mohanty a écrit :
>>>>> I am having a problem with keep-together.within-page="always" in Fop
>>> 0.95/1.0.
>>>>> It behaves erratically depending on size of the content. I need to
>>>>> print a letter where all contents (Request/Data/Body/Para and
>>> Request/Data/Closure)
>>>>> need to be printed in one page. If it does not fit, I need to take
>>>>> the
>>> LAST
>>>>> paragraph of the Request/Data/Para and the Closure to the next page.
>>>>> This works in many cases, but sometimes, FOP squeezes the line-feeds
>>>>> (or takes
>>> away
>>>>> the empty lines) to accommodate the whole content in one page. If I
>>>>> have little larger contents, when it feels (I think) that it can not
>>>>> put all in
>>> a
>>>>> single page (even after squeezing), it works fine without trimming
>>>>> the
>>> line-
>>>>> feeds.
>>>>>
>>>>> Any help will be well appreciated. Thanks in advance.
>>>>> Here is a sample XSL -
>>>>> <xsl:template name="LetterBody">
>>>>>     <fo:block white-space-collapse="false" linefeed-
> treatment="preserve">
>>>>>            <xsl:for-each select ="Request/Data/Body/Para">
>>>>>               <xsl:if test="position()!=last()">
>>>>>                <xsl:if test="Text">
>>>>>                     <fo:block font-size="10pt" font-family="Courier">
>>>>>                       <xsl:call-template name="WriteASIS">
>>>>>                            <xsl:with-param name="buffer"
>>>>> select="string
>>> (.)"/>
>>>>>                      </xsl:call-template>
>>>>>                     </fo:block>
>>>>>               </xsl:if>
>>>>>             </xsl:if>
>>>>>          </xsl:for-each>
>>>>>    </fo:block>
>>>>> </xsl:template>
>>>>> ...
>>>>> <xsl:template name="Closure">
>>>>> <fo:block space-before="5mm" font-family="Courier"
>>>>> keep-together.within- page="always">
>>>>>   <xsl:for-each select="Request/Data/Body/Para[last()]/Text">
>>>>>        <xsl:call-template name="WriteASIS">
>>>>>             <xsl:with-param name="buffer" select="string(.)"/>
>>>>>        </xsl:call-template>
>>>>>  </xsl:for-each>
>>>>>  <xsl:if test="NB21Request/Data/Closure/Text !=''">
>>>>>       <xsl:for-each select="Request/Data/Closure/Text">
>>>>>           <xsl:call-template name="WriteASIS">
>>>>>              <xsl:with-param name="buffer" select="string(.)"/>
>>>>>           </xsl:call-template>
>>>>>       </xsl:for-each>
>>>>>  </xsl:if>
>>>>> </fo:block>
>>>>> </xsl:template>
>>>>
>>>
>>>
>>> Dear Pascal:
>>> I am sorry I could not make my issue clear. I am also not sure what you 
> mean by
>>> "short XSL-FO". I wish I could attach an image to demonstrate the issue. I 
> have
>>> put some empty lines between each paragraph using empty <fo:block>. FOP is
>>> preserving these lines in many cases. However, in certain cases, it is 
> taking them
>>> out and squeezes the texts together.
>>> AAA
>>>
>>> BBB
>>> becomes
>>> AAA
>>> BBB
>>> This typically happens, when FOP tries to fit all the texts in the same 
> page.I
>>> have tried white-space-collapse="false" linefeed-treatment="preserve", but 
> it
>>> does not help. I have a feeling that keep-together.within-page="always" 
> might
>>> be overwriting the linefeed treatments. But keep-together.within-
>>> page="always"
>>> and linefeed-treatment="preserve" are in two different blocks. That's what 
> I
>>> had shown in my xsl-fo snippet.
>>>
>>> Please help me how I can preserve these linefeeds.
>>> Thanks
>>> Lal
>>
>>
> Thank you all for your patience (for a novice FOP builder). 
> Here is the snippet where I think FOP is being erratic. Typically, I see a 
> linefeed from TEXT 1 & TEXT 2 in one page and LAST TEXT in a different page. 
> But sometimes, TEXT1, TEXT2 & LAST TEXT appears in the same page w/o any 
> linefeed. Does it make any sense ?
> 
> <fo:block linefeed-treatment="preserve" white-space-collapse="false">
>    <fo:block font-family="Courier" font-size="10pt">
>      <fo:block space-before.optimum="5pt" space-after.optimum="10pt" 
>          padding-right="0.5in" padding-left="0.5in" text-align="left" 
>          line-height="12pt">
>       TEXT  1...
>         <fo:block white-space="pre" white-space-collapse="false" 
>         linefeed-treatment="preserve"/>
>       <fo:block margin-left="0.0in"/>
>       <fo:block/>
>      </fo:block>
>      <fo:block margin-left="0.0in"/>
>      <fo:block/>
>    </fo:block>
>    <fo:block font-family="Courier" font-size="10pt">
>      <fo:block space-before.optimum="5pt" space-after.optimum="10pt" 
>          padding-right="0.5in" padding-left="0.5in" text-align="left" 
>          line-height="12pt">
>       TEXT 2...
>       <fo:block white-space="pre" white-space-collapse="false" 
>          linefeed-treatment="preserve"/>
>       <fo:block margin-left="0.0in"/>
>       <fo:block/>
>      </fo:block>
>      <fo:block margin-left="0.0in"/>
>      <fo:block/>
>     </fo:block>
>     ...                               
> </fo:block>
> <fo:block keep-together.within-page="always" font-family="Courier" 
>     space-before="5mm">
>     LAST TEXT ...
>     <fo:block white-space="pre" white-space-collapse="false" 
>        linefeed-treatment="preserve"/>
>     <fo:block margin-left="0.0in"/>
>     <fo:block/>
>     ...
> </fo:block>

-- 
Pascal

---------------------------------------------------------------------
To unsubscribe, e-mail: fop-users-unsubscr...@xmlgraphics.apache.org
For additional commands, e-mail: fop-users-h...@xmlgraphics.apache.org

Reply via email to