public class Document extends RootElement<Document>
A 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, defaultFontProvider, 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.
|
Document |
add(IBlockElement 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()
Gets the bottom margin, measured in points
|
float |
getLeftMargin()
Gets the left margin, measured in points
|
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()
Gets the right margin, measured in points
|
float |
getTopMargin()
Gets the top margin, measured in points
|
void |
relayout()
Performs an entire recalculation of the document flow, taking into account all its current child elements.
|
void |
setBottomMargin(float bottomMargin)
Sets the bottom margin, measured in points
|
void |
setLeftMargin(float leftMargin)
Sets the left margin, measured in points
|
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)
Sets the right margin, measured in points
|
void |
setTopMargin(float topMargin)
Sets the top margin, measured in points
|
add, deleteOwnProperty, getDefaultProperty, getFontProvider, getOwnProperty, getProperty, getRenderer, hasOwnProperty, hasProperty, setFontProvider, setProperty, showTextAligned, showTextAligned, showTextAligned, showTextAligned, showTextAligned, showTextAligned, showTextAlignedKernedgetHeight, getSplitCharacters, getStrokeColor, getStrokeWidth, getTextRenderingMode, getWidth, setBackgroundColor, setBackgroundColor, setBackgroundColor, setBackgroundColor, setBaseDirection, setBold, setBorder, setBorderBottom, setBorderLeft, setBorderRight, setBorderTop, setCharacterSpacing, setDestination, setFixedPosition, setFixedPosition, setFixedPosition, setFixedPosition, setFont, setFont, setFontColor, setFontColor, setFontKerning, setFontScript, setFontSize, setHeight, setHorizontalAlignment, setHyphenation, setItalic, setLineThrough, setOpacity, setRelativePosition, setSplitCharacters, setStrokeColor, setStrokeWidth, setTextAlignment, setTextRenderingMode, setUnderline, 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 document
public Document(PdfDocument pdfDoc, PageSize pageSize)
PdfDocument with a manually set PageSize.
pdfDoc - the in-memory representation of the PDF document
pageSize - the page size
public Document(PdfDocument pdfDoc, PageSize pageSize, boolean immediateFlush)
PdfDocument with a manually set PageSize.
pdfDoc - the in-memory representation of the PDF document
pageSize - the page size
immediateFlush - 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 size
public Document add(IBlockElement element)
RootElement
add in class RootElement<Document>
element - an element with spacial margins, tabbing, and alignment
BlockElement
public 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()
Do not use when you have set RootElement.immediateFlush to true.
public float getLeftMargin()
float containing the left margin value
public void setLeftMargin(float leftMargin)
leftMargin - a float containing the new left margin value
public float getRightMargin()
float containing the right margin value
public void setRightMargin(float rightMargin)
rightMargin - a float containing the new right margin value
public float getTopMargin()
float containing the top margin value
public void setTopMargin(float topMargin)
topMargin - a float containing the new top margin value
public float getBottomMargin()
float containing the bottom margin value
public void setBottomMargin(float bottomMargin)
bottomMargin - a float containing the new bottom margin value
public void setMargins(float topMargin,
float rightMargin,
float bottomMargin,
float leftMargin)
topMargin - the upper margin
rightMargin - the right margin
leftMargin - the left margin
bottomMargin - the lower margin
public Rectangle getPageEffectiveArea(PageSize pageSize)
pageSize - the size of the page to
Rectangle with the required dimensions and origin point
protected RootRenderer ensureRootRendererNotNull()
ensureRootRendererNotNull in class RootElement<Document>
protected void checkClosingStatus()
Copyright © 1998–2017 iText Group NV. All rights reserved.