Examples of FopFactory


Examples of org.apache.fop.apps.FopFactory

     * @throws FOPException in case of an error during processing
     */
    public void renderTo(FOUserAgent userAgent, String outputFormat, OutputStream out)
                throws FOPException {

        FopFactory factory = userAgent.getFactory();
        Fop fop;
        if (out != null) {
            fop = factory.newFop(outputFormat, userAgent, out);
        } else {
            fop = factory.newFop(outputFormat, userAgent);
        }

        // if base URL was not explicitly set in FOUserAgent, obtain here
        if (fop.getUserAgent().getBaseURL() == null && sourcefile != null) {
            String baseURL = null;
View Full Code Here

Examples of org.apache.fop.apps.FopFactory

        mockGetFactory(mockFOUserAgent);
        when(mockFOEventHandler.getUserAgent()).thenReturn(mockFOUserAgent);
    }

    private static void mockGetFactory(FOUserAgent mockFOUserAgent) {
        FopFactory mockFopFactory = mock(FopFactory.class);
        mockGetImageManager(mockFopFactory);
        when(mockFOUserAgent.getFactory()).thenReturn(mockFopFactory);
    }
View Full Code Here

Examples of org.apache.fop.apps.FopFactory

        Document doc = (Document) res.getNode();
        return doc.getDocumentElement();
    }

    public FopFactory getFopFactory(boolean base14KerningEnabled) {
        FopFactory effFactory = (base14KerningEnabled ? fopFactoryWithBase14Kerning : fopFactory);
        return effFactory;
    }
View Full Code Here

Examples of org.apache.fop.apps.FopFactory

        return effFactory;
    }

    public FopFactory getFopFactory(Document testDoc) {
        boolean base14KerningEnabled = isBase14KerningEnabled(testDoc);
        FopFactory effFactory = getFopFactory(base14KerningEnabled);

        boolean strictValidation = isStrictValidation(testDoc);
        effFactory.setStrictValidation(strictValidation);

        return effFactory;
    }
View Full Code Here

