You are viewing a plain text version of this content. The canonical link for it is here.
Posted to fop-dev@xmlgraphics.apache.org by Ken McKelvey <ke...@courts.state.wi.us> on 2000/10/02 15:41:40 UTC

Unknown # of pages and static content

Hello,

This is my first time posting a question, but I have found the
ongoing discussion and archives very helpful.

I have a situation where the number of pages in my document is
variable, depending on information stored in a database.  So,
within a given <flow>, there can be 1,2,3.. etc. pages.

I would like to have one header (<fo:static-content
flow-name="xsl-region-before">) on the first page, and a
distinctly different header on the 2nd and subsequent pages.
These headers (1st page vs the rest) will have different content
as well as page positioning.  I think I've figured out how to
position the headers using <page-master-sequence>, but I can't
find a way to change the content of a header (using
static-content) within a single <fo:flow>.

Any suggestions would be appreciated.

Thanks,

Ken


Re: Unknown # of pages and static content

Posted by Sebastian Rahtz <se...@computing-services.oxford.ac.uk>.
Hani Elabed writes:
 > While the solution you suggested allows us to change the Layout
 > of the remaining pages, it does NOT allow
 > us to change the content( i.e data ) of the
 > <fo:static-content flow-name="xsl-region-before">
 > 
 > This is because the  <fo: static-content ... >
 > is defined inside <fo: page-sequence as follows...>
 > and there is NO WAY to tell FOP to use ONE
 > <fo:static-content flow-name="xsl-region-before">
 > for the 1st page and ANOTHER for subsequent pages...

Sorry, but it's easy. the "firstpage" page-master puts a static flow
called "xsl-region-before-firstpage" in the before region:

        <fo:simple-page-master master-name="firstpage"
                               page-height="297mm" page-width="210mm"
                               margin-top="20mm"  margin-bottom="10mm"
                               margin-left="25mm" margin-right="20mm">
          <fo:region-before
                region-name="xsl-region-before-firstpage"
                extent="10mm"/>

while "evenpage" puts "xsl-region-before-evenpage" there:

        <fo:simple-page-master master-name="evenpage"
                               page-height="297mm" page-width="210mm"
                               margin-top="20mm"  margin-bottom="10mm"
                               margin-left="25mm" margin-right="20mm">
          <fo:region-before
                region-name="xsl-region-before-evenpage"
                extent="10mm"/>

now in the page-sequence you can say

   <fo:static-content flow-name="xsl-region-before-evenpage">
          <fo:block>I am an even page</fo:block>
   </fo:static-content>
   <fo:static-content flow-name="xsl-region-before-firstpage">
          <fo:block>I am a first page</fo:block>
   </fo:static-content>

and get changed headers. you match up the "flow-name" of
static-content to the "region-name" of fo:region-before - the names
are arbitrary! you probably got confused by the earlier drafts where I
recall that the names were fixed.

If you want *dynamic* headers, you need fo:marker and
fo:retrieve-marker, which can be used to eg put section headings in
running heads. has FOP implemented those yet?

sebastian


Re: Unknown # of pages and static content

Posted by Hani Elabed <ha...@elabed.net>.
Sebastian,

I am working with Ken M. on the same project...

While the solution you suggested allows us to change the Layout
of the remaining pages, it does NOT allow
us to change the content( i.e data ) of the
<fo:static-content flow-name="xsl-region-before">

This is because the  <fo: static-content ... >
is defined inside <fo: page-sequence as follows...>
and there is NO WAY to tell FOP to use ONE
<fo:static-content flow-name="xsl-region-before">
for the 1st page and ANOTHER for subsequent pages...

While the Layout can be changed as you suggest from
first page to subsequent pages... Ken and I and others here
at the Wisconsin Court System have failed in finding a way
that allows us to change the content of the header from one
page to the other, i.e all within the same page-sequence that
happens to have the <fo: flow ...> object.

Again, we might be collectively missing something here...

Your suggestions for a plan of attack is greatly appreciated.

Thanks in advance to all.

Hani

