Как обрабатывать сообщения журнала Apache FOP FopConfParser - PullRequest
0 голосов
/ 21 ноября 2018

Как описано в Apache FOP: встраивание и Apache FOP: EventsProcessing Я создаю свой класс CreateReport для создания pdf-файла и обработки событий обработки.Но есть следующие сообщения, которые не были прослушаны слушателем:

Ноя.21, 2018 4:41:09 NACHM.org.apache.fop.apps.FopConfParser configure ИНФОРМАЦИЯ: Высота страницы по умолчанию установлена ​​на: 11in

Nov.21, 2018 4:41:09 NACHM.org.apache.fop.справиться?Спасибо за вашу поддержку!

Это мой класс:

class CreateReport {
  static String javaFOPconfName;
  static FopFactory fopFactory;
  static{
     javaFOPconfName = "myFop.xconf";
     // Construct a FopFactory by specifying a reference to the configuration file
     // (reuse if you plan to render multiple documents!)
     try {
          fopFactory = FopFactory.newInstance(new File(javaFOPconfName));
     } catch (Exception ex) {
          System.out.println("FOP Factory Exception: "+ ex.getMessage());
  }   
static void createPDFReport (String xmlReportName) {
    String xslReportName = "myReport.xsl";
    String pdfReportName = "myReport.pdf";
    // see https://xmlgraphics.apache.org/fop/2.3/embedding.html
    try (OutputStream pdf = new FileOutputStream( pdfReportName )){
        // Set up output stream
        // Construct fop with desired output format
        Fop fop = fopFactory.newFop(MimeConstants.MIME_PDF, pdf);
        FOUserAgent foUserAgent = fop.getUserAgent();
        foUserAgent.getEventBroadcaster().addEventListener(new SysOutEventListener());
        // Setup input and output for XSLT transformation
        // Setup input stream
        Source xml = new StreamSource( xmlReportName );
        Source xsl = new StreamSource( xslReportName );
        // Resulting SAX events (the generated FO) must be piped through to FOP
        Result sax = new SAXResult(fop.getDefaultHandler());
        // Setup JAXP using identity transformer
        TransformerFactory factory = TransformerFactory.newInstance();
        Transformer transformer = factory.newTransformer(xsl);
        // Start XSLT transformation and FOP processing
        transformer.transform( xml, sax );
    } catch (Exception ex) {
        System.out.println("FOP Factory Exception: "+ ex.getMessage());
    }
}
// A simple event listener that writes the events to stdout and stderr.
static class SysOutEventListener implements EventListener {
    public void processEvent(Event event) {
        String msg = EventFormatter.format(event);
        EventSeverity severity = event.getSeverity();
        if (severity == EventSeverity.INFO) {
            System.out.println("my[INFO ] " + msg);
        } else if (severity == EventSeverity.WARN) {
            System.out.println("my[WARN ] " + msg);
        } else if (severity == EventSeverity.ERROR) {
            System.err.println("my[ERROR] " + msg);
        } else if (severity == EventSeverity.FATAL) {
            System.err.println("my[FATAL] " + msg);
        } else {
            assert false;
        }
    }
 }
Добро пожаловать на сайт PullRequest, где вы можете задавать вопросы и получать ответы от других членов сообщества.
...