Examples of org.apache.fop.apps.FopFactory

    @Test
    public void testSVGNoViewbox() throws Exception {
        String uri = "test/resources/images/circles.svg";

        FopFactory ff = FopFactory.newInstance();
        ff.setSourceResolution(96);
        ff.setTargetResolution(300);

        FOUserAgent userAgent = ff.newFOUserAgent();

        ImageManager manager = ff.getImageManager();
        ImageInfo info = manager.preloadImage(uri, userAgent.getImageSessionContext());
        assertNotNull("ImageInfo must not be null", info);

        Image img = manager.getImage(info, XMLNamespaceEnabledImageFlavor.SVG_DOM,
                userAgent.getImageSessionContext());
View Full Code Here

Examples of org.apache.fop.apps.FopFactory

    }

    @Test
    public void testSVGWithReferences() throws Exception {
        String uri = "test/resources/fop/svg/images.svg";
        FopFactory ff = FopFactory.newInstance();
        FOUserAgent userAgent = ff.newFOUserAgent();

        ImageManager manager = ff.getImageManager();
        ImageInfo info = manager.preloadImage(uri, userAgent.getImageSessionContext());
        assertNotNull("ImageInfo must not be null", info);

        Image img = manager.getImage(info, XMLNamespaceEnabledImageFlavor.SVG_DOM,
                userAgent.getImageSessionContext());
View Full Code Here

Examples of org.apache.fop.apps.FopFactory

*/
public class RendererFactoryTestCase {

    @Test
    public void testDocumentHandlerLevel() throws Exception {
        FopFactory fopFactory = FopFactory.newInstance();
        RendererFactory factory = fopFactory.getRendererFactory();
        FOUserAgent ua;
        IFDocumentHandler handler;
        IFDocumentHandler overrideHandler;

        ua = fopFactory.newFOUserAgent();
        handler = factory.createDocumentHandler(ua, MimeConstants.MIME_PDF);

        ua = fopFactory.newFOUserAgent();
        overrideHandler = new PDFDocumentHandler();
        overrideHandler.setContext(new IFContext(ua));
        ua.setDocumentHandlerOverride(overrideHandler);
        handler = factory.createDocumentHandler(ua, null);
        assertTrue(handler == overrideHandler);

        ua = fopFactory.newFOUserAgent();
        try {
            handler = factory.createDocumentHandler(ua, "invalid/format");
            fail("Expected UnsupportedOperationException");
        } catch (UnsupportedOperationException uoe) {
            //expected
View Full Code Here

Examples of org.apache.fop.apps.FopFactory

        }
    }

    @Test
    public void testRendererLevel() throws Exception {
        FopFactory fopFactory = FopFactory.newInstance();
        RendererFactory factory = fopFactory.getRendererFactory();
        FOUserAgent ua;
        Renderer renderer;

        ua = fopFactory.newFOUserAgent();
        renderer = factory.createRenderer(ua, MimeConstants.MIME_PDF);
        assertTrue(renderer instanceof IFRenderer);

        ua = fopFactory.newFOUserAgent();
        renderer = factory.createRenderer(ua, MimeConstants.MIME_FOP_IF);
        assertTrue(renderer instanceof IFRenderer);

        ua = fopFactory.newFOUserAgent();
        IFDocumentHandler overrideHandler;
        overrideHandler = new PDFDocumentHandler();
        overrideHandler.setContext(new IFContext(ua));
        ua.setDocumentHandlerOverride(overrideHandler);
        renderer = factory.createRenderer(ua, null);
        assertTrue(renderer instanceof IFRenderer);

        ua = fopFactory.newFOUserAgent();
        try {
            renderer = factory.createRenderer(ua, "invalid/format");
            fail("Expected UnsupportedOperationException");
        } catch (UnsupportedOperationException uoe) {
            //expected
View Full Code Here

Examples of org.apache.fop.apps.FopFactory

        }
    }

    @Test
    public void testFOEventHandlerLevel() throws Exception {
        FopFactory fopFactory = FopFactory.newInstance();
        RendererFactory factory = fopFactory.getRendererFactory();
        FOUserAgent ua;
        FOEventHandler foEventHandler;
        FOEventHandler overrideFOEventHandler;

        ua = fopFactory.newFOUserAgent();
        foEventHandler = factory.createFOEventHandler(
                ua, MimeConstants.MIME_PDF, new NullOutputStream());
        assertTrue(foEventHandler instanceof AreaTreeHandler);

        ua = fopFactory.newFOUserAgent();
        foEventHandler = factory.createFOEventHandler(
                ua, MimeConstants.MIME_RTF, new NullOutputStream());
        assertTrue(foEventHandler instanceof RTFHandler);

        ua = fopFactory.newFOUserAgent();
        try {
            foEventHandler = factory.createFOEventHandler(
                    ua, "invalid/format", new NullOutputStream());
            fail("Expected UnsupportedOperationException");
        } catch (UnsupportedOperationException uoe) {
            //expected
        }

        ua = fopFactory.newFOUserAgent();
        try {
            foEventHandler = factory.createFOEventHandler(
                    ua, MimeConstants.MIME_PDF, null);
            fail("Expected FOPException because of missing OutputStream");
        } catch (FOPException fe) {
            //expected
        }

        ua = fopFactory.newFOUserAgent();
        overrideFOEventHandler = new RTFHandler(ua, new NullOutputStream());
        ua.setFOEventHandlerOverride(overrideFOEventHandler);
        foEventHandler = factory.createFOEventHandler(
                ua, null, null);
        assertTrue(foEventHandler == overrideFOEventHandler);
View Full Code Here

Examples of org.apache.fop.apps.FopFactory

        ElementListCollector elCollector = new ElementListCollector();
        ElementListObserver.addObserver(elCollector);

        Fop fop;
        FopFactory effFactory;
        try {
            Document testDoc = testAssistant.loadTestCase(testFile);
            effFactory = testAssistant.getFopFactory(testDoc);

            //Setup Transformer to convert the testcase XML to XSL-FO
            Transformer transformer = testAssistant.getTestcase2FOStylesheet().newTransformer();
            Source src = new DOMSource(testDoc);

            //Setup Transformer to convert the area tree to a DOM
            TransformerHandler athandler;
            athandler = testAssistant.getTransformerFactory().newTransformerHandler();
            athandler.setResult(domres);

            //Setup FOP for area tree rendering
            FOUserAgent ua = effFactory.newFOUserAgent();
            ua.setBaseURL(testFile.getParentFile().toURI().toURL().toString());
            ua.getEventBroadcaster().addEventListener(
                    new ConsoleEventListenerForTests(testFile.getName(), EventSeverity.WARN));

            XMLRenderer atrenderer = new XMLRenderer(ua);
            atrenderer.setContentHandler(athandler);
            ua.setRendererOverride(atrenderer);
            fop = effFactory.newFop(ua);

            SAXResult fores = new SAXResult(fop.getDefaultHandler());
            transformer.transform(src, fores);
        } finally {
            ElementListObserver.removeObserver(elCollector);
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.