Package org.foray.core

Examples of org.foray.core.FOraySession


     */
    public void convertFO2PDF(final URL fo, final File pdf) throws IOException,
            FOrayException {

        // Setup FOraySession
        final FOraySession session = FOraySpecific.makeFOraySession(null);

        // Setup FOrayDocument
        final InputSource inputSource = new InputSource(fo.openStream());
        final FOrayDocument document = new FOrayDocument(session, inputSource,
                null);

        //Setup Renderer
        final OutputStream out = new FileOutputStream(pdf);
        final OutputTarget renderer = OutputTargetFactory.makeOutputTarget(
                OutputTargetType.PDF, null, out, session.getLogger(),
                session.getGraphicServer());

        //Setup FOrayTarget
        new FOrayTarget(document, renderer, null, out);

        // Start the processing.
        session.process();
    }
View Full Code Here


                this.log.error("Error setting base directory");
            } catch (final ConfigurationException e) {
                this.log.error("Error setting base directory");
            }

            final FOraySession session = FOraySpecific.makeFOraySession(
                    configuration);

            FOrayDocument document = null;
            if (xsl == null) {
                InputSource inputSource = null;
                inputSource = new InputSource(xmlFile.toURI().toURL().openStream());
                document = new FOrayDocument(session, inputSource, null);
            } else {
                document = new FOrayDocument(session, xmlFile.toURI().toURL(),
                        URLFactory.createURL(this.baseDir + "/" + xsl));
            }


            String outname = xmlFile.getName();
            if (outname.endsWith(".xml")) {
                outname = outname.substring(0,
                        outname.length() - ".xml".length());
            }
            String extension;
            if (this.outputPDF) {
                extension = ".pdf";
            } else {
                extension = ".at.xml";
            }
            final BufferedOutputStream bos = new BufferedOutputStream(
                    new FileOutputStream(new File(this.destdir,
                            outname + extension)));
            OutputTargetType rendererType = null;
            if (this.outputPDF) {
                rendererType = OutputTargetType.PDF;
            } else {
                rendererType = OutputTargetType.XML;
            }

            final OutputConfig renderOptions = new OutputConfig();
            renderOptions.setFineDetail(Boolean.FALSE, SessionConfig.PRECEDENCE_DEFAULT);
            renderOptions.setConsistentOutput(Boolean.TRUE, SessionConfig.PRECEDENCE_DEFAULT);
            final OutputTarget renderer = OutputTargetFactory.makeOutputTarget(
                    rendererType, renderOptions, bos, session.getLogger(),
                    session.getGraphicServer());

            new FOrayTarget(document, renderer, null, bos);

            this.log.debug("ddir:" + this.destdir + " on:" + outname + ".pdf");
            session.process();

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

    public void convertXML2PDF(final File xml, final File xslt, final File pdf)
                throws FOrayException {

        // Setup FOraySession
        final SessionConfig config = new SessionConfig();
        final FOraySession session = FOraySpecific.makeFOraySession(config);

        // Setup FOrayDocument
        // Setup JAXP transformation
        final TransformerFactory factory = TransformerFactory.newInstance();
        Transformer transformer;
        try {
            transformer = factory.newTransformer(new StreamSource(xslt));
        } catch (final TransformerConfigurationException e) {
            throw new FOrayException(e);
        }
        // Setup JAXP input source
        final Source source = new StreamSource(xml);
        /*
         * Create the FOrayDocument using the JAXP constructor. Resulting SAX
         * events (the generated FO) will be piped through to FOray.
         */
        final FOrayDocument document = new FOrayDocument(session, transformer,
                source);

        //Setup Renderer
        OutputStream out;
        try {
            out = new FileOutputStream(pdf);
        } catch (final FileNotFoundException e) {
            throw new FOrayException(e);
        }
        final OutputTarget renderer = OutputTargetFactory.makeOutputTarget(
                OutputTargetType.PDF, null, out, session.getLogger(),
                session.getGraphicServer());

        //Setup FOrayTarget
        new FOrayTarget(document, renderer, null, out);

        // Start the processing.
        session.process();
    }
View Full Code Here

     */
    public void convertProjectTeam2PDF(final ProjectTeam team, final File xslt,
            final File pdf) throws FOrayException {

        // Setup FOraySession
        final FOraySession session = FOraySpecific.makeFOraySession(null);

        // Setup FOrayDocument
        // Setup JAXP transformation
        final TransformerFactory factory = TransformerFactory.newInstance();
        Transformer transformer;
        try {
            transformer = factory.newTransformer(new StreamSource(xslt));
        } catch (final TransformerConfigurationException e) {
            throw new FOrayException(e);
        }
        // Setup JAXP input source
        final Source source = team.getSourceForProjectTeam();
        /*
         * Create the FOrayDocument using the JAXP constructor. Resulting SAX
         * events (the generated FO) will be piped through to FOray.
         */
        final FOrayDocument document = new FOrayDocument(session, transformer,
                source);

        //Setup Renderer
        OutputStream out;
        try {
            out = new FileOutputStream(pdf);
        } catch (final FileNotFoundException e) {
            throw new FOrayException(e);
        }
        final OutputTarget renderer = OutputTargetFactory.makeOutputTarget(
                OutputTargetType.PDF, null, out, session.getLogger(),
                session.getGraphicServer());

        //Setup FOrayTarget
        new FOrayTarget(document, renderer, null, out);

        // Start the processing.
        session.process();
    }
View Full Code Here

        userMessage.setTranslator(getResourceBundle(
                DemoAWTViewer.TRANSLATION_PATH + "messages." + language));
        // TODO: userMessage doesn't seem to be used anywhere.

        //Setup FOraySession
        final FOraySession session = FOraySpecific.makeFOraySession(null);

        //Setup FOrayDocument
        final InputSource inputSource = new InputSource(fo.openStream());
        final FOrayDocument document = new FOrayDocument(session, inputSource,
                null);
View Full Code Here

     */
    protected FOraySession setupSession(final HttpServletResponse response)
            throws FOrayException {
        response.setContentType(getContentType());
        // Setup FOraySession
        final FOraySession session = FOraySpecific.makeFOraySession(null);
        return session;
    }
View Full Code Here

     * @throws ServletException For exceptions during processing.
     */
    public void renderFO(final InputSource inputHandler,
            final HttpServletResponse response) throws ServletException {
        try {
            final FOraySession session = setupSession(response);
            final FOrayDocument document = setupSAXDocument(session,
                    inputHandler);

            // Setup the Renderer
            final ByteArrayOutputStream output = new ByteArrayOutputStream();
            final OutputTarget renderer = OutputTargetFactory.makeOutputTarget(
                    OutputTargetType.PDF, null, output,
                    session.getLogger(), session.getGraphicServer());

            // Setup FOrayTarget
            new FOrayTarget(document, renderer, null, output);

            // Run the FOraySession
            session.process();

            final byte[] content = output.toByteArray();
            response.setContentLength(content.length);
            response.getOutputStream().write(content);
            response.getOutputStream().flush();
View Full Code Here

            final HttpServletResponse response) throws ServletException {
        try {
            response.setContentType("application/pdf");

            // Setup FOraySession
            final FOraySession session = FOraySpecific.makeFOraySession(null);

            // Setup FOrayDocument
            final TransformerFactory factory = TransformerFactory.newInstance();
            final Transformer transformer = factory.newTransformer(
                    new StreamSource(xslFile));
            final Source source = new StreamSource(xmlFile);
            final FOrayDocument document = new FOrayDocument(session,
                    transformer, source);

            // Setup the Renderer
            final ByteArrayOutputStream output = new ByteArrayOutputStream();
            final OutputTarget renderer = OutputTargetFactory.makeOutputTarget(
                    OutputTargetType.PDF, null, output,
                    session.getLogger(), session.getGraphicServer());

            // Setup FOrayTarget
            new FOrayTarget(document, renderer, null, output);

            // Run the FOraySession
            session.process();

            final byte[] content = output.toByteArray();
            response.setContentLength(content.length);
            response.getOutputStream().write(content);
            response.getOutputStream().flush();
View Full Code Here

        } catch (final IOException e) {
            throw new FOrayException(e);
        }

        final SessionConfig configuration = getOptions().getSessionConfig();
        final FOraySession session = FOraySpecific.makeFOraySession(
                configuration);

        this.document = new FOrayDocument(session, getInputSource(), null);

        final OutputConfig renderOptions =
View Full Code Here

     * {@inheritDoc}
     */
    public void renderFO(final InputSource inputSource,
            final HttpServletResponse response) throws ServletException {
        try {
            final FOraySession session = setupSession(response);
            final FOrayDocument document = setupSAXDocument(session,
                    inputSource);
            setupTarget(document);
            session.process();
            reportOK(response);
        } catch (final FOrayException ex) {
            throw new ServletException(ex);
        }
    }
View Full Code Here

TOP

Related Classes of org.foray.core.FOraySession

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.