public class RenderContext extends Object implements Renderer, Closeable, DrawContext, DrawListener
| Constructor and Description |
|---|
RenderContext(Document document,
org.apache.pdfbox.pdmodel.PDDocument pdDocument)
Creates a render context.
|
| Modifier and Type | Method and Description |
|---|---|
void |
close() |
boolean |
closePage()
Closes the current page.
|
void |
drawn(Object drawnObject,
Position upperLeft,
float width,
float height)
Indicates that an object has been drawn.
|
org.apache.pdfbox.pdmodel.PDPageContentStream |
getContentStream() |
org.apache.pdfbox.pdmodel.PDPage |
getCurrentPage() |
org.apache.pdfbox.pdmodel.PDPageContentStream |
getCurrentPageContentStream() |
Position |
getCurrentPosition() |
Document |
getDocument() |
float |
getHeight() |
Layout |
getLayout() |
Position |
getLowerRight() |
Position |
getMarkedPosition() |
protected Position |
getMaxPositionOnPage() |
org.apache.pdfbox.pdmodel.common.PDRectangle |
getMediaBox()
Deprecated.
use
getPageFormat() instead. |
Orientation |
getOrientation()
Deprecated.
use
getPageFormat() instead. |
org.apache.pdfbox.pdmodel.PDPage |
getPage()
Deprecated.
|
PageFormat |
getPageFormat() |
float |
getPageHeight() |
int |
getPageIndex() |
protected Orientation |
getPageOrientation() |
float |
getPageWidth() |
org.apache.pdfbox.pdmodel.PDDocument |
getPdDocument() |
float |
getRemainingHeight() |
Position |
getUpperLeft() |
float |
getWidth() |
boolean |
isPageTilted() |
void |
movePositionBy(float x,
float y)
Moves the
current position relatively by
the given offset. |
void |
newPage()
Triggers a new page.
|
protected boolean |
render(PositionControl positionControl) |
boolean |
render(RenderContext renderContext,
Element element,
LayoutHint layoutHint)
Renders an element.
|
protected void |
resetMaxPositionOnPage()
Resets the maximumn position to upper left.
|
void |
resetPositionToLeft()
Resets the position to the x of
getUpperLeft() while keeping the
current y. |
protected void |
resetPositionToLeftEndOfPage()
Resets the position to the x of
getUpperLeft() and the
y of getMaxPositionOnPage(). |
void |
resetPositionToUpperLeft()
Resets the position to
getUpperLeft(). |
void |
setLayout(Layout layout)
Sets the current
Layout used for rendering. |
protected void |
setMarkedPosition(Position markedPosition) |
void |
setPageFormat(PageFormat pageFormat) |
protected void |
updateMaxPositionOnPage(Position upperLeft,
float width,
float height)
Updates the maximum right resp.
|
public RenderContext(Document document, org.apache.pdfbox.pdmodel.PDDocument pdDocument) throws IOException
document - the document to render.pdDocument - the underlying pdfbox document.IOException - by pdfbox.public void setLayout(Layout layout)
Layout used for rendering.layout - the new layout.@Deprecated public Orientation getOrientation()
getPageFormat() instead.page format is set, the
document orientation is used.@Deprecated public org.apache.pdfbox.pdmodel.common.PDRectangle getMediaBox()
getPageFormat() instead.page format is set, the
document media box is used.public void setPageFormat(PageFormat pageFormat)
public PageFormat getPageFormat()
public Position getUpperLeft()
document margins.public Position getLowerRight()
document margins.public Position getCurrentPosition()
public Position getMarkedPosition()
PositionControl.MARKED_POSITION.protected void setMarkedPosition(Position markedPosition)
public void movePositionBy(float x,
float y)
current position relatively by
the given offset.x - to move horizontally.y - to move vertically.public void resetPositionToUpperLeft()
getUpperLeft().public void resetPositionToLeft()
getUpperLeft() while keeping the
current y.protected void resetPositionToLeftEndOfPage()
getUpperLeft() and the
y of getMaxPositionOnPage().protected Orientation getPageOrientation()
public boolean isPageTilted()
true if the page is rotated by 90/270 degrees.public float getPageWidth()
rotated - the
height.public float getPageHeight()
rotated - the
width.public float getWidth()
width of the page respecting the
margins.public float getHeight()
height of the page respecting the
margins.public float getRemainingHeight()
public Document getDocument()
public org.apache.pdfbox.pdmodel.PDDocument getPdDocument()
getPdDocument in interface DrawContextpublic org.apache.pdfbox.pdmodel.PDPage getCurrentPage()
getCurrentPage in interface DrawContextpublic org.apache.pdfbox.pdmodel.PDPageContentStream getCurrentPageContentStream()
getCurrentPageContentStream in interface DrawContext@Deprecated public org.apache.pdfbox.pdmodel.PDPage getPage()
public org.apache.pdfbox.pdmodel.PDPageContentStream getContentStream()
public int getPageIndex()
public boolean render(RenderContext renderContext, Element element, LayoutHint layoutHint) throws IOException
Rendererrender in interface RendererrenderContext - the render context.element - the element to draw.layoutHint - the associated layout hinttrue if the layout is able to render the element.IOException - by pdfboxprotected boolean render(PositionControl positionControl)
public void newPage()
throws IOException
IOException - by pdfboxpublic boolean closePage()
throws IOException
true if the current page has not been closed before.IOException - by pdfboxpublic void close()
throws IOException
close in interface Closeableclose in interface AutoCloseableIOExceptionpublic void drawn(Object drawnObject, Position upperLeft, float width, float height)
DrawListenerdrawn in interface DrawListenerdrawnObject - the drawn object.upperLeft - the upper left position.width - the width of the drawn object.height - the height of the drawn object.protected void updateMaxPositionOnPage(Position upperLeft, float width, float height)
upperLeft - width - height - protected void resetMaxPositionOnPage()
protected Position getMaxPositionOnPage()
Copyright © 2021. All rights reserved.