xmlgraphics-fop-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Georg Datterl" <georg.datt...@geneon.de>
Subject AW: Area Tree Handling
Date Mon, 13 Jul 2009 06:24:42 GMT
Hi Tom,

I get the area tree using

            FOUserAgent foUserAgent = getFopFactory().newFOUserAgent();
            Transformer transformer =  getMultipassFactory().newTransformer();
            TransformerHandler handler = getMultipassFactory().newTransformerHandler();
            DOMResult domResult = new DOMResult();
            handler.setResult(domResult);

            org.apache.fop.render.Renderer targetRenderer =
            foUserAgent.getRendererFactory().createRenderer(
                            foUserAgent, MimeConstants.MIME_PDF);

            XMLRenderer renderer = new XMLRenderer();
            renderer.mimicRenderer(targetRenderer);
            renderer.setContentHandler(handler);
            renderer.setUserAgent(foUserAgent);

            foUserAgent.setRendererOverride(renderer);
            
            Fop fop = getFopFactory().newFop(MimeConstants.MIME_FOP_AREA_TREE, foUserAgent);
            Result res = new SAXResult(fop.getDefaultHandler());
            transformer.transform(source, res);
            org.w3c.dom.Document doc = domResult.getNode();

Then I get values from the tree through Xpath

		XPathFactory factory=XPathFactory.newInstance();
		XPath xPath=factory.newXPath(); 
		NodeList nl = (NodeList)xPath.evaluate("//block[@prod-id='"+DT_TAG+id+"']", doc, XPathConstants.NODESET);
		xPath.evaluate(".//block[@prod-id='"+L1_TAG+id+"']/@bpd", nl.item(i), XPathConstants.NUMBER)

The blocks I'm interested in have well-known ids and I'm interested in more than one information
below the node with id DT_TAGxx, that's why I use a nodelist. When you find a smarter way
to get the information, please tell me, cause this xpath solution is not very fast in large
documents...

Regards,
 
Georg Datterl
 
------ Kontakt ------
 
Georg Datterl
 
Geneon media solutions gmbh
Gutenstetter Straße 8a
90449 Nürnberg
 
HRB Nürnberg: 17193
Geschäftsführer: Yong-Harry Steiert 

Tel.: 0911/36 78 88 - 26
Fax: 0911/36 78 88 - 20
 
www.geneon.de
 
Weitere Mitglieder der Willmy MediaGroup:
 
IRS Integrated Realization Services GmbH:    www.irs-nbg.de 
Willmy PrintMedia GmbH:                            www.willmy.de
Willmy Consult & Content GmbH:                 www.willmycc.de 
-----Ursprüngliche Nachricht-----
Von: TomWilcox [mailto:wilcox@hp.com] 
Gesendet: Freitag, 10. Juli 2009 18:52
An: fop-users@xmlgraphics.apache.org
Betreff: Area Tree Handling


Hi,

First of all, I am a FOP dummy. I can make PDFs from FO but I don't know about the inner workings.

I have FOP 0.95 embedded in my Java application. I would like to construct an FO document
and modify/examine the AreaTree for it on the fly.

This is in an attempt to fill blocks (of set size and position) on a page with text/graphics
and until the areatree info shows that block is full.

I would like to do this as fast as possible and I thought this would imply the best route
is to get hold of the areatree object in my application and modify/access the objects of interest.
(Or, failing that, to get hold area tree xml fragments maybe)..

Can anyone tell me how I might go about achieving this?

Or even better, can anyone point me in the direction of any good tutorials/examples that show
Java code using embedded FOP to generate an area tree object for an FO stream/file and then
modify it with code..?

That would be awesome :)

Thanks in advance,
Tom
--
View this message in context: http://www.nabble.com/Area-Tree-Handling-tp24431098p24431098.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


---------------------------------------------------------------------
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