<fo:root xmlns:fo="http://www.w3.org/1999/XSL/Format">
    <fo:layout-master-set>

        <!-- sebastian's code STARTS here -->

        <fo:simple-page-master master-name="firstpage"
                               page-height="297mm" page-width="210mm"
                               margin-top="20mm"  margin-bottom="10mm"
                               margin-left="25mm" margin-right="20mm">
          <fo:region-body
                          margin-top="0mm" margin-bottom="15mm"
                          margin-left="0mm" margin-right="0mm"/>
          <fo:region-before
                region-name="xsl-region-before-firstpage"
                extent="10mm"/>
          <fo:region-after
                region-name="xsl-region-after-firstpage"
                extent="10mm"/>
        </fo:simple-page-master>
        <!-- layout for the even page -->
        <fo:simple-page-master master-name="evenpage"
                               page-height="297mm" page-width="210mm"
                               margin-top="20mm"  margin-bottom="10mm"
                               margin-left="25mm" margin-right="20mm">
          <fo:region-body
                          margin-top="0mm" margin-bottom="15mm"
                          margin-left="0mm" margin-right="0mm"/>
          <fo:region-before
                region-name="xsl-region-before-evenpage"
                extent="10mm"/>
          <fo:region-after
                region-name="xsl-region-after-evenpage"
                extent="10mm"/>
        </fo:simple-page-master>
        <!-- layout for the odd page -->
        <fo:simple-page-master master-name="oddpage"
                               page-height="297mm" page-width="210mm"
                               margin-top="20mm"  margin-bottom="10mm"
                               margin-left="25mm" margin-right="20mm">
          <fo:region-body
                          margin-top="0mm" margin-bottom="15mm"
                          margin-left="0mm" margin-right="0mm"/>
          <fo:region-before
                region-name="xsl-region-before-oddpage"
                extent="10mm"/>
          <fo:region-after
                region-name="xsl-region-after-oddpage"
                extent="10mm"/>
        </fo:simple-page-master>
     <fo:page-sequence-master master-name="twoside">

      <fo:repeatable-page-master-alternatives>
        <fo:conditional-page-master-reference
                master-name="firstpage"
                page-position="first"/>
        <fo:conditional-page-master-reference
                master-name="oddpage"
                odd-or-even="odd"/>
        <fo:conditional-page-master-reference
                master-name="evenpage"
                odd-or-even="even"/>
      </fo:repeatable-page-master-alternatives>
     </fo:page-sequence-master>

        <!-- sebastian's code ENDS here -->

    </fo:layout-master-set>
    <fo:page-sequence master-name="psmA">
        <fo:static-content flow-name="xsl-region-before">
            .... header data ........
        </fo:static-content>
        <fo:static-content flow-name="xsl-region-after">
            .....footer data ......
        </fo:static-content>
        <fo:flow flow-name="xsl-region-body">

        ...... plenty of data........

        </fo:flow>
    </fo:page-sequence>
</fo:root>


Sebastian Rahtz wrote:

> Ken McKelvey writes:
>  > I would like to have one header (<fo:static-content
>  > flow-name="xsl-region-before">) on the first page, and a
>  > distinctly different header on the 2nd and subsequent pages.
>  > These headers (1st page vs the rest) will have different content
>  > as well as page positioning.  I think I've figured out how to
>
> Try something like the appended. It defines 3 simplepage masters, for first,
> even, and odd, and then makes a composite one which calls on the
> others if the conditions are right. The key is
> "fo:repeatable-page-master-alternatives"
>
> I am not sure whether FOP implements all this.
>
> sebastian
>
>         <fo:simple-page-master master-name="firstpage"
>                                page-height="297mm" page-width="210mm"
>                                margin-top="20mm"  margin-bottom="10mm"
>                                margin-left="25mm" margin-right="20mm">
>           <fo:region-body
>                           margin-top="0mm" margin-bottom="15mm"
>                           margin-left="0mm" margin-right="0mm"/>
>           <fo:region-before
>                 region-name="xsl-region-before-firstpage"
>                 extent="10mm"/>
>           <fo:region-after
>                 region-name="xsl-region-after-firstpage"
>                 extent="10mm"/>
>         </fo:simple-page-master>
>         <!-- layout for the even page -->
>         <fo:simple-page-master master-name="evenpage"
>                                page-height="297mm" page-width="210mm"
>                                margin-top="20mm"  margin-bottom="10mm"
>                                margin-left="25mm" margin-right="20mm">
>           <fo:region-body
>                           margin-top="0mm" margin-bottom="15mm"
>                           margin-left="0mm" margin-right="0mm"/>
>           <fo:region-before
>                 region-name="xsl-region-before-evenpage"
>                 extent="10mm"/>
>           <fo:region-after
>                 region-name="xsl-region-after-evenpage"
>                 extent="10mm"/>
>         </fo:simple-page-master>
>         <!-- layout for the odd page -->
>         <fo:simple-page-master master-name="oddpage"
>                                page-height="297mm" page-width="210mm"
>                                margin-top="20mm"  margin-bottom="10mm"
>                                margin-left="25mm" margin-right="20mm">
>           <fo:region-body
>                           margin-top="0mm" margin-bottom="15mm"
>                           margin-left="0mm" margin-right="0mm"/>
>           <fo:region-before
>                 region-name="xsl-region-before-oddpage"
>                 extent="10mm"/>
>           <fo:region-after
>                 region-name="xsl-region-after-oddpage"
>                 extent="10mm"/>
>         </fo:simple-page-master>
>      <fo:page-sequence-master master-name="twoside">
>
>       <fo:repeatable-page-master-alternatives>
>         <fo:conditional-page-master-reference
>                 master-name="firstpage"
>                 page-position="first"/>
>         <fo:conditional-page-master-reference
>                 master-name="oddpage"
>                 odd-or-even="odd"/>
>         <fo:conditional-page-master-reference
>                 master-name="evenpage"
>                 odd-or-even="even"/>
>       </fo:repeatable-page-master-alternatives>
>      </fo:page-sequence-master>


