xmlgraphics-fop-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Kai Hackemesser <k...@gmx.de>
Subject PreviewPanel - better example?
Date Thu, 24 May 2007 12:06:19 GMT
Hi there!

I'm wondering about how to use the PreviewPanel correctly.

I tried it like following:

    public JComponent getPreviewer() {
        if (page == null) {
            if(renderer==null){
                try {
                    renderer = newRenderer();
                    page = new PreviewPanel(agent, null, renderer);
                } catch (RenderingException e) {

                }
            }
        }
        return page;
    }

    protected AWTRenderer newRenderer() throws RenderingException {
        AWTRenderer renderer = null;

        FopFactory fopFactory = AbstractFopRenderer.getFopFactory();
        renderer = new AWTRenderer();
        agent = fopFactory.newFOUserAgent();
        agent.setRendererOverride(renderer);
        renderer.setPreviewDialogDisplayed(false);
        renderer.setUserAgent(agent);
        return renderer;
    }

The big question currently is, how to fill the previewer correctly. My 
current render method looks as such:

    protected void render(Source xml, Source xsl, OutputStream out,
            Map parameters) throws RenderingException {
        try {
            // reset();

            Transformer transformer = newTransformer(xsl, parameters);
            try {
                final Fop fop = getFopFactory().newFop(
                        MimeConstants.MIME_FOP_PRINT, out);
                final Result result = new 
SAXResult(fop.getDefaultHandler());
                transformer.transform(xml, result);
            } catch (FOPException e) {
                throw new RenderingException("Couldn't show page", e);
            } finally {
                out.close();
            }
        } catch (TransformerException ex) {
            throw new RenderingException("Couldn't show page", ex);
        } catch (IOException e) {
            throw new RenderingException("Couldn't close stream", e);
        }
    }

What is missing or wrong to get the output from this method into the 
previewer?

Kind regards,
Kai

---------------------------------------------------------------------
To unsubscribe, e-mail: fop-users-unsubscribe@xmlgraphics.apache.org
For additional commands, e-mail: fop-users-help@xmlgraphics.apache.org


Mime
View raw message