Package org.apache.fop.cli

Examples of org.apache.fop.cli.InputHandler


        }
    }

    private void render(File foFile, File outFile,
                        String outputFormat) throws FOPException {
        InputHandler inputHandler = new InputHandler(foFile);

        OutputStream out = null;
        try {
            out = new java.io.FileOutputStream(outFile);
            out = new BufferedOutputStream(out);
        } catch (Exception ex) {
            throw new BuildException("Failed to open " + outFile, ex);
        }

        if (task.getLogFiles()) {
            task.log(foFile + " -> " + outFile, Project.MSG_INFO);
        }

        boolean success = false;
        try {
            FOUserAgent userAgent = fopFactory.newFOUserAgent();
            userAgent.setBaseURL(this.baseURL);
            inputHandler.renderTo(userAgent, outputFormat, out);
            success = true;
        } catch (Exception ex) {
            throw new BuildException(ex);
        } finally {
            try {
View Full Code Here


        }
    }

    private void render(File foFile, File outFile,
                        String outputFormat) throws FOPException {
        InputHandler inputHandler = new InputHandler(foFile);
        try {
            renderInputHandler(inputHandler, outFile, outputFormat);
        } catch (Exception ex) {
            logger.error("Error rendering fo file: " + foFile, ex);
        }
View Full Code Here

    }

    private void render(File xmlFile, File xsltFile, File outFile, String outputFormat) {
        //TODO: implement support for XSLT params
        final Vector xsltParams = null;
        InputHandler inputHandler = new InputHandler(xmlFile, xsltFile, xsltParams);
        try {
            renderInputHandler(inputHandler, outFile, outputFormat);
        } catch (Exception ex) {
            logger.error("Error rendering xml/xslt files: " + xmlFile + ", " + xsltFile, ex);
        }
View Full Code Here

                baseURL = xmlFile.getParentFile().toURI().toURL().toExternalForm();
            } catch (Exception e) {
                logger.error("Error setting base directory");
            }

            InputHandler inputHandler = null;
            if (xsl == null) {
                inputHandler = new InputHandler(xmlFile);
            } else {
                inputHandler = new InputHandler(xmlFile,
                                                new File(baseDir + "/"
                                                         + xsl), null);
            }

            FOUserAgent userAgent = fopFactory.newFOUserAgent();
            userAgent.setBaseURL(baseURL);

            userAgent.getRendererOptions().put("fineDetail", new Boolean(false));
            userAgent.getRendererOptions().put("consistentOutput", new Boolean(true));
            userAgent.setProducer("Testsuite Converter");

            String outname = res;
            if (outname.endsWith(".xml") || outname.endsWith(".pdf")) {
                outname = outname.substring(0, outname.length() - 4);
            }
            File outputFile = new File(destdir,
                                       outname + makeResultExtension());

            outputFile.getParentFile().mkdirs();
            OutputStream outStream = new java.io.BufferedOutputStream(
                                 new java.io.FileOutputStream(outputFile));
            logger.debug("ddir:" + destdir + " on:" + outputFile.getName());
            inputHandler.renderTo(userAgent, outputFormat, outStream);
            outStream.close();

            // check difference
            if (compare != null) {
                File f1 = new File(destdir, outname + ".at.xml");
View Full Code Here

        }
    }

    private void render(File foFile, File outFile,
                        String outputFormat, Configuration userConfig) throws FOPException {
        InputHandler inputHandler = new InputHandler(foFile);

        OutputStream out = null;
        try {
            out = new java.io.FileOutputStream(outFile);
            out = new BufferedOutputStream(out);
        } catch (Exception ex) {
            throw new BuildException("Failed to open " + outFile, ex);
        }

        if (task.getLogFiles()) {
            task.log(foFile + " -> " + outFile, Project.MSG_INFO);
        }

        boolean success = false;
        try {
            FOUserAgent userAgent = fopFactory.newFOUserAgent();
            userAgent.setBaseURL(this.baseURL);
            inputHandler.renderTo(userAgent, outputFormat, out);
            success = true;
        } catch (Exception ex) {
            throw new BuildException(ex);
        } finally {
            try {
View Full Code Here

                baseURL = xmlFile.getParentFile().toURL().toExternalForm();
            } catch (Exception e) {
                logger.error("Error setting base directory");
            }

            InputHandler inputHandler = null;
            if (xsl == null) {
                inputHandler = new InputHandler(xmlFile);
            } else {
                inputHandler = new InputHandler(xmlFile,
                                                new File(baseDir + "/"
                                                         + xsl), null);
            }

            FOUserAgent userAgent = fopFactory.newFOUserAgent();
            userAgent.setBaseURL(baseURL);

            userAgent.getRendererOptions().put("fineDetail", new Boolean(false));
            userAgent.getRendererOptions().put("consistentOutput", new Boolean(true));
            userAgent.setProducer("Testsuite Converter");

            String outname = res;
            if (outname.endsWith(".xml") || outname.endsWith(".pdf")) {
                outname = outname.substring(0, outname.length() - 4);
            }
            File outputFile = new File(destdir,
                                       outname + makeResultExtension());

            outputFile.getParentFile().mkdirs();
            OutputStream outStream = new java.io.BufferedOutputStream(
                                 new java.io.FileOutputStream(outputFile));
            logger.debug("ddir:" + destdir + " on:" + outputFile.getName());
            inputHandler.renderTo(userAgent, outputFormat, outStream);
            outStream.close();

            // check difference
            if (compare != null) {
                File f1 = new File(destdir, outname + ".at.xml");
View Full Code Here

        FOUserAgent foUserAgent = fopFactory.newFOUserAgent();
        File xmlFile = new File(getBaseDir(), "test/xml/1.xml");
        File xsltFile = new File(getBaseDir(), "test/xsl/doc.xsl");
        ByteArrayOutputStream baout = new ByteArrayOutputStream();
       
        InputHandler handler = new InputHandler(xmlFile, xsltFile, null);
        handler.renderTo(foUserAgent, MimeConstants.MIME_PDF, baout);
       
        assertTrue("Generated PDF has zero length", baout.size() > 0);
    }
View Full Code Here

            params.add("admon.graphics.path");
            params.add(configPath.resolve("docbook/images/").toUri().toString());
            params.add("callout.graphics.path");
            params.add(configPath.resolve("docbook/images/callouts/").toUri().toString());

            InputHandler handler = new InputHandler(bookXml.toFile(), configPath.resolve("docbook-config/fo-pdf.xsl").toFile(), params);

            FopFactory fopFactory = FopFactory.newInstance();

            fopFactory.setUserConfig(configPath.resolve("docbook-config/fop.xconf").toFile());
            try (FileOutputStream outputStream = new FileOutputStream(currentPath.resolve("book.pdf").toFile());) {
                FOUserAgent userAgent = new FOUserAgent(fopFactory);
                handler.renderTo(userAgent, "application/pdf", outputStream);
            } finally {

                indikatorService.completeCycle();

                asciiDocController.setLastConvertedFile(Optional.of(currentPath.resolve("book.pdf")));
View Full Code Here

            String tabText = current.getCurrentTabText().replace("*", "").trim();
            String tabTextDocbook = tabText.concat(".xml");
            Path articlePath = currentPath.resolve(tabTextDocbook);
            Files.write(articlePath, docBook.getBytes(Charset.forName("UTF-8")), CREATE, TRUNCATE_EXISTING, WRITE);
            InputHandler handler = new InputHandler(articlePath.toFile(), configPath.resolve("docbook-config/fo-pdf.xsl").toFile(), params);

            FopFactory fopFactory = FopFactory.newInstance();

            fopFactory.setUserConfig(configPath.resolve("docbook-config/fop.xconf").toFile());
            try (FileOutputStream outputStream = new FileOutputStream(currentPath.resolve(tabText.concat(".pdf")).toFile());) {
                FOUserAgent userAgent = new FOUserAgent(fopFactory);
                handler.renderTo(userAgent, "application/pdf", outputStream);
            } finally {

                indikatorService.completeCycle();

                asciiDocController.setLastConvertedFile(Optional.of(currentPath.resolve(tabText.concat(".pdf"))));
View Full Code Here

        }
    }

    private void render(File foFile, File outFile,
                        String outputFormat) throws FOPException {
        InputHandler inputHandler = new InputHandler(foFile);

        OutputStream out = null;
        try {
            out = new java.io.FileOutputStream(outFile);
        } catch (Exception ex) {
            throw new BuildException("Failed to open " + outFile, ex);
        }

        if (task.getLogFiles()) {
            task.log(foFile + " -> " + outFile, Project.MSG_INFO);
        }

        try {
            FOUserAgent userAgent = new FOUserAgent();
            userAgent.setBaseURL(this.baseURL);
            org.apache.fop.apps.Fop fop = new org.apache.fop.apps.Fop(
                    outputFormat, userAgent);
            fop.setOutputStream(out);
            inputHandler.render(fop);
        } catch (Exception ex) {
            throw new BuildException(ex);
        } finally {
            try {
                out.close();
View Full Code Here

TOP

Related Classes of org.apache.fop.cli.InputHandler

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.