Package com.openhtmltopdf.render
Class PageBox
java.lang.Object
com.openhtmltopdf.render.PageBox
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionprivate static class
private static class
private static class
private static class
private static class
private static class
private static final class
private static class
private static class
private static class
private static class
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate int
private int
private PageBox.MarginAreaContainer[]
private Element
private int
private PageBox.PageDimensions
private PageInfo
private int
private int
private int
private int
private CalculatedStyle
private int
private int
private PageBox.MarginAreaContainer
private static final int
private static final PageBox.MarginArea[]
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoid
exportLeadingText
(RenderingContext c, Writer writer) void
exportTrailingText
(RenderingContext c, Writer writer) int
private Rectangle
getBorderEdge
(int left, int top, CssContext cssCtx) int
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.int
If we are in a footnote callsgetBottom()
, otherwise usesgetBottomUsable()
.int
Gets the document Y position taking into accountfloat: bottom
content such as footnotes.int
getContentHeight
(CssContext cssCtx) int
getContentWidth
(CssContext cssCtx) Get the rectangle that this page's content area will cover of the layed out document.getDocumentCoordinatesContentBoundsForInsertedPage
(CssContext c, int shadowPageNumber) Get the shadow page (a page inserted to carry cut off content) content area of the layed out document.int
float
Gets the footnote area max-height if it is provided in the footnote at-rule for this page, otherwise -1.int
getHeight
(CssContext cssCtx) getMargin
(CssContext cssCtx) int
getMarginBorderPadding
(CssContext cssCtx, int which) int
The maximum number of shadow pages to insert for cut-off content.int
getMaxShadowPagesForXPos
(CssContext c, int x) Returns the number of shadow pages needed for a given x coordinate.int
getPagedViewClippingBounds
(CssContext cssCtx, int additionalClearance) int
int
int
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.getPrintClippingBounds
(CssContext cssCtx) getPrintPaintingBounds
(CssContext cssCtx) getScreenPaintingBounds
(CssContext cssCtx, int additionalClearance) int
getStyle()
int
getTop()
Get the document Y index into this page.int
getWidth
(CssContext cssCtx) boolean
If this page is reserved for footnote content.boolean
boolean
void
private void
void
paintBackground
(RenderingContext c, int additionalClearance, short mode) void
paintBorder
(RenderingContext c, int additionalClearance, short mode) void
paintMarginAreas
(RenderingContext c, int additionalClearance, short mode) private int
resolveAutoPageHeight
(CssContext cssCtx) Return the default page height if defined, else A4.private int
resolveAutoPageWidth
(CssContext cssCtx) Returns the default page width if defined, else the A4 page size width.private void
resolvePageDimensions
(CssContext cssCtx) private void
void
setBasePagePdfPageIndex
(int idx) void
setFootnoteAreaHeight
(int footnoteAreaHeight) Sets the footnote area height on this page.void
setOuterPageWidth
(int containingBlockWidth) void
setPageInfo
(PageInfo pageInfo) void
setPageNo
(int pageNo) void
setPaintingBottom
(int paintingBottom) void
setPaintingTop
(int paintingTop) void
setShadowPageCount
(int cnt) void
setStyle
(CalculatedStyle style) void
setTopAndBottom
(CssContext cssCtx, int top) boolean
Should shadow pages be inserted for cut off content for this page.
-
Field Details
-
MARGIN_AREA_DEFS
-
LEADING_TRAILING_SPLIT
private static final int LEADING_TRAILING_SPLIT- See Also:
-
_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
-
_pageInfo
-
_marginAreas
-
_metadata
-
_basePagePdfPageIndex
private int _basePagePdfPageIndex -
_shadowPageCount
private int _shadowPageCount -
_totalFootnoteHeight
private int _totalFootnoteHeight -
currentMarginAreaContainer
-
-
Constructor Details
-
PageBox
public PageBox()
-
-
Method Details
-
setBasePagePdfPageIndex
public void setBasePagePdfPageIndex(int idx) -
setShadowPageCount
public void setShadowPageCount(int cnt) -
getBasePagePdfPageIndex
public int getBasePagePdfPageIndex() -
getShadowPageCount
public int getShadowPageCount() -
getWidth
-
getHeight
-
resolvePageDimensions
-
resolveAutoPageWidth
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
Return the default page height if defined, else A4.- Parameters:
cssCtx
-- Returns:
-
getContentHeight
-
getContentWidth
-
getStyle
-
setStyle
-
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: bottom
content. For this, you can usegetBottomUsable()
.
Important: PrefergetBottom(CssContext)
over this method. -
getBottomUsable
public int getBottomUsable()Gets the document Y position taking into accountfloat: bottom
content 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
If we are in a footnote callsgetBottom()
, otherwise usesgetBottomUsable()
. -
isFootnoteReserved
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
-
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
-
getPrintPaintingBounds
-
getDocumentCoordinatesContentBounds
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 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
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
- 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
-
getPrintClippingBounds
-
getMargin
-
getBorderEdge
-
paintBorder
-
paintBackground
-
paintMarginAreas
-
getCurrentMarginBoxNames
-
getPageNo
public int getPageNo() -
setPageNo
public void setPageNo(int pageNo) -
getOuterPageWidth
public int getOuterPageWidth() -
setOuterPageWidth
public void setOuterPageWidth(int containingBlockWidth) -
getMarginBorderPadding
-
getPageInfo
-
setPageInfo
-
getMetadata
-
layout
-
retrievePageMetadata
-
layoutMarginAreas
-
isLeftPage
public boolean isLeftPage() -
isRightPage
public boolean isRightPage() -
exportLeadingText
- Throws:
IOException
-
exportTrailingText
- Throws:
IOException
-
getFootnoteMaxHeight
Gets the footnote area max-height if it is provided in the footnote at-rule for this page, otherwise -1.
-