Re: Unknown # of pages and static content

Posted by Sebastian Rahtz <se...@computing-services.oxford.ac.uk>.
Ken McKelvey writes:
 > I would like to have one header (<fo:static-content
 > flow-name="xsl-region-before">) on the first page, and a
 > distinctly different header on the 2nd and subsequent pages.
 > These headers (1st page vs the rest) will have different content
 > as well as page positioning.  I think I've figured out how to

Try something like the appended. It defines 3 simplepage masters, for first,
even, and odd, and then makes a composite one which calls on the
others if the conditions are right. The key is
"fo:repeatable-page-master-alternatives" 

I am not sure whether FOP implements all this.

sebastian

        <fo:simple-page-master master-name="firstpage"
                               page-height="297mm" page-width="210mm"
                               margin-top="20mm"  margin-bottom="10mm" 
                               margin-left="25mm" margin-right="20mm">
          <fo:region-body
                          margin-top="0mm" margin-bottom="15mm"
                          margin-left="0mm" margin-right="0mm"/>
          <fo:region-before
		region-name="xsl-region-before-firstpage" 
		extent="10mm"/>
          <fo:region-after 
		region-name="xsl-region-after-firstpage" 
		extent="10mm"/>
        </fo:simple-page-master>
        <!-- layout for the even page -->
        <fo:simple-page-master master-name="evenpage"
                               page-height="297mm" page-width="210mm"
                               margin-top="20mm"  margin-bottom="10mm" 
                               margin-left="25mm" margin-right="20mm">
          <fo:region-body
                          margin-top="0mm" margin-bottom="15mm"
                          margin-left="0mm" margin-right="0mm"/>
          <fo:region-before
		region-name="xsl-region-before-evenpage" 
		extent="10mm"/>
          <fo:region-after 
		region-name="xsl-region-after-evenpage" 
		extent="10mm"/>
        </fo:simple-page-master>
        <!-- layout for the odd page -->
        <fo:simple-page-master master-name="oddpage"
                               page-height="297mm" page-width="210mm"
                               margin-top="20mm"  margin-bottom="10mm" 
                               margin-left="25mm" margin-right="20mm">
          <fo:region-body
                          margin-top="0mm" margin-bottom="15mm"
                          margin-left="0mm" margin-right="0mm"/>
          <fo:region-before
		region-name="xsl-region-before-oddpage" 
		extent="10mm"/>
          <fo:region-after 
		region-name="xsl-region-after-oddpage" 
		extent="10mm"/>
        </fo:simple-page-master>
     <fo:page-sequence-master master-name="twoside">

      <fo:repeatable-page-master-alternatives>
        <fo:conditional-page-master-reference
		master-name="firstpage"
		page-position="first"/>
        <fo:conditional-page-master-reference
		master-name="oddpage"
		odd-or-even="odd"/>
        <fo:conditional-page-master-reference
		master-name="evenpage"
		odd-or-even="even"/>
      </fo:repeatable-page-master-alternatives>
     </fo:page-sequence-master>