Question

I am trying to generate pdf using Apache FOP. Is this possible to create both A3 and A4 size pages in a Single pdf file. Apparently FOP using below setting from xconf and applying to all the pages. A working example will help. Thanks.

Was it helpful?

Solution

You could have 2 different page masters defined each having size. Use different page masters as needed on each page sequence.

For example the below code displays how to define and use different page masters:

     <fo:layout-master-set>
    <fo:simple-page-master master-name="PageMaster-A4"
          page-height="11.00in" page-width="8.50in" margin="1cm"> 
      <fo:region-body margin="15mm 5mm 5mm 5mm"/>
      <fo:region-before extent="8cm"/>
      <fo:region-after extent="1.5cm"/>
    </fo:simple-page-master>

    <fo:simple-page-master master-name="PageMaster-A3"
          page-height="11.00in" page-width="8.50in" margin="1cm"> 
                                //define required page size and margins..
      <fo:region-body margin="10mm 5mm 5mm 10mm"/>
      <fo:region-before extent="5cm"/>
      <fo:region-after extent="6mm"/>
    </fo:simple-page-master>

  </fo:layout-master-set>

 <fo:page-sequence master-reference="PageMaster-A4">
   <fo:flow flow-name="xsl-region-body">

       // TBD your page content. 

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

There are many tutorials available on how to define and use different page masters.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top