xmlgraphics-fop-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Leopard2A5 <persc...@itso-berlin.de>
Subject HowTo export several pages to PNG-format
Date Tue, 31 Mar 2009 08:16:08 GMT


I've searched the mailing lists and the docs but i somehow couldn't find
I'm using fop to generate PDFs in my web-application, but i also need
preview-pictures to display via HTML.
Generating PDFs via FOP works great, but i can't manage to get more than the
first page as a preview.

Here's my code:

private int getImagesFromPDF(String path, Reader stylesheet) throws
        FileOutputStream output = new FileOutputStream(path + ".png");
        //Instantiate FOP
        FopFactory fopFactory = FopFactory.newInstance();
            fopFactory.setUserConfig(VISITE_BASE_PATH + "fop_config2.xml");
        catch (SAXException e)
        Fop fop = fopFactory.newFop(MimeConstants.MIME_PNG, output);
        TransformerFactory factory = TransformerFactory.newInstance();
        Transformer transformer = factory.newTransformer();

        // get the right input format for conversion
        Source style = new StreamSource(stylesheet);
        Result res = new SAXResult(fop.getDefaultHandler());

        // Step 6: Start XSLT transformation and FOP processing
        transformer.transform(style, res);

        return 0;

and my fop_config-file:

<fop version="1.0">
   <renderer mime="image/png">
        <!-- register a particular font -->
          <font-triplet name="Georgia" style="normal" weight="normal"/>
          <font-triplet name="Georgia" style="normal" weight="bold"/>
          <font-triplet name="Georgia" style="italic" weight="normal"/>
          <font-triplet name="Georgia" style="italic" weight="bold"/>


Any help would be appreciated!
Thx in advance!
View this message in context: http://www.nabble.com/HowTo-export-several-pages-to-PNG-format-tp22800402p22800402.html
Sent from the FOP - Users mailing list archive at Nabble.com.

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

View raw message