You are viewing a plain text version of this content. The canonical link for it is here.
Posted to fop-users@xmlgraphics.apache.org by Felipe Villarinho <fe...@gmail.com> on 2006/08/30 19:14:08 UTC

One Page DOcument

Hello,

I need to display in the footer of a document different sentences depending
on which page it is.
For exemple,
1. if it is the last page of the document show "Last Page"
2. if it is not the last page show "Continue..."
3. if it is the first and only page show "This Document Has Only One Page"

Using markers I did 1 and 2 but I can't figure a way of doing 3.

Does Anybody knows how to do it?

Re: One Page DOcument

Posted by "J.Pietschmann" <j3...@yahoo.de>.
mikevn123 wrote:
>     <fo:conditional-page-master-reference 
>      page-position="last" master-reference="last-page"/>
>     <fo:conditional-page-master-reference 
>      page-position="any" master-reference="default-page" />

The spec says the page master reference first matching the position
is used, in case of a one page document the "last-page" page master
should go into effect. I'd say if you are not getting this page
master, this indicates a bug.

J.Pietschmann

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


Re: One Page DOcument

Posted by Andreas L Delmelle <a_...@pandora.be>.
On Oct 18, 2006, at 15:56, mikevn123 wrote:

>
> I've used the fo:marker logic with FOP 0.20.5, however 0.92beta  
> does not
> allow fo:tables within markers.

FYI: this has been fixed in FOP Trunk, and so will be available in  
the next release.

Cheers,

Andreas

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


RE: One Page DOcument

Posted by mikevn123 <mi...@ci-inc.com>.
I've used the fo:marker logic with FOP 0.20.5, however 0.92beta does not
allow fo:tables within markers.

There are also issues with figuring out the exact last page.  I've used the
position()=last() logic, but then if you have a long field that flows onto
another page, it puts the same footer on the second to last page and the
last page.

For example, in printing business forms - you have a order header and order
detail lines.
If you use the position()=last() logic on the detail lines, it seems to work
fine, until after your detail lines, you want to put a document message from
the order header that happens to flow onto another page.

The last page should display a sub-total, tax and grand total.  This should
not be on the first page (unless the first page happens to also be the last
page).

There doesn't seem to be a good real test for last page yet.  The "only"
option should work, but when is it *actually* going to be implemented so I
can use it?

-Mike


Pascal Sancho wrote:
> 
> Mike,
> 
> There is something about that in list archives (see [1]).
> Jeremias wrote that the right solution should be page-position="only"
> (XSL-FO 1.1 spec), witch is not yet implemented in FOP.
> Playing with fo:marker should be a workaround.
> 
> Pascal
> 
> [1] http://marc.theaimsgroup.com/?l=fop-user&m=115700779613800&w=2
> 
>> -----Original Message-----
>> From: mikevn123 [mailto:mikev@ci-inc.com] 
>> Sent: Wednesday, October 18, 2006 2:14 PM
>> To: fop-users@xmlgraphics.apache.org
>> Subject: RE: One Page DOcument
>> 
>> 
>> > I have a similar problem as to the one posted before.
>> > 
>> > I've setup two page masters, one to be used for page-position="any" 
>> > and another to be used for page-position="last".
>> > 
>> > When my document is rendered, and it is two or more pages, it works 
>> > great.
>> > When my document is rendered and it is only one page, it uses the 
>> > "any"
>> > page-master.
>> > 
>> > Since there is no "first" defined, I was hoping that the 
>> "last" would 
>> > apply to page 1.
>> > 
>> > I am using FOP 0.92beta.
>> > 
>> > Is there a way to have a single page document take on the 
>> attributes 
>> > of the "last" page?
>> > 
>> > Thanks.
>> 
>> Hi,
>> 1. Can you send a short XSL-FO that demonstrate that?
>> 2. I guess you use a fo:repeatable-page-master-alternatives.
>> you can try to change the fo:conditional-page-master-reference order.
>> 
>> 
>> You guessed right, I am using 
>> fo:repeatable-page-master-alternative and 
>> fo:conditional-page-master-reference.
>> 
>>  <fo:layout-master-set>
>>   <fo:simple-page-master master-name="default-page"
>>                          page-height="11in" 
>>                          page-width="8.50in" 
>>                          margin-top="0.25in" 
>>                          margin-left="0.25in"
>>                          margin-right="0.25in"
>>                          margin-bottom="0.25in">
>> <!-- space needed for header & footer tables -->
>>   <fo:region-body          
>>    region-name="body"
>>    margin-top="0in" 
>>                          margin-bottom="1.50in"/>
>>   <fo:region-before region-name="header" extent="10.0in"/> 
>> <!-- space needed for header table -->
>>   <fo:region-after region-name="footer" extent="1.50in"/> 
>> <!-- space needed for footer table -->
>>   <fo:region-start  extent="0.00in"/>
>>   <fo:region-end    extent="0.00in"/>
>>   </fo:simple-page-master>
>>   
>>   
>>   <fo:simple-page-master master-name="last-page"
>>    page-height="11in" 
>>    page-width="8.50in" 
>>    margin-top="0.25in" 
>>    margin-left="0.25in"
>>    margin-right="0.25in"
>>    margin-bottom="0.25in"> 
>>    <!-- space needed for header & footer tables -->
>>    <fo:region-body          
>>     region-name="body"
>>     margin-top="0in" 
>>     margin-bottom="1.50in"/>
>>    <fo:region-before region-name="header" extent="10.0in"/> 
>> <!-- space needed for header table -->
>>    <fo:region-after  region-name="last-footer" 
>> extent="1.50in"/> <!-- space needed for footer table -->
>>    <fo:region-start  extent="0.00in"/>
>>    <fo:region-end    extent="0.00in"/>
>>   </fo:simple-page-master>
>>   
>>   
>>   <fo:page-sequence-master master-name="all">
>>    <fo:repeatable-page-master-alternatives>
>> 
>>     <fo:conditional-page-master-reference 
>>      page-position="last" master-reference="last-page"/>
>>     
>>     <fo:conditional-page-master-reference 
>>      page-position="any" master-reference="default-page" />
>> 
>>    </fo:repeatable-page-master-alternatives>
>>   </fo:page-sequence-master>
>>  </fo:layout-master-set>
>> 
>> As I said, it works for 2+ pages, but not for one.
>> 
>> Tell me if you want more code.
>> 
>> Thanks.
>> 
>> -Mike
>> --
>> View this message in context: 
>> http://www.nabble.com/One-Page-DOcument-tf2191362.html#a6874870
>> Sent from the FOP - Users mailing list archive at Nabble.com.
>> 
>> 
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: fop-users-unsubscribe@xmlgraphics.apache.org
>> For additional commands, e-mail: fop-users-help@xmlgraphics.apache.org
>> 
>> 
>> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: fop-users-unsubscribe@xmlgraphics.apache.org
> For additional commands, e-mail: fop-users-help@xmlgraphics.apache.org
> 
> 
> 

