W3C home > Mailing lists > Public > www-xsl-fo@w3.org > October 2004

page-count

From: Marc.Sauber <marc.sauber@yellowtelecom.be>
Date: Tue, 26 Oct 2004 13:17:19 +0200
Message-Id: <200410261111.i9QBBPR03421@guri.is.scarlet.be>
To: <www-xsl-fo@w3.org>
 
Hi,
I would like to get and store the complete
number of pages of my document.
 
I created a library (jar file)
with this (found on http://xml.apache.org/fop/)
            import org.apache.fop.apps.*;
import org.xml.sax.*;
import java.io.*;
import javax.xml.transform.*;
import javax.xml.transform.sax.*;
import javax.xml.transform.stream.*;
 
class rendtest {
 
  public static void main(String args[]) {
    try {
      Driver driver=new Driver();
      driver.setOutputStream(new FileOutputStream(args[2]));
      driver.setRenderer(Driver.RENDER_PDF);
      Transformer transformer=TransformerFactory.newInstance()
        .newTransformer(new StreamSource(new File(args[1])));
      transformer.setParameter("page-count","#");
      transformer.transform(new StreamSource(new File(args[0])),
        new SAXResult(driver.getContentHandler()));
      String pageCount=Integer.toString(driver.getResults().getPageCount());
      driver=new Driver();
      driver.setOutputStream(new FileOutputStream(args[2]));
      driver.setRenderer(Driver.RENDER_PDF);
      transformer=TransformerFactory.newInstance()
        .newTransformer(new StreamSource(new File(args[1])));
      transformer.setParameter("page-count",pageCount);
      transformer.transform(new StreamSource(new File(args[0])),
        new SAXResult(driver.getContentHandler()));
    }
    catch( Exception e) {
      e.printStackTrace();
    }
  }
}
 
but I can't use it on my xsl file.
 
How can I use page-count on my file ?
Or Is there a better way to do ?
 
Thank in advance.
 
Marc
marc.sauber@yellowtelecom.be
 






image001.gif
(image/gif attachment: image001.gif)

Received on Tuesday, 26 October 2004 11:12:46 GMT

This archive was generated by hypermail 2.2.0+W3C-0.50 : Wednesday, 3 October 2007 16:06:13 GMT