Package com.openhtmltopdf.render
Class PageBox
- java.lang.Object
-
- com.openhtmltopdf.render.PageBox
-
public class PageBox extends java.lang.Object
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description private static classPageBox.BottomLeftCornerprivate static classPageBox.BottomMarginAreaprivate static classPageBox.BottomRightCornerprivate static classPageBox.LeftMarginAreaprivate static classPageBox.MarginAreaprivate static classPageBox.MarginAreaContainerprivate static classPageBox.PageDimensionsprivate static classPageBox.RightMarginAreaprivate static classPageBox.TopLeftCornerprivate static classPageBox.TopMarginAreaprivate static classPageBox.TopRightCorner
-
Field Summary
Fields Modifier and Type Field Description private int_basePagePdfPageIndexprivate int_bottomprivate PageBox.MarginAreaContainer[]_marginAreasprivate org.w3c.dom.Element_metadataprivate int_outerPageWidthprivate PageBox.PageDimensions_pageDimensionsprivate PageInfo_pageInfoprivate int_pageNoprivate int_paintingBottomprivate int_paintingTopprivate int_shadowPageCountprivate CalculatedStyle_styleprivate int_topprivate int_totalFootnoteHeightprivate PageBox.MarginAreaContainercurrentMarginAreaContainerprivate static intLEADING_TRAILING_SPLITprivate static PageBox.MarginArea[]MARGIN_AREA_DEFS
-
Constructor Summary
Constructors Constructor Description PageBox()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidexportLeadingText(RenderingContext c, java.io.Writer writer)voidexportTrailingText(RenderingContext c, java.io.Writer writer)intgetBasePagePdfPageIndex()private java.awt.RectanglegetBorderEdge(int left, int top, CssContext cssCtx)intgetBottom()Gets the document Y position in top down units (20 per CSS pixel for PDF)
Example: If each page is 500px high and has a 50px margin, then if this is called on the second page it will return 16_000, which is 2 x 400px x 20.intgetBottom(CssContext c)If we are in a footnote callsgetBottom(), otherwise usesgetBottomUsable().intgetBottomUsable()Gets the document Y position taking into accountfloat: bottomcontent such as footnotes.intgetContentHeight(CssContext cssCtx)intgetContentWidth(CssContext cssCtx)MarginBoxName[]getCurrentMarginBoxNames()IdentValuegetCutOffPageDirection()java.awt.RectanglegetDocumentCoordinatesContentBounds(CssContext c)Get the rectangle that this page's content area will cover of the layed out document.java.awt.RectanglegetDocumentCoordinatesContentBoundsForInsertedPage(CssContext c, int shadowPageNumber)Get the shadow page (a page inserted to carry cut off content) content area of the layed out document.intgetFootnoteAreaHeight()floatgetFootnoteMaxHeight(CssContext c)Gets the footnote area max-height if it is provided in the footnote at-rule for this page, otherwise -1.intgetHeight(CssContext cssCtx)RectPropertySetgetMargin(CssContext cssCtx)intgetMarginBorderPadding(CssContext cssCtx, int which)intgetMaxInsertedPages()The maximum number of shadow pages to insert for cut-off content.intgetMaxShadowPagesForXPos(CssContext c, int x)Returns the number of shadow pages needed for a given x coordinate.org.w3c.dom.ElementgetMetadata()intgetOuterPageWidth()java.awt.RectanglegetPagedViewClippingBounds(CssContext cssCtx, int additionalClearance)PageInfogetPageInfo()intgetPageNo()intgetPaintingBottom()intgetPaintingTop()Example: If a page is 100 units high and has a 10 unit margin, this will return 0 for the first page and 80 for the second and so on.java.awt.RectanglegetPrintClippingBounds(CssContext cssCtx)java.awt.RectanglegetPrintPaintingBounds(CssContext cssCtx)java.awt.RectanglegetScreenPaintingBounds(CssContext cssCtx, int additionalClearance)intgetShadowPageCount()CalculatedStylegetStyle()intgetTop()Get the document Y index into this page.intgetWidth(CssContext cssCtx)booleanisFootnoteReserved(CssContext c)If this page is reserved for footnote content.booleanisLeftPage()booleanisRightPage()voidlayout(LayoutContext c)private voidlayoutMarginAreas(LayoutContext c)voidpaintBackground(RenderingContext c, int additionalClearance, short mode)voidpaintBorder(RenderingContext c, int additionalClearance, short mode)voidpaintMarginAreas(RenderingContext c, int additionalClearance, short mode)private intresolveAutoPageHeight(CssContext cssCtx)Return the default page height if defined, else A4.private intresolveAutoPageWidth(CssContext cssCtx)Returns the default page width if defined, else the A4 page size width.private voidresolvePageDimensions(CssContext cssCtx)private voidretrievePageMetadata(LayoutContext c)voidsetBasePagePdfPageIndex(int idx)voidsetFootnoteAreaHeight(int footnoteAreaHeight)Sets the footnote area height on this page.voidsetOuterPageWidth(int containingBlockWidth)voidsetPageInfo(PageInfo pageInfo)voidsetPageNo(int pageNo)voidsetPaintingBottom(int paintingBottom)voidsetPaintingTop(int paintingTop)voidsetShadowPageCount(int cnt)voidsetStyle(CalculatedStyle style)voidsetTopAndBottom(CssContext cssCtx, int top)booleanshouldInsertPages()Should shadow pages be inserted for cut off content for this page.
-
-
-
Field Detail
-
MARGIN_AREA_DEFS
private static final PageBox.MarginArea[] MARGIN_AREA_DEFS
-
LEADING_TRAILING_SPLIT
private static final int LEADING_TRAILING_SPLIT
- See Also:
- Constant Field Values
-
_style
private CalculatedStyle _style
-
_top
private int _top
-
_bottom
private int _bottom
-
_paintingTop
private int _paintingTop
-
_paintingBottom
private int _paintingBottom
-
_pageNo
private int _pageNo
-
_outerPageWidth
private int _outerPageWidth
-
_pageDimensions
private PageBox.PageDimensions _pageDimensions
-
_pageInfo
private PageInfo _pageInfo
-
_marginAreas
private PageBox.MarginAreaContainer[] _marginAreas
-
_metadata
private org.w3c.dom.Element _metadata
-
_basePagePdfPageIndex
private int _basePagePdfPageIndex
-
_shadowPageCount
private int _shadowPageCount
-
_totalFootnoteHeight
private int _totalFootnoteHeight
-
currentMarginAreaContainer
private PageBox.MarginAreaContainer currentMarginAreaContainer
-
-
Method Detail
-
setBasePagePdfPageIndex
public void setBasePagePdfPageIndex(int idx)
-
setShadowPageCount
public void setShadowPageCount(int cnt)
-
getBasePagePdfPageIndex
public int getBasePagePdfPageIndex()
-
getShadowPageCount
public int getShadowPageCount()
-
getWidth
public int getWidth(CssContext cssCtx)
-
getHeight
public int getHeight(CssContext cssCtx)
-
resolvePageDimensions
private void resolvePageDimensions(CssContext cssCtx)
-
resolveAutoPageWidth
private int resolveAutoPageWidth(CssContext cssCtx)
Returns the default page width if defined, else the A4 page size width. Note: We previously returned different sizes based on locale, but this could lead to different results between developement machines and servers so we now always return A4.- Parameters:
cssCtx-- Returns:
-
resolveAutoPageHeight
private int resolveAutoPageHeight(CssContext cssCtx)
Return the default page height if defined, else A4.- Parameters:
cssCtx-- Returns:
-
getContentHeight
public int getContentHeight(CssContext cssCtx)
-
getContentWidth
public int getContentWidth(CssContext cssCtx)
-
getStyle
public CalculatedStyle getStyle()
-
setStyle
public void setStyle(CalculatedStyle style)
-
getBottom
public int getBottom()
Gets the document Y position in top down units (20 per CSS pixel for PDF)
Example: If each page is 500px high and has a 50px margin, then if this is called on the second page it will return 16_000, which is 2 x 400px x 20.
Note: Does not take into account footnotes and any otherfloat: bottomcontent. For this, you can usegetBottomUsable().
Important: PrefergetBottom(CssContext)over this method.
-
getBottomUsable
public int getBottomUsable()
Gets the document Y position taking into accountfloat: bottomcontent such as footnotes. When laying in-flow content we use this method while when in footnotes we usegetBottom().
Important: PrefergetBottom(CssContext)over this method.
-
getBottom
public int getBottom(CssContext c)
If we are in a footnote callsgetBottom(), otherwise usesgetBottomUsable().
-
isFootnoteReserved
public boolean isFootnoteReserved(CssContext c)
If this page is reserved for footnote content.
-
getFootnoteAreaHeight
public int getFootnoteAreaHeight()
-
setFootnoteAreaHeight
public void setFootnoteAreaHeight(int footnoteAreaHeight)
Sets the footnote area height on this page.
-
getTop
public int getTop()
Get the document Y index into this page. SeegetBottom()for example.
-
setTopAndBottom
public void setTopAndBottom(CssContext cssCtx, int top)
-
getPaintingBottom
public int getPaintingBottom()
-
setPaintingBottom
public void setPaintingBottom(int paintingBottom)
-
getPaintingTop
public int getPaintingTop()
Example: If a page is 100 units high and has a 10 unit margin, this will return 0 for the first page and 80 for the second and so on.- Returns:
- the y index into the document coordinates.
-
setPaintingTop
public void setPaintingTop(int paintingTop)
-
getScreenPaintingBounds
public java.awt.Rectangle getScreenPaintingBounds(CssContext cssCtx, int additionalClearance)
-
getPrintPaintingBounds
public java.awt.Rectangle getPrintPaintingBounds(CssContext cssCtx)
-
getDocumentCoordinatesContentBounds
public java.awt.Rectangle getDocumentCoordinatesContentBounds(CssContext c)
Get the rectangle that this page's content area will cover of the layed out document. For example: If a page is 100 units high and 150 wide and has a margin of 10 then this method will return a rect(0, 0, 130, 80) for the first page and a rect(0, 80, 130, 80) for the second and so on.
-
getDocumentCoordinatesContentBoundsForInsertedPage
public java.awt.Rectangle getDocumentCoordinatesContentBoundsForInsertedPage(CssContext c, int shadowPageNumber)
Get the shadow page (a page inserted to carry cut off content) content area of the layed out document. For example: If a page one is 100 units high and 150 wide and has a margin of 10 then this will return a rect(130, 0, 130, 80) for the first shadow page and a rect(260, 0, 130, 80) for the second shadow page assuming cut-off direction is LTR. For RTL the rects would be rect(-130, 0, 130, 80) and rect(-260, 0, 130, 80).
-
getMaxShadowPagesForXPos
public int getMaxShadowPagesForXPos(CssContext c, int x)
Returns the number of shadow pages needed for a given x coordinate. For example if x = 800 and content width = 1000 returns 0 (assumes LTR). For example if x = 2400 and content width = 900 returns 2 (assumes LTR).
-
shouldInsertPages
public boolean shouldInsertPages()
Should shadow pages be inserted for cut off content for this page.
-
getMaxInsertedPages
public int getMaxInsertedPages()
The maximum number of shadow pages to insert for cut-off content.
-
getCutOffPageDirection
public IdentValue getCutOffPageDirection()
- Returns:
- Either ltr (should insert cut-off content to the right of the page) or rtl (should insert cut-off content to the left of the page).
-
getPagedViewClippingBounds
public java.awt.Rectangle getPagedViewClippingBounds(CssContext cssCtx, int additionalClearance)
-
getPrintClippingBounds
public java.awt.Rectangle getPrintClippingBounds(CssContext cssCtx)
-
getMargin
public RectPropertySet getMargin(CssContext cssCtx)
-
getBorderEdge
private java.awt.Rectangle getBorderEdge(int left, int top, CssContext cssCtx)
-
paintBorder
public void paintBorder(RenderingContext c, int additionalClearance, short mode)
-
paintBackground
public void paintBackground(RenderingContext c, int additionalClearance, short mode)
-
paintMarginAreas
public void paintMarginAreas(RenderingContext c, int additionalClearance, short mode)
-
getCurrentMarginBoxNames
public MarginBoxName[] getCurrentMarginBoxNames()
-
getPageNo
public int getPageNo()
-
setPageNo
public void setPageNo(int pageNo)
-
getOuterPageWidth
public int getOuterPageWidth()
-
setOuterPageWidth
public void setOuterPageWidth(int containingBlockWidth)
-
getMarginBorderPadding
public int getMarginBorderPadding(CssContext cssCtx, int which)
-
getPageInfo
public PageInfo getPageInfo()
-
setPageInfo
public void setPageInfo(PageInfo pageInfo)
-
getMetadata
public org.w3c.dom.Element getMetadata()
-
layout
public void layout(LayoutContext c)
-
retrievePageMetadata
private void retrievePageMetadata(LayoutContext c)
-
layoutMarginAreas
private void layoutMarginAreas(LayoutContext c)
-
isLeftPage
public boolean isLeftPage()
-
isRightPage
public boolean isRightPage()
-
exportLeadingText
public void exportLeadingText(RenderingContext c, java.io.Writer writer) throws java.io.IOException
- Throws:
java.io.IOException
-
exportTrailingText
public void exportTrailingText(RenderingContext c, java.io.Writer writer) throws java.io.IOException
- Throws:
java.io.IOException
-
getFootnoteMaxHeight
public float getFootnoteMaxHeight(CssContext c)
Gets the footnote area max-height if it is provided in the footnote at-rule for this page, otherwise -1.
-
-