Loading ...
Sorry, an error occurred while loading the content.

5547Re: how to set fop in quiet mode

Expand Messages
  • tlange051264
    Jun 14, 2004
      Hi,

      this is really simple. Just initialize the new ConsoleLogger with
      ConsoleLogger.DISABLED or ERROR or FATAL. Depends on what messages you
      want to get.
      The example below converts a DOM into a PDF-file without writing it to
      XML before, using the ConsoleLogger-Options.

      public static void convertDom2PdfFile(org.jdom.Document doc,
      String xsltFile, String pdfFile) throws Exception{
      Driver driver = new Driver();

      //Setup logger
      //Logger logger = new ConsoleLogger(ConsoleLogger.LEVEL_INFO);
      Logger logger = new ConsoleLogger(ConsoleLogger.LEVEL_WARN);
      driver.setLogger(logger);
      MessageHandler.setScreenLogger(logger);

      //Setup Renderer (output format)
      driver.setRenderer(Driver.RENDER_PDF);

      //Setup output
      OutputStream out = new java.io.FileOutputStream(pdfFile);

      try {
      driver.setOutputStream(out);

      //Setup XSLT
      TransformerFactory factory = TransformerFactory.
      newInstance();
      Transformer transformer = factory.newTransformer(new
      StreamSource(xsltFile));

      //Setup input for XSLT transformation
      JDOMSource in = new JDOMSource(doc);

      //Resulting SAX events (the generated FO) must be piped
      through to FOP
      Result res = new SAXResult(driver.getContentHandler());

      //Start XSLT transformation and FOP processing
      transformer.transform(in, res);
      }catch (Exception e){
      VmtEnv.writeSystemOut("Exception in DomConverter.
      convertDom2PdfStream:" + e.getMessage());
      out.close();
      throw e;
      } finally {
      out.close();
      }
      }

      Bye Torsten

      --- In XSL-FO@yahoogroups.com, "Ben Abdallah" <mourad.benabdallah@t...
      > wrote:
      > i have embedded fop in a java project and i don't knoww how to let
      > it work in quiet mode, any one know how?
    • Show all 3 messages in this topic