I skipped over your other message.  I see now where you tried to
reference an AreaTreeHandler, but that's not necessary.
You sent 2 incomplete pieces of code.  The second one looks closer.
Here's a bit of a combination.  See if this helps.

[code]
File fileXsl = new File("c:\\xsl.xml");
FileInputStream xslFIS = new FileInputStream(fileXsl);
byte[] xslSource = new byte[xslFIS.available()];
xslFIS.read(xslSource);
xslFIS.close();
ByteArrayInputStream xslBAIS = new ByteArrayInputStream(xslSource);
InputSource xslIS = new InputSource(xslBAIS);
xslSS = new SAXSource(xslIS);

File xmlFile = new File("c:\\xml.xml");
FileInputStream xmlFIS = new FileInputStream(xmlFile);
byte[] xmlSource = new byte[xmlFIS.available()];
xmlFIS.read(xmlSource);
xmlFIS.close();
ByteArrayInputStream xmlBAIS = new ByteArrayInputStream(xmlSource);
InputSource xmlIS = new InputSource(xmlBAIS);
xmlSS = new SAXSource(xmlIS);

FopFactory fopFactory = FopFactory.newInstance();
AWTRenderer renderer = new AWTRenderer(true);
FOUserAgent foUserAgent = fopFactory.newFOUserAgent();
renderer.setUserAgent(foUserAgent);
foUserAgent.setRendererOverride(renderer);

PreviewPanel previewPanel = new PreviewPanel(foUserAgent, null,
renderer);

renderer.setScaleFactor(25.4 * 800 /
(Toolkit.getDefaultToolkit().getScreenResolution() * 210.0));
renderer.setPreviewDialogDisplayed(false);

Fop fop = fopFactory.newFop(MimeConstants.MIME_FOP_AWT_PREVIEW,
foUserAgent);

// Standard fop usage...
TransformerFactory factory = TransformerFactory.newInstance();
Transformer transformer = factory.newTransformer(xslSS);

Result res = new SAXResult(fop.getDefaultHandler());
transformer.transform(xmlSS, res);

// To handle several pages on the same panel :
previewPanel.setDisplayMode(PreviewPanel.CONTINUOUS);
previewPanel.showPage();
previewPanel.setPage(0);
[/code] 

That's pretty much how I wrote mine initially, excluding some custom
code like font loading.
The only problem I found with this built in preview panel is the
renderer attached to the PreviewPanel.
1) I'm doing client-server code.  Transforms normally run on the server.
The PreviewPanel of course has to run on the client.  Changing the zoom
(ScaleFactor) has to re-render the entire document.
2) This also has to create a transformer and renderer object on the
client which is taking a long time.

In my new custom preview panel I'm using the PNGRenderer.  This holds
the transformed output in the renderer.  I can use it's getNumberOfPages
method to create an array and retrieve the pages with getPageImage.  For
the zoom I just use drawImage from Graphics2D which makes the pages a
little fuzzy at any level other than the initial size but they're
readable and it's a lot faster.

-----Original Message-----
From: pedro [mailto:[email protected]] 
Sent: Friday, February 18, 2011 5:55 AM
To: [email protected]
Subject: PrintPreview


HI all i use the PrintPreviewPanel

The problem is that i have to use a AreaTreeHandler but i don't know how
to do it.
The other problem is how to display the toolbar.


Thanks!
--
View this message in context:
http://old.nabble.com/PrintPreview-tp30957628p30957628.html
Sent from the FOP - Users mailing list archive at Nabble.com.


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to