Package org.apache.fop.apps

Examples of org.apache.fop.apps.FOUserAgent


    /**
     * create an FOUserAgent for our tests
     * @return an initialized FOUserAgent
     */
    protected FOUserAgent getUserAgent() {
        final FOUserAgent a = fopFactory.newFOUserAgent();
        return a;
    }
View Full Code Here


    protected abstract String getTargetFormat();
   
    /** @see org.apache.fop.visual.BitmapProducer */
    public BufferedImage produce(File src, ProducerContext context) {
        try {
            FOUserAgent userAgent = fopFactory.newFOUserAgent();
            userAgent.setTargetResolution(context.getTargetResolution());
            userAgent.setBaseURL(src.getParentFile().toURL().toString());

            File tempOut = new File(context.getTargetDir(),
                    src.getName() + "." + getTargetExtension());
            File tempPNG = new File(context.getTargetDir(),
                    src.getName() + "." + getTargetExtension() + ".png");
View Full Code Here

            backgroundPositionVertical = pList.get(
                    Constants.PR_BACKGROUND_POSITION_VERTICAL).getLength();

            //Additional processing: preload image
            String uri = URISpecification.getURL(backgroundImage);
            FOUserAgent userAgent = pList.getFObj().getUserAgent();
            ImageManager manager = userAgent.getFactory().getImageManager();
            ImageSessionContext sessionContext = userAgent.getImageSessionContext();
            ImageInfo info;
            try {
                info = manager.getImageInfo(uri, sessionContext);
                this.backgroundImageInfo = info;
            } catch (Exception e) {
View Full Code Here

                throws PropertyException {
        padding[side] = pList.get(paddingProp).getCondLength();
        // If style = none, force width to 0, don't get Color (spec 7.7.20)
        int style = pList.get(styleProp).getEnum();
        if (style != Constants.EN_NONE) {
            FOUserAgent ua = pList.getFObj().getUserAgent();
            setBorderInfo(new BorderInfo(style,
                pList.get(widthProp).getCondLength(),
                pList.get(colorProp).getColor(ua)), side);
        }
    }
View Full Code Here

    public PDFsRGBSettingsTestCase(String name) {
        super(name);
    }

    private FOUserAgent getUserAgent(boolean enablePDFA) {
        final FOUserAgent a = fopFactory.newFOUserAgent();
        if (enablePDFA) {
            a.getRendererOptions().put("pdf-a-mode", "PDF/A-1b");
        }
        a.getRendererOptions().put("disable-srgb-colorspace", Boolean.TRUE);
        return a;
    }
View Full Code Here

     *
     * @param filename path to the test FO file
     * @param factory to create the appropriate FOEventHandler for performing tests
     */
    public void setUp(String filename, FOEventHandlerFactory factory) throws Exception {
        FOUserAgent ua = fopFactory.newFOUserAgent();
        ua.setFOEventHandlerOverride(factory.createFOEventHandler(ua));

        Fop fop = fopFactory.newFop(ua);

        foReader.setContentHandler(fop.getDefaultHandler());
        foReader.setDTDHandler(fop.getDefaultHandler());
View Full Code Here

    }
   
    public void testSVG() throws Exception {
        String uri = "test/resources/images/img-w-size.svg";
       
        FOUserAgent userAgent = fopFactory.newFOUserAgent();
       
        ImageManager manager = fopFactory.getImageManager();
        ImageInfo info = manager.preloadImage(uri, userAgent.getImageSessionContext());
        assertNotNull("ImageInfo must not be null", info);
       
        Image img = manager.getImage(info, ImageFlavor.XML_DOM,
                userAgent.getImageSessionContext());
        assertNotNull("Image must not be null", img);
        assertEquals(ImageFlavor.XML_DOM, img.getFlavor());
        ImageXMLDOM imgDom = (ImageXMLDOM)img;
        assertNotNull(imgDom.getDocument());
        assertEquals("http://www.w3.org/2000/svg", imgDom.getRootNamespace());
        info = imgDom.getInfo(); //Switch to the ImageInfo returned by the image
        assertEquals(16000, info.getSize().getWidthMpt());
        assertEquals(16000, info.getSize().getHeightMpt());
       
        img = manager.getImage(info, ImageFlavor.RENDERED_IMAGE,
                    userAgent.getImageSessionContext());
        assertNotNull("Image must not be null", img);
        assertEquals(ImageFlavor.RENDERED_IMAGE, img.getFlavor());
        ImageRendered imgRed = (ImageRendered)img;
        assertNotNull(imgRed.getRenderedImage());
        if (DEBUG_TARGET_DIR != null) {
            ImageWriterUtil.saveAsPNG(imgRed.getRenderedImage(),
                    (int)userAgent.getTargetResolution(),
                    new File(DEBUG_TARGET_DIR, "out.svg.png"));
        }
        assertEquals(67, imgRed.getRenderedImage().getWidth());
        assertEquals(67, imgRed.getRenderedImage().getHeight());
        info = imgRed.getInfo(); //Switch to the ImageInfo returned by the image
View Full Code Here

    }
   
    public void testWMF() throws Exception {
        String uri = "test/resources/images/testChart.wmf";
       
        FOUserAgent userAgent = fopFactory.newFOUserAgent();
       
        ImageManager manager = fopFactory.getImageManager();
        ImageInfo info = manager.preloadImage(uri, userAgent.getImageSessionContext());
        assertNotNull("ImageInfo must not be null", info);
       
        Image img = manager.getImage(info, ImageFlavor.RENDERED_IMAGE,
                userAgent.getImageSessionContext());
        assertNotNull("Image must not be null", img);
        assertEquals(ImageFlavor.RENDERED_IMAGE, img.getFlavor());
        ImageRendered imgRed = (ImageRendered)img;
        assertNotNull(imgRed.getRenderedImage());
        if (DEBUG_TARGET_DIR != null) {
            ImageWriterUtil.saveAsPNG(imgRed.getRenderedImage(),
                    (int)userAgent.getTargetResolution(),
                    new File(DEBUG_TARGET_DIR, "out.wmf.png"));
        }
        assertEquals(3300, imgRed.getRenderedImage().getWidth());
        assertEquals(2550, imgRed.getRenderedImage().getHeight());
        info = imgRed.getInfo(); //Switch to the ImageInfo returned by the image
View Full Code Here

        spf.setNamespaceAware(true);
        spf.setValidating(false);
        SAXParser parser = spf.newSAXParser();
        XMLReader reader = parser.getXMLReader();
               
        FOUserAgent ua = fopFactory.newFOUserAgent();
        ua.setBaseURL(testFile.getParentFile().toURL().toString());
        ua.setFOEventHandlerOverride(new DummyFOEventHandler(ua));

        //Used to set values in the user agent through processing instructions
        reader = new PIListener(reader, ua);
       
        Fop fop = fopFactory.newFop(ua);
View Full Code Here

            //Setup Transformer to convert the area tree to a DOM
            TransformerHandler athandler = tfactory.newTransformerHandler();
            athandler.setResult(domres);
           
            //Setup FOP for area tree rendering
            FOUserAgent ua = effFactory.newFOUserAgent();
            ua.setBaseURL(testFile.getParentFile().toURL().toString());
            XMLRenderer atrenderer = new XMLRenderer();
            atrenderer.setUserAgent(ua);
            atrenderer.setContentHandler(athandler);
            ua.setRendererOverride(atrenderer);
            fop = effFactory.newFop(ua);
           
            SAXResult fores = new SAXResult(fop.getDefaultHandler());
            transformer.transform(src, fores);
        } finally {
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.