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 "Chakravarty, Abhishek" <Ab...@accidentfund.com> on 2009/01/22 22:16:37 UTC

know number of pages in end pdf without actually making it

Is there a way to know the number of pages in the final pdf document
generated from FOP without actually doing its generation?

The XML content being pulled in for the pdf generation is dynamic and so
the number of pages being generated at the end would change too based on
this. Was wondering if there was someway of grabbing the number of pages
being generated in a 2 pass sequence.

As in
1st pass:  XML + XSL -> FO
2nd pass: FO -> PDF

Any help would be appreciated.

Regards
Abhishek
---------------------------------------------------------------------
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


Re: know number of pages in end pdf without actually making it

Posted by Andreas Delmelle <an...@telenet.be>.
On 22 Jan 2009, at 22:16, Chakravarty, Abhishek wrote:

> Is there a way to know the number of pages in the final pdf document
> generated from FOP without actually doing its generation?

Depends on what you mean by "generation". The FO content at least has  
to be parsed and processed partly (layout) before FOP can tell you how  
many pages there will be.
The actual rendering of the resulting document can be postponed,  
currently still by using the intermediate area tree XML (see: http://xmlgraphics.apache.org/fop/0.95/intermediate.html)


> The XML content being pulled in for the pdf generation is dynamic  
> and so
> the number of pages being generated at the end would change too  
> based on
> this. Was wondering if there was someway of grabbing the number of  
> pages
> being generated in a 2 pass sequence.
>
> As in
> 1st pass:  XML + XSL -> FO
> 2nd pass: FO -> PDF

In Java code, you could generate the FO (your first pass), and store  
it on disk. In the same pass, you could immediately also echo the  
result to FOP to render to the intermediate format (dispatching the  
SAX events to multiple ContentHandlers). In a second pass, you can  
then merge information from the area tree with the FO.

The same can be done via the command-line, but it would be a multi- 
pass looking like:

1. XML + XSLT -> FO
2. FO -> Area Tree
3a. FO + XSLT -> PDF, or
3b. Area Tree + XSLT -> PDF

Where in 3a (resp. 3b) the necessary information can be extracted from  
the Area Tree (resp. FO) by means of XSLT's document() function.

HTH!

Andreas

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