XSL FO Printing footer only on Page 2

I'm using Apache FOP to produce a PDF and I have a situation where I have to print different headers and footers based on the page position. The document is by default 2 page and it could be more than 2 page and when that happens "I need to print footer only on page 2" what that means is that page 3, 4..e.t.c will not have a footer.
jdharshaAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Geert BormansInformation ArchitectCommented:
There is limited support for conditional page masters in XSL-FO
Look at the below example that would work for 3 or 4 pages
You can play with the conditions in the page master alternatives
but still this is limited.
You can't say "put a footer on page 2"

<?xml version="1.0" encoding="UTF-8"?>
<fo:root xmlns:fo="http://www.w3.org/1999/XSL/Format">
    <fo:layout-master-set>
        <fo:simple-page-master master-name="no-footer" margin="1cm">
            <fo:region-body margin-top="2cm" margin-bottom="2cm" background-color="#FFFFAA"/>
        </fo:simple-page-master>
         <fo:simple-page-master master-name="footer" margin="1cm">
            <fo:region-body margin-top="2cm" margin-bottom="4cm" background-color="#FFFFAA"/>
            <fo:region-after extent="3cm" background-color="#FFAAFF" display-align="after"/>
        </fo:simple-page-master>
        <fo:page-sequence-master master-name="footer-test">
            <fo:repeatable-page-master-alternatives>
                <fo:conditional-page-master-reference odd-or-even="odd" master-reference="no-footer"/>
                <fo:conditional-page-master-reference page-position="last" master-reference="no-footer"/>
                <fo:conditional-page-master-reference odd-or-even="even" master-reference="footer"/>
              </fo:repeatable-page-master-alternatives>
        </fo:page-sequence-master>
    </fo:layout-master-set>
    <fo:page-sequence master-reference="footer-test">
        <!-- footer -->
        <fo:static-content flow-name="xsl-region-after" font-size="90%">
            <fo:block>PAGE 2</fo:block>
        </fo:static-content>
        <!-- body -->
        <fo:flow flow-name="xsl-region-body">
            <fo:block break-after="page">Lorem ipsum...</fo:block>
            <fo:block break-after="page">... ipsum ...</fo:block>
            <fo:block break-after="page">... more ipsum ...</fo:block>
            <fo:block>... finitus est.</fo:block>
       </fo:flow>
    </fo:page-sequence>
</fo:root>

Open in new window

0
Geert BormansInformation ArchitectCommented:
But the first important question is...
do you need to do this in a single fo:page-sequence
or can you split your document into different fo:page-sequence
If the first page could be in a seperate flow, that would really help, because you then put the footer on the first page in the second fo:page-sequence

So, you need to tell a bit more about what is on the pages, so we can give better advice
0
jdharshaAuthor Commented:
Thanks for the response! Please find my answers below:

"do you need to do this in a single fo:page-sequence
or can you split your document into different fo:page-sequence"
--- Not necessarily but I am not sure what it means to have two separate page-sequence?

"If the first page could be in a seperate flow, that would really help, because you then put the footer on the first page in the second fo:page-sequence"
--- That sounds ok to me as long as I am able to achieve the same output when I had it as single page-sequence.

"So, you need to tell a bit more about what is on the pages, so we can give better advice "
--- Here is the scenario...I need to have a different header and footer on the first page than on any other page..except that any pages other than 1 and 2 will not have footer.
Hope that clarifies a bit, please let me know if you need more info.
0
Cloud Class® Course: Python 3 Fundamentals

This course will teach participants about installing and configuring Python, syntax, importing, statements, types, strings, booleans, files, lists, tuples, comprehensions, functions, and classes.

Geert BormansInformation ArchitectCommented:
what it means to have two separate page-sequence
I am not sure how much XSL-FO you know, so I might be too basic in my explanation...

each page sequence starts a new page
If you would create a book, you would create a page sequence per chapter, and then each chapter would start a new page

In this project a seperate page sequence for the firt page would help, if you are sure that the content for page 1 needs to be on one page and would not exeed that first page
My technique would work well if the first page was a cover page

I understand the requirement. I would like to understand the data... is it one flow, is it a series of pages having one flow per page...
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
jdharshaAuthor Commented:
"I am not sure how much XSL-FO you know, so I might be too basic in my explanation..."
--- I explore on need basis so it is fine for the explanation to be basic.

"In this project a seperate page sequence for the firt page would help, if you are sure that the content for page 1 needs to be on one page and would not exeed that first page"
--- Yes, content on first page will not exceed the first page.

"I understand the requirement. I would like to understand the data... is it one flow, is it a series of pages having one flow per page... "
--- I am not sure if I understand this question 100% but I think it is just "one flow".
0
jdharshaAuthor Commented:
One more thing that I wanted to mention...the document will mostly be 2 paged but it is possible that there could be more that 2 and that I want the page numbers to appear on each of the pages for example "Page 1 of 3".
0
Geert BormansInformation ArchitectCommented:
Let's tackle one problem at the time...

We are talking in circles, so I have a suggestion: send us the XML and draft the pages in wireframes.
Show which data you want to go where. I think that would get us past this
0
jdharshaAuthor Commented:
Hey just to let you know I implemented the idea of having multiple page-sequence and that worked for my scenario thanks for the help and an excellent idea!
0
Geert BormansInformation ArchitectCommented:
welcome
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
XML

From novice to tech pro — start learning today.