Package com.pd4ml.dom
Class Layout
- java.lang.Object
-
- com.pd4ml.dom.Layout
-
public final class Layout extends java.lang.ObjectThe document laid out into pages aswritePDF()would write it, asPD4ML.layout()returns it: where each element is, on which page, and its computed style. Positions are in PDF points from the top left corner of a page.Layout layout = pd4ml.layout(); for (LayoutBox box : layout.getBoxes(doc.getElementById("signature"))) { System.out.println(box); // page 2: 56.69, 640.10, 481.89 x 85.00 pt } if (layout.getPageCount() > 1) { doc.getElementById("summary").setAttribute("style", "page-break-before: always"); } pd4ml.writePDF(out);A layout is a snapshot: changes made to the document afterwards are not in it (call layout() again). The page content ofpd4ml:page.header/footer, footnotes and endnotes is not part of it. WithgenerateMulticolumn(), a page here is a column; on a page turned by a page format directive (rotate), boxes are given as on the page before turning.- Since:
- v4.2.0
-
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description ElementelementAt(int page, float x, float y)The innermost element at a point of a page, or null (a margin, or nothing there).java.util.List<LayoutBox>getBoxes(Element element)The boxes of an element, in page order; empty if it is not displayed (display: none, in<head>, ...).java.lang.StringgetComputedStyle(Element element, java.lang.String property)The computed value of a CSS property of an element (e.g.intgetPageCount()The number of pages.floatgetPageHeight(int page)The height of a page (1 for the first one), in points.intgetPageNumber(int page)The page number printed on a page (1 for the first one):$[page], after setInitialPageNumber().java.util.List<java.lang.Integer>getPages(Element element)The pages an element is on, in order; empty if it is not displayed.floatgetPageWidth(int page)The width of a page (1 for the first one), in points.static Layoutof(java.lang.Object pagedDocument, float pointsPerPixel)The layout object for a paginated v42 layout.
-
-
-
Method Detail
-
of
public static Layout of(java.lang.Object pagedDocument, float pointsPerPixel)
The layout object for a paginated v42 layout. Internal: usePD4ML.layout().
-
getPageCount
public int getPageCount()
The number of pages.
-
getPageWidth
public float getPageWidth(int page)
The width of a page (1 for the first one), in points.
-
getPageHeight
public float getPageHeight(int page)
The height of a page (1 for the first one), in points.
-
getPageNumber
public int getPageNumber(int page)
The page number printed on a page (1 for the first one):$[page], after setInitialPageNumber().
-
getBoxes
public java.util.List<LayoutBox> getBoxes(Element element)
The boxes of an element, in page order; empty if it is not displayed (display: none, in<head>, ...).
-
getPages
public java.util.List<java.lang.Integer> getPages(Element element)
The pages an element is on, in order; empty if it is not displayed.
-
getComputedStyle
public java.lang.String getComputedStyle(Element element, java.lang.String property)
The computed value of a CSS property of an element (e.g.color,font-size,display), as CSS text, or null if the element is not displayed.
-
elementAt
public Element elementAt(int page, float x, float y)
The innermost element at a point of a page, or null (a margin, or nothing there).- Parameters:
page- the page, 1 for the first onex- the distance from the left edge of the page, in pointsy- the distance from the top edge of the page, in points
-
-