Dear Erik & Fellow FOPers,

Quite right!  I should have provided the source.  I'm using
XML and XSLT to generate the PDF.  Here are the XML and XSL
files for your perusal.

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE document SYSTEM "demo.dtd">

<!-- Demonstrate problems with FOP -->

<document>
  <title>Problems with FOP</title>
  <section left="left side">
    <paragraph>
      This document should demonstrate the problems I'm
      currently experiencing with FOP.  The first involves
      the use of leaders causing the text to wrap.  Note
      that the leader (rule) above is fine, as is the leader
      (dots) at the beginning of this section.
    </paragraph>
  </section>
  <section left="left side" right="right side">
    <title>Leader Problem</title>
    <paragraph>
      This section header consists of the text <code>"left
      side"</code>, then a leader (dots), and then the text
      <code>"right side"</code>.  It appears that the leader
      forces this header text to split into multiple lines.
    </paragraph>
    <paragraph>
      The following section header has text only at the end
      and the leader again appears to force the text onto
      two lines.  It also pushes the text outside the right
      margin.
    </paragraph>
  </section>
  <section right="right side">
    <title>List Problem</title>
    <paragraph>
      The following list consists of a number of
      <code>list-item-label</code>
      <code>list-item-body</code> pairs.  The default
      behaviour when there are no attributes for the
      <code>list-item-label</code> or the
      <code>list-item-body</code> appears to overlay the
      body on top of the label.  This can be overcome by
      including the attribute
      <code>start-indent="body-start()"</code> inside the
      <code>list-item-body</code> tag.
    </paragraph>
    <list>
      <item>the first</item>
      <item>
        the second, the second, the second, the second, the
        second, the second, the second, the second, the
        second, the second
      </item>
      <item>the third</item>
    </list>
  </section>
  <section>
    <title>Widows and Orphans</title>
    <paragraph>
      I thought that widows and orphans were handled
      intelligently by FOP, but that doesn't seem to be the
      case.  Let's move down to the bottom of the page ...
    </paragraph>
    <paragraph>
      Going down ...
    </paragraph>
    <paragraph>
      Going down ...
    </paragraph>
    <paragraph>
      Going down ...
    </paragraph>
    <paragraph>
      Going down ...
    </paragraph>
    <paragraph>
      Going down ...
    </paragraph>
    <paragraph>
      Going down ...
    </paragraph>
    <paragraph>
      Going down ...
    </paragraph>
    <paragraph>
      Going down ...
    </paragraph>
    <paragraph>
      Going down ...
    </paragraph>
    <paragraph>
      Going down ...
    </paragraph>
    <paragraph>
      Going down ...
    </paragraph>
    <paragraph>
      Ok, here we are at the bottom of the page generating
      text that will demonstrate the problem.  We keep
      adding lines until we get a widow.  That didn't work.
      Let's see if we can generate an orphan.  Once again we
      keep adding text until it runs off the page.  It can
      take time at this rate.  It can take time at this
      rate.  It can take time at this rate.
    </paragraph>
    <paragraph>
      There should be an orphan above this paragraph if my
      suspicion is correct, even though I have the
      attributes <code>orphans="2"</code> and
      <code>widows="2"</code> in my
      <code>&lt;simple-page-master&gt;</code> tag.
    </paragraph>
  </section>
  <section>
    <title>Floats</title>
    <paragraph>
      I would like text to flow round images in a paragraph,
      but FOP 0.18.1 doesn't support
      <code>&lt;fo:float&gt;</code> as far as I know.
    </paragraph>
  </section>
  <section>
    <title>Line Breaks</title>
    <paragraph>
      I've been having trouble getting a simple line break
      in my text, but I might have an answer.
      <break/>
      If that broke the line, we're home!
    </paragraph>
  </section>
</document>
<?xml version="1.0" encoding="UTF-8"?>
<!-- XML to PDF transformations    -->

<xsl:stylesheet version="1.0"
                xmlns:fo="http://www.w3.org/1999/XSL/Format";
                xmlns:xsl="http://www.w3.org/1999/XSL/Transform";>

  <xsl:template match="/">
    <fo:root xmlns:fo="http://www.w3.org/1999/XSL/Format";>
      <fo:layout-master-set>
        <fo:simple-page-master margin-bottom="0.5in" 
                               margin-left="0.75in" 
                               margin-right="0.75in"
                               margin-top="0.5in"
                               master-name="a4"
                               orphans="2"
                               page-height="11.7in" 
                               page-width="8.3in"
                               widows="2">
          <fo:region-body/>
        </fo:simple-page-master>
      </fo:layout-master-set>

      <fo:page-sequence master-name="a4">
        <fo:flow flow-name="xsl-region-body">
          <xsl:apply-templates/>
        </fo:flow>
      </fo:page-sequence>
    </fo:root>
  </xsl:template>

  <xsl:template match="break">
      <xsl:text>&#xA;</xsl:text>
  </xsl:template>

  <xsl:template match="code">
    <fo:inline font-family="monospace">
      <xsl:apply-templates/>
    </fo:inline>
  </xsl:template>

  <xsl:template match="document">
    <fo:block font-size="18pt"
              font-weight="bold"
              text-align="center">
      <xsl:apply-templates select="title"/>
    </fo:block>
    <fo:block>
      <fo:leader leader-pattern="rule"/>
    </fo:block>
    <xsl:apply-templates/>
  </xsl:template>

  <xsl:template match="image">
    <fo:block float="start">
      <fo:external-graphic src="[EMAIL PROTECTED]"/>
    </fo:block>
  </xsl:template>

  <xsl:template match="item">
    <fo:list-item>
      <fo:list-item-label>
        <fo:block>
          <fo:inline font-family="Symbol">
            &#183;
          </fo:inline>
        </fo:block>
      </fo:list-item-label>
      <fo:list-item-body start-indent="body-start()">
        <fo:block>
          <xsl:apply-templates/>
        </fo:block>
      </fo:list-item-body>
    </fo:list-item>
  </xsl:template>

  <xsl:template match="list">
    <fo:list-block space-before="10pt">
      <xsl:apply-templates/>
    </fo:list-block>
  </xsl:template>

  <xsl:template match="paragraph">
    <fo:block font-size="10pt"
              space-before="10pt"
              text-align="justify">
      <xsl:apply-templates/>
    </fo:block>
  </xsl:template>

  <xsl:template match="section">
    <fo:block font-size="14pt"
              font-weight="bold"
              space-before="14pt"
              text-align="start">
      <xsl:apply-templates select="title"/>
    </fo:block>
    <fo:block>
      <xsl:value-of select="@left"/>
      <fo:leader leader-pattern="dots"/>
      <xsl:value-of select="@right"/>
    </fo:block>
    <xsl:apply-templates/>
  </xsl:template>

</xsl:stylesheet>
Regards,

Mick               /"\                      
                   \ /                      
                    X  ASCII Ribbon Campaign
                   / \ Against HTML Mail

Reply via email to