Package org.apache.fop.viewer

Examples of org.apache.fop.viewer.Translator


    public void viewFO(File fo)
                throws IOException, FOPException, TransformerException {

        //Setup l18n
        String language = System.getProperty("user.language");
        Translator translator = getResourceBundle(
            TRANSLATION_PATH + "resources." + language);
        translator.setMissingEmphasized(false);

        UserMessage.setTranslator(getResourceBundle(
            TRANSLATION_PATH + "messages." + language));

        //Setup renderer
        AWTRenderer renderer = new AWTRenderer(translator);

        //Create preview dialog (target for the AWTRenderer)
        PreviewDialog frame = createPreviewDialog(renderer, translator);
        renderer.setProgressListener(frame);
        renderer.setComponent(frame);

        //Setup Driver
        Driver driver = new Driver();
        driver.setLogger(new ConsoleLogger(ConsoleLogger.LEVEL_INFO));
        driver.setRenderer(renderer);

        try {
            // build FO tree: time
            frame.progress(translator.getString("Build FO tree") + " ...");

            //Load XSL-FO file (you can also do an XSL transformation here)
            TransformerFactory factory = TransformerFactory.newInstance();
            Transformer transformer = factory.newTransformer();
            Source src = new StreamSource(fo);
            Result res = new SAXResult(driver.getContentHandler());
            transformer.transform(src, res);

            //Show page
            frame.progress(translator.getString("Show"));
            frame.showPage();

        } catch (Exception e) {
            frame.reportException(e);
            if (e instanceof FOPException) {
View Full Code Here

TOP

Related Classes of org.apache.fop.viewer.Translator

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.