-- 
View this message in context: http://www.nabble.com/One-Page-DOcument-tf2191362.html#a6876821
Sent from the FOP - Users mailing list archive at Nabble.com.


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


RE: One Page DOcument

Posted by mikevn123 <mi...@ci-inc.com>.
> I have a similar problem as to the one posted before.
> 
> I've setup two page masters, one to be used for page-position="any" 
> and another to be used for page-position="last".
> 
> When my document is rendered, and it is two or more pages, it works 
> great.
> When my document is rendered and it is only one page, it uses the 
> "any"
> page-master.
> 
> Since there is no "first" defined, I was hoping that the "last" would 
> apply to page 1.
> 
> I am using FOP 0.92beta.
> 
> Is there a way to have a single page document take on the attributes 
> of the "last" page?
> 
> Thanks.

Hi,
1. Can you send a short XSL-FO that demonstrate that?
2. I guess you use a fo:repeatable-page-master-alternatives.
you can try to change the fo:conditional-page-master-reference order.


You guessed right, I am using fo:repeatable-page-master-alternative and
fo:conditional-page-master-reference.

 <fo:layout-master-set>
  <fo:simple-page-master master-name="default-page"
                         page-height="11in" 
                         page-width="8.50in" 
                         margin-top="0.25in" 
                         margin-left="0.25in"
                         margin-right="0.25in"
                         margin-bottom="0.25in"> 
<!-- space needed for header & footer tables -->
  <fo:region-body          
   region-name="body"
   margin-top="0in" 
                         margin-bottom="1.50in"/>
  <fo:region-before region-name="header" extent="10.0in"/> <!-- space needed
for header table -->
  <fo:region-after region-name="footer" extent="1.50in"/> <!-- space needed
for footer table -->
  <fo:region-start  extent="0.00in"/>
  <fo:region-end    extent="0.00in"/>
  </fo:simple-page-master>
  
  
  <fo:simple-page-master master-name="last-page"
   page-height="11in" 
   page-width="8.50in" 
   margin-top="0.25in" 
   margin-left="0.25in"
   margin-right="0.25in"
   margin-bottom="0.25in"> 
   <!-- space needed for header & footer tables -->
   <fo:region-body          
    region-name="body"
    margin-top="0in" 
    margin-bottom="1.50in"/>
   <fo:region-before region-name="header" extent="10.0in"/> <!-- space
needed for header table -->
   <fo:region-after  region-name="last-footer" extent="1.50in"/> <!-- space
needed for footer table -->
   <fo:region-start  extent="0.00in"/>
   <fo:region-end    extent="0.00in"/>
  </fo:simple-page-master>
  
  
  <fo:page-sequence-master master-name="all">
   <fo:repeatable-page-master-alternatives>

    <fo:conditional-page-master-reference 
     page-position="last" master-reference="last-page"/>
    
    <fo:conditional-page-master-reference 
     page-position="any" master-reference="default-page" />

   </fo:repeatable-page-master-alternatives>
  </fo:page-sequence-master>
 </fo:layout-master-set>

As I said, it works for 2+ pages, but not for one.

Tell me if you want more code.

Thanks.

-Mike
-- 
View this message in context: http://www.nabble.com/One-Page-DOcument-tf2191362.html#a6874870
Sent from the FOP - Users mailing list archive at Nabble.com.


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


Re: One Page DOcument

Posted by mikevn123 <mi...@ci-inc.com>.
I have a similar problem as to the one posted before.

I've setup two page masters, one to be used for page-position="any" and
another to be used for page-position="last".

When my document is rendered, and it is two or more pages, it works great.
When my document is rendered and it is only one page, it uses the "any"
page-master.

Since there is no "first" defined, I was hoping that the "last" would apply
to page 1.  

I am using FOP 0.92beta.

Is there a way to have a single page document take on the attributes of the
"last" page?

Thanks.
-- 
View this message in context: http://www.nabble.com/One-Page-DOcument-tf2191362.html#a6864617
Sent from the FOP - Users mailing list archive at Nabble.com.


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


Re: One Page DOcument

Posted by Jeremias Maerki <de...@jeremias-maerki.ch>.
You simply run FOP twice. There's two possibilities to approach that:

1. If you're doing this in Java, you can retrieve the number of pages
generated through the Fop object. See http://xmlgraphics.apache.org/fop/0.92/embedding.html#render-info
for more info.

2. In the first run, you can generate Area Tree XML (-at on the
command-line) instead of PDF (or whatever you generate). By inspecting
the generated XML file you can find out how many pages were produced.
This probably won't work reliably in 0.20.5. For 0.92beta and later it's
a good idea to set the "mimic renderer" so you get the same page breaks
as with the original renderer. More info on the area tree XML aka.
intermediate format:
http://xmlgraphics.apache.org/fop/0.92/intermediate.html

For the second run, you have to pass the number of expected pages into
your XSLT stylesheet so it can react as necessary.

HTH

On 31.08.2006 15:34:19 Felipe Villarinho wrote:
> On 8/31/06, Jeremias Maerki <de...@jeremias-maerki.ch> wrote:
> >
> > Either you know yourself from the amount of text
> > if you get beyond the first page, or you have to take a two-phase
> > approach. In the first step, you simply render the document to know how
> > many pages you get and then you render it again and write a different
> > text depending on the number of pages that are expected.
> >
> >
> How can I do this two-phase approach?



Jeremias Maerki


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


Re: One Page DOcument

Posted by Felipe Villarinho <fe...@gmail.com>.
On 8/31/06, Jeremias Maerki <de...@jeremias-maerki.ch> wrote:
>
> Either you know yourself from the amount of text
> if you get beyond the first page, or you have to take a two-phase
> approach. In the first step, you simply render the document to know how
> many pages you get and then you render it again and write a different
> text depending on the number of pages that are expected.
>
>
How can I do this two-phase approach?

Re: One Page DOcument

Posted by Jeremias Maerki <de...@jeremias-maerki.ch>.
Generelly, you have to define a complex page-master using
repeatable-page-master-alternatives and
conditional-page-master-reference. You can find examples in the
examples/fo/pagination directly. The text is then added as children to
static-content elements.

On 30.08.2006 19:14:08 Felipe Villarinho wrote:
> Hello,
> 
> I need to display in the footer of a document different sentences depending
> on which page it is.
> For exemple,
> 1. if it is the last page of the document show "Last Page"

This is addressed by using page-position="last" on the
conditional-page-master-reference. Please note that this is only
available in the latest code directly from the Subversion repository
(FOP Trunk) and may not yet work in every case. It's a new feature which
has not been widely tested and I know there are still a few problems.

> 2. if it is not the last page show "Continue..."

You'd write that in a static-content element for a footer that's on a
simple-page-master which is not used for page-position="first" or
page-position="last".

> 3. if it is the first and only page show "This Document Has Only One Page"

That's where page-position="only" is used. But this is only available
since XSL 1.1 and this feature has not been implemented, yet, in FOP.

> Using markers I did 1 and 2 but I can't figure a way of doing 3.

Ok, markers is probably another way to do it, but page-position="only"
would be the right way. But since that's not available, yet, you'd have
to take a work-around. Either you know yourself from the amount of text
if you get beyond the first page, or you have to take a two-phase
approach. In the first step, you simply render the document to know how
many pages you get and then you render it again and write a different
text depending on the number of pages that are expected.

> Does Anybody knows how to do it?



Jeremias Maerki


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