public class Document extends RootElement<Document>
Document's rendering behavior can be modified by extending
DocumentRenderer and setting an instance of this newly created with
setRenderer(com.itextpdf.layout.renderer.DocumentRenderer).| Modifier and Type | Field and Description |
|---|---|
protected float |
bottomMargin |
protected float |
leftMargin |
protected float |
rightMargin |
protected float |
topMargin |
childElements, defaultFont, defaultSplitCharacters, immediateFlush, pdfDocument, properties, rootRenderer| Constructor and Description |
|---|
Document(PdfDocument pdfDoc)
Creates a document from a
PdfDocument. |
Document(PdfDocument pdfDoc,
PageSize pageSize)
Creates a document from a
PdfDocument with a manually set PageSize. |
Document(PdfDocument pdfDoc,
PageSize pageSize,
boolean immediateFlush)
Creates a document from a
PdfDocument with a manually set PageSize. |
| Modifier and Type | Method and Description |
|---|---|
Document |
add(AreaBreak areaBreak)
Terminates the current element, usually a page.
|
<T extends IElement> |
add(BlockElement<T> element)
Adds an element to the root.
|
protected void |
checkClosingStatus()
checks whether a method is invoked at the closed document
|
void |
close()
Closes the document and associated PdfDocument.
|
protected RootRenderer |
ensureRootRendererNotNull() |
void |
flush()
Forces all registered renderers (including child element renderers) to
flush their contents to the content stream.
|
float |
getBottomMargin() |
float |
getLeftMargin() |
Rectangle |
getPageEffectiveArea(PageSize pageSize)
Returns the area that will actually be used to write on the page, given
the current margins.
|
PdfDocument |
getPdfDocument()
Gets PDF document.
|
float |
getRightMargin() |
float |
getTopMargin() |
void |
relayout()
Performs an entire recalculation of the document flow, taking into
account all its current child elements.
|
void |
setBottomMargin(float bottomMargin) |
void |
setLeftMargin(float leftMargin) |
void |
setMargins(float topMargin,
float rightMargin,
float bottomMargin,
float leftMargin)
Convenience method to set all margins with one method.
|
void |
setRenderer(DocumentRenderer documentRenderer)
Changes the
DocumentRenderer at runtime. |
void |
setRightMargin(float rightMargin) |
void |
setTopMargin(float topMargin) |
add, deleteOwnProperty, getDefaultProperty, getOwnProperty, getProperty, getRenderer, hasOwnProperty, hasProperty, setProperty, showTextAligned, showTextAligned, showTextAligned, showTextAligned, showTextAligned, showTextAligned, showTextAlignedKernedgetHeight, getSplitCharacters, getStrokeColor, getStrokeWidth, getTextRenderingMode, getWidth, setBackgroundColor, setBackgroundColor, setBaseDirection, setBold, setBorder, setBorderBottom, setBorderLeft, setBorderRight, setBorderTop, setCharacterSpacing, setDestination, setFixedPosition, setFixedPosition, setFixedPosition, setFixedPosition, setFont, setFontColor, setFontKerning, setFontScript, setFontSize, setHeight, setHorizontalAlignment, setHyphenation, setItalic, setLineThrough, setRelativePosition, setSplitCharacters, setStrokeColor, setStrokeWidth, setTextAlignment, setTextRenderingMode, setUnderline, setUnderline, setUnderline, setWidth, setWidth, setWidthPercent, setWordSpacingprotected float leftMargin
protected float rightMargin
protected float topMargin
protected float bottomMargin
public Document(PdfDocument pdfDoc)
PdfDocument. Initializes the first page
with the PdfDocument's current default PageSize.pdfDoc - the in-memory representation of the PDF documentpublic Document(PdfDocument pdfDoc, PageSize pageSize)
PdfDocument with a manually set PageSize.pdfDoc - the in-memory representation of the PDF documentpageSize - the page sizepublic Document(PdfDocument pdfDoc, PageSize pageSize, boolean immediateFlush)
PdfDocument with a manually set PageSize.pdfDoc - the in-memory representation of the PDF documentpageSize - the page sizeimmediateFlush - if true, write pages and page-related instructions
to the PdfDocument as soon as possible.public void close()
public Document add(AreaBreak areaBreak)
areaBreak - an AreaBreak, optionally with a specified sizepublic <T extends IElement> Document add(BlockElement<T> element)
RootElementadd in class RootElement<Document>element - an element with spacial margins, tabbing, and alignmentBlockElementpublic PdfDocument getPdfDocument()
public void setRenderer(DocumentRenderer documentRenderer)
DocumentRenderer at runtime. Use this to customize
the Document's IRenderer behavior.documentRenderer - public void flush()
public void relayout()
RootElement.immediateFlush to true.protected RootRenderer ensureRootRendererNotNull()
ensureRootRendererNotNull in class RootElement<Document>public float getLeftMargin()
public void setLeftMargin(float leftMargin)
public float getRightMargin()
public void setRightMargin(float rightMargin)
public float getTopMargin()
public void setTopMargin(float topMargin)
public float getBottomMargin()
public void setBottomMargin(float bottomMargin)
public void setMargins(float topMargin,
float rightMargin,
float bottomMargin,
float leftMargin)
topMargin - the upper marginrightMargin - the right marginleftMargin - the left marginbottomMargin - the lower marginpublic Rectangle getPageEffectiveArea(PageSize pageSize)
pageSize - the size of the page toRectangle with the required dimensions and origin pointprotected void checkClosingStatus()
PdfExceptionCopyright © 1998–2016 iText Group NV. All rights reserved.