what version of FOP do you use?
try this code.
it works perfectly with 0.20.3 FOP

public static void execWFop(String xmlFile, String xslFile, String outputFile){
try{


try {
javax.xml.transform.stream.StreamSource xmlSource=new javax.xml.transform.stream.StreamSource(new java.io.File(xmlFile));
javax.xml.transform.stream.StreamSource xslSource=new javax.xml.transform.stream.StreamSource(new java.io.File(xslFile));
javax.xml.transform.Transformer transformer=javax.xml.transform.TransformerFactory.newInstance()
.newTransformer(xslSource);
transformer.setURIResolver(new TTURIResolver());
org.apache.fop.apps.Driver driver=new org.apache.fop.apps.Driver();
driver.setOutputStream(new java.io.FileOutputStream(outputFile));
driver.setRenderer(org.apache.fop.apps.Driver.RENDER_PDF);
transformer.transform(xmlSource,
new javax.xml.transform.sax.SAXResult(driver.getContentHandler()));


     System.exit(2);
    }
   catch( Exception e ) {
     e.printStackTrace(System.out);
   }
}

BR,
Fishy


Marianne von den Driesch und Viktor Goebel wrote:

We have the following problem using FOP:

First we tried to embed FOP into a small java programm:

package TestPackage;

import java.io.*;

import javax.servlet.*;
import javax.servlet.http.*;

import org.xml.sax.InputSource;
import org.xml.sax.XMLReader;

import org.apache.fop.apps.Driver;
import org.apache.fop.apps.Version;
import org.apache.fop.apps.*;

import org.apache.log.*;

public class Test {

   public static void main(String[] args) throws Exception {

   File fxml=new File("D:\\xslfoRef.xml");
   File fxsl=new File("D:\\xml2pdf.xsl");
   File fpdf=new File("D:\\ttt.pdf");

   Logger log;
   Hierarchy hierarchy = Hierarchy.getDefaultHierarchy();
   log = hierarchy.getLoggerFor("fop");
   log.setPriority(Priority.WARN);

   Driver dr=new Driver();
   dr.setLogger(log);
   dr.setRenderer(Driver.RENDER_PDF);
   InputHandler ih=new XSLTInputHandler(fxml,fxsl);
   XMLReader p=ih.getParser();
   dr.setOutputStream(new FileOutputStream(fpdf));
   dr.render(p,ih.getInputSource());

 }
}

The program can be compiled without any problems, but the pdf-file has 0
bytes. What is wrong?

We tried also to start FOP from the command line under dos and linux with the
parameters  xslfoRef.xml and xml2pdf.xsl. The error message was :   "Master
-reference" for "fo:page -sequence" matches no "simple -page -master" or
"page -sequence -master".

Do you have any idea??

Thanks for your help,
Viktor und Marianne.








Reply via email to