Package org.apache.fop.apps

Examples of org.apache.fop.apps.FOUserAgent


        OutputStream out = new java.io.FileOutputStream(pdffile);
        out = new java.io.BufferedOutputStream(out);
        try {
            //Setup fonts and user agent
            FontInfo fontInfo = new FontInfo();
            FOUserAgent userAgent = fopFactory.newFOUserAgent();

            //Construct the AreaTreeModel that will received the individual pages
            AreaTreeModel treeModel = new RenderPagesModel(userAgent,
                    MimeConstants.MIME_PDF, fontInfo, out);
           
View Full Code Here


       
        OutputStream out = null;
        Fop fop;
       
        try {
            FOUserAgent foUserAgent = fopFactory.newFOUserAgent();
            // configure foUserAgent as desired
   
            // Setup output stream.  Note: Using BufferedOutputStream
            // for performance reasons (helpful with FileOutputStreams).
            out = new FileOutputStream(pdf);
View Full Code Here

        this.fopFactory = fopFactory;
        this.remaining = remaining;
    }

    public void process(Exchange exchange) throws Exception {
        FOUserAgent userAgent = fopFactory.newFOUserAgent();
        Map<String, Object> headers = exchange.getIn().getHeaders();
        setRenderParameters(userAgent, headers);
        setEncryptionParameters(userAgent, headers);

        String outputFormat = getOutputFormat(exchange);
View Full Code Here

            protected Property convertPropertyDatatype(
                    Property p, PropertyList propertyList, FObj fo) throws PropertyException {
                String nameval = p.getNCname();
                if (nameval != null) {
                    FObj fobj = (fo == null ? propertyList.getFObj() : fo);
                    FOUserAgent ua = (fobj == null ? null : fobj.getUserAgent());
                    return ColorProperty.getInstance(ua, nameval);
                }
                return super.convertPropertyDatatype(p, propertyList, fo);
            }
        };
View Full Code Here

            IOUtils.closeQuietly(out);
        }
    }
   
    private FOUserAgent createUserAgent() {
        FOUserAgent userAgent = fopFactory.newFOUserAgent();
        try {
            userAgent.setBaseURL(testDir.toURL().toExternalForm());
        } catch (MalformedURLException e) {
            //ignore, won't happen
        }
        return userAgent;
    }
View Full Code Here

        //Set up XMLRenderer to render to a DOM
        TransformerHandler handler = tFactory.newTransformerHandler();
        DOMResult domResult = new DOMResult();
        handler.setResult(domResult);
       
        FOUserAgent userAgent = createUserAgent();

        //Create an instance of the target renderer so the XMLRenderer can use its font setup
        Renderer targetRenderer = userAgent.getRendererFactory().createRenderer(
                userAgent, MimeConstants.MIME_PDF);
       
        XMLRenderer renderer = new XMLRenderer();
        renderer.mimicRenderer(targetRenderer);
        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);
       
View Full Code Here

    }
   
    private void parseAndRender(Source src, OutputStream out, String mime) throws Exception {
        AreaTreeParser parser = new AreaTreeParser();
               
        FOUserAgent userAgent = createUserAgent();
        FontInfo fontInfo = new FontInfo();
        AreaTreeModel treeModel = new RenderPagesModel(userAgent,
                mime, fontInfo, out);
        parser.parse(src, treeModel, userAgent);
        treeModel.endDocument();
View Full Code Here

        DOMResult domResult = new DOMResult();
        handler.setResult(domResult);
        XMLRenderer renderer = new XMLRenderer();
        renderer.setContentHandler(handler);

        FOUserAgent userAgent = createUserAgent();
        userAgent.setRendererOverride(renderer);
        renderer.setUserAgent(userAgent);

        FontInfo fontInfo = new FontInfo();
        AreaTreeModel treeModel = new RenderPagesModel(userAgent,
                MimeConstants.MIME_FOP_AREA_TREE, fontInfo, null);
View Full Code Here

    public void testFO1b() throws Exception {
        innerTestFO1(true);
    }
   
    private void innerTestFO1(boolean withStream) throws Exception {
        FOUserAgent ua = fopFactory.newFOUserAgent();

        File foFile = new File(getBaseDir(), "test/xml/uri-resolution1.fo");
       
        MyURIResolver resolver = new MyURIResolver(withStream);
        ua.setURIResolver(resolver);
        ua.setBaseURL(foFile.getParentFile().toURL().toString());

        Document doc = createAreaTree(foFile, ua);
       
        //Check how many times the resolver was consulted
        assertEquals("Expected resolver to do 1 successful URI resolution",
View Full Code Here

     */
    public void DISABLEDtestFO2() throws Exception {
        //TODO This will only work when we can do URI resolution inside Batik!
        File foFile = new File(getBaseDir(), "test/xml/uri-resolution2.fo");
       
        FOUserAgent ua = fopFactory.newFOUserAgent();
        MyURIResolver resolver = new MyURIResolver(false);
        ua.setURIResolver(resolver);
        ua.setBaseURL(foFile.getParentFile().toURL().toString());

        ByteArrayOutputStream baout = new ByteArrayOutputStream();

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

View Full Code Here

TOP

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

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.