I do a similar thing for very large PDF files.
(I save the individual .FO files for fast formatting into user selected options for various pages.)
You may have refinements needed for you process which I miss but here is a 'simple' solution that keeps memory overhead low as well.


The way I do this is to put all necessary FO into each individual file but construct a master 'index' XML document that contains references to each individual file required.
This should contain any summary information required for TOCs, cross references etc.


I then process this master document with a stylesheet that produces output FO, usually with many separate page-sequence (usually one per sub-file) and, using the XSLT 'document' function parses each sub document and includes just the relevant nodetrees (for my purposes usually just the page-sequences as I use an overall set of common master page-masters).
(The nice thing is that this 'combining' stylesheet can be very generic and used for assembling many different documents.)


This approach also makes it easy to assemble a combined output from selected, different sets of input subfiles (and also allows some limited reformatting if differing page sizes are required).

I've used this to process documents that would actually be several hundred megabytes in size if produced as a single FO file.

In case it helps to make things clearer here is an example of a very simple master stylesheet to merge separate FO files by processing a master XML file containing the names of the files to be processed.



The FO files names are stored in /SECTIONS/SECTION/TABLES/TABLE/TABFIL/@href_fo.

'dl_dotags.xsl' processes a file containing layout parameters and defines the template DL_FO_ATTR.



1 <xsl:stylesheet version="1.1" xmlns:xsl="http://www.w3.org/1999/XSL/Transform";

  2 xmlns:fo="http://www.w3.org/1999/XSL/Format";

  3 xmlns:dl='http://www.datalucid.com/'

  4 >

5 <xsl:output method="xml" encoding="UTF-8" omit-xml-declaration='yes' indent='yes'/>

  6 <xsl:decimal-format name="nan0" NaN="0"/>

  7

  8 <!-- 11.27in = 29cm ??? -->

  9 <xsl:param name='PAGEWID_CM' select='29'/>

 10 <xsl:include href='dl_dotags.xsl'/>

 11 <!-- ############################################################ -->

 12 <!-- XSLT for DLXML - Author: Mike Trotman - 03/10/2002 -->

 13 <!-- ############################################################ -->

 14 <xsl:template match="/">

 15

 16 <fo:root xmlns:fo='http://www.w3.org/1999/XSL/Format'>

 17

 18 <fo:layout-master-set>

 19 <fo:simple-page-master master-name='first'>

20 <xsl:call-template name='DL_FO_ATTR'><xsl:with-param name='RULE' select='"page"'/></xsl:call-template>

 21 <fo:region-body>

22 <xsl:call-template name='DL_FO_ATTR'><xsl:with-param name='RULE' select='"region-body"'/></xsl:call-template>

 23 </fo:region-body>

 24 <fo:region-before>

25 <xsl:call-template name='DL_FO_ATTR'><xsl:with-param name='RULE' select='"region-before"'/></xsl:call-template>

 26 </fo:region-before>

 27 <fo:region-after>

28 <xsl:call-template name='DL_FO_ATTR'><xsl:with-param name='RULE' select='"region-after"'/></xsl:call-template>

 29 </fo:region-after>

 30 </fo:simple-page-master>

 31 </fo:layout-master-set>

 32

 33 <xsl:apply-templates select="SECTIONS/SECTION"/>

 34

 35 </fo:root>

 36 </xsl:template>

 37 <!-- ############################################################ -->

 38 <xsl:template match="SECTION">

 39 <xsl:variable name='sid' select='count(preceding::SECTION)'/>

 40 <xsl:for-each select='TABLES/TABLE'>

 41         <xsl:choose>

 42         <xsl:when test='TABFIL/@href_fo'>

43 <xsl:message>FO Table lookup <xsl:value-of select="@tableno"/></xsl:message>

44 <xsl:apply-templates select='document(TABFIL/@href_fo)/*' mode='FO'/>

 45         </xsl:when>

 46         </xsl:choose>

 47 </xsl:for-each>

 48 </xsl:template>

 49 <!-- ############################################################ -->

 50 <xsl:template match='fo:root' mode='FO'>

 51

 52 <xsl:copy-of select='./fo:page-sequence'/>

 53

 54 </xsl:template>

 55 <!-- ############################################################ -->

 56 </xsl:stylesheet>






Jay Chiu wrote:

We need to generate pdf report file based on a pdf cover page
and a few generated fo files. I would like to ask what is the
best approach for this.


Right now, we have an application to use xslt to generate fo
file, and then fop to pdf file for each different report. But
the client want to put all the reports together into a single
pdf file.


So I am thinking to use fop api to implement this feature. I
guess what I need to do is:
(1) for each fo/pdf file, I need to set the initial page number
when calling fop process api and retrieve the number of pages
for that fo/pdf at the end of fop process.
(2) I need to call fop to append a fo/pdf after the previous
processing.

Can someone tell me if this is doable, which fop api to call?

Thanks a lot.

Jay

________________________________________________
Get your own "800" number
Voicemail, fax, email, and a lot more
http://www.ureach.com/reg/tag

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]





--------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]



Reply via email to