Package org.apache.fop.apps

Examples of org.apache.fop.apps.Fop


        renderer.setContentHandler(handler);
        renderer.setUserAgent(userAgent);

        userAgent.setRendererOverride(renderer);
       
        Fop fop = fopFactory.newFop(MimeConstants.MIME_FOP_AREA_TREE, userAgent);
        Result res = new SAXResult(fop.getDefaultHandler());
        transformer.transform(src, res);
       
        return (Document)domResult.getNode();
    }
View Full Code Here


        ua.setURIResolver(resolver);
        ua.setBaseURL(foFile.getParentFile().toURL().toString());

        ByteArrayOutputStream baout = new ByteArrayOutputStream();

        Fop fop = fopFactory.newFop(MimeConstants.MIME_PDF, ua, baout);

        Transformer transformer = tfactory.newTransformer(); //Identity transf.
        Source src = new StreamSource(foFile);
        Result res = new SAXResult(fop.getDefaultHandler());
        transformer.transform(src, res);
       
        OutputStream out = new java.io.FileOutputStream(
                new File(backupDir, foFile.getName() + ".pdf"));
        try {
View Full Code Here

        XMLRenderer atrenderer = new XMLRenderer();
        atrenderer.setUserAgent(ua);
        atrenderer.setContentHandler(athandler);
        ua.setRendererOverride(atrenderer);
       
        Fop fop = fopFactory.newFop(ua);

        Transformer transformer = tfactory.newTransformer(); //Identity transf.
        Source src = new StreamSource(fo);
        Result res = new SAXResult(fop.getDefaultHandler());
        transformer.transform(src, res);
       
        Document doc = (Document)domres.getNode();
        saveAreaTreeXML(doc, new File(backupDir, fo.getName() + ".at.xml"));
        return doc;
View Full Code Here

        transformer.setParameter("repeats", new Integer(replicatorRepeats));
       
        OutputStream out = new NullOutputStream(); //write to /dev/nul
        FOUserAgent userAgent = fopFactory.newFOUserAgent();
        userAgent.setBaseURL(foFile.getParentFile().toURL().toExternalForm());
        Fop fop = fopFactory.newFop(MimeConstants.MIME_PDF, userAgent, out);
        Result res = new SAXResult(fop.getDefaultHandler());
       
        transformer.transform(src, res);
       
        System.out.println("Generated " + fop.getResults().getPageCount() + " pages.");
       
    }
View Full Code Here

        FOUserAgent foUserAgent = fopFactory.newFOUserAgent();
        foUserAgent.setCreationDate(new Date(10000));
        MessageDigest outDigest = MessageDigest.getInstance("MD5");
        DigestOutputStream out =
            new DigestOutputStream(new ByteArrayOutputStream(), outDigest);
        Fop fop = fopFactory.newFop(MimeConstants.MIME_PDF, foUserAgent, out);
        InputSource source = new InputSource(new StringReader(fo));
        DigestFilter filter = new DigestFilter("MD5");
        filter.setParent(parserFactory.newSAXParser().getXMLReader());
        filter.setContentHandler(fop.getDefaultHandler());
        filter.parse(source);
        String digestInActual = digestToString(filter.getDigestValue());
        if (!digestIn.equals(digestInActual)) {
            fail("input MD5: was " + digestInActual + ", expected " + digestIn);
        }
View Full Code Here

    /** {@inheritDoc} */
    public void process(InputStream in, Templates templates, OutputStream out)
                throws org.apache.fop.apps.FOPException, java.io.IOException {
        FOUserAgent foUserAgent = fopFactory.newFOUserAgent();
        Fop fop = fopFactory.newFop(this.mime, foUserAgent, out);

        try {
            Transformer transformer;
            if (templates == null) {
                transformer = factory.newTransformer();
            } else {
                transformer = templates.newTransformer();
            }
            Source src = new StreamSource(in);
            Result res = new SAXResult(fop.getDefaultHandler());
            transformer.transform(src, res);
        } catch (TransformerException e) {
            throw new FOPException(e);
        }
    }
View Full Code Here

     */
    public void testFO2PDFWithJAXP() throws Exception {
        FOUserAgent foUserAgent = fopFactory.newFOUserAgent();
        File foFile = new File(getBaseDir(), "test/xml/bugtests/block.fo");
        ByteArrayOutputStream baout = new ByteArrayOutputStream();
        Fop fop = fopFactory.newFop(MimeConstants.MIME_PDF, foUserAgent, baout);
       
        TransformerFactory factory = TransformerFactory.newInstance();
        Transformer transformer = factory.newTransformer(); //Identity transf.
        Source src = new StreamSource(foFile);
        Result res = new SAXResult(fop.getDefaultHandler());
        transformer.transform(src, res);
       
        assertTrue("Generated PDF has zero length", baout.size() > 0);
    }
View Full Code Here

     */
    public void testFO2PSWithJAXP() throws Exception {
        FOUserAgent foUserAgent = fopFactory.newFOUserAgent();
        File foFile = new File(getBaseDir(), "test/xml/bugtests/block.fo");
        ByteArrayOutputStream baout = new ByteArrayOutputStream();
        Fop fop = fopFactory.newFop(MimeConstants.MIME_POSTSCRIPT, foUserAgent, baout);
       
        TransformerFactory factory = TransformerFactory.newInstance();
        Transformer transformer = factory.newTransformer(); //Identity transf.
        Source src = new StreamSource(foFile);
        Result res = new SAXResult(fop.getDefaultHandler());
        transformer.transform(src, res);
       
        assertTrue("Generated PostScript has zero length", baout.size() > 0);
    }
View Full Code Here

     */
    public void testFO2RTFWithJAXP() throws Exception {
        FOUserAgent foUserAgent = fopFactory.newFOUserAgent();
        File foFile = new File(getBaseDir(), "test/xml/bugtests/block.fo");
        ByteArrayOutputStream baout = new ByteArrayOutputStream();
        Fop fop = fopFactory.newFop(MimeConstants.MIME_RTF, foUserAgent, baout);
       
        TransformerFactory factory = TransformerFactory.newInstance();
        Transformer transformer = factory.newTransformer(); //Identity transf.
        Source src = new StreamSource(foFile);
        Result res = new SAXResult(fop.getDefaultHandler());
        transformer.transform(src, res);
       
        assertTrue("Generated RTF has zero length", baout.size() > 0);
    }
View Full Code Here

                    src.getName() + "." + getTargetExtension() + ".png");
            try {
                OutputStream out = new FileOutputStream(tempOut);
                out = new BufferedOutputStream(out);
                try {
                    Fop fop = fopFactory.newFop(getTargetFormat(), userAgent, out);
                    SAXResult res = new SAXResult(fop.getDefaultHandler());
                   
                    Transformer transformer = getTransformer(context);
                    transformer.transform(new StreamSource(src), res);
                } finally {
                    IOUtils.closeQuietly(out);
View Full Code Here

TOP

Related Classes of org.apache.fop.apps.Fop

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.