1

After a layout is completed, I want to parse through the DOM tree and get the computed styles of each element. Is this possible.

The closest I could get is the below snippet, but it gives only uncomputed styles.

Element elm = (Element) _doc.getElementsByTagName("table").item(0);
Map props = _sharedContext.getCss().getCascadedPropertiesMap(elm);

Is it also possible to get which "Box" the element lies in.

Bart
  • 19,692
  • 7
  • 68
  • 77
samarjit samanta
  • 1,285
  • 2
  • 16
  • 29
  • Did you try JSOUP.http://jsoup.org/. Best DOM parser with Jquery equivalent functionality? – SRy Dec 26 '12 at 05:29

1 Answers1

0

You can access the computed style in the document with ITextRenderer.getRootBox().

This method return a tree of org.xhtmlrenderer.render.Box objects which you can scan to find your element.

You can get the box computed style with Box.getStyle() and you can get the element the box refers to with Box.getElement().

obourgain
  • 8,856
  • 6
  • 42
  • 57