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.
|
|
add(BlockElement
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 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
publicIElement> Document add(BlockElement 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()
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 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 void checkClosingStatus()
PdfException
Copyright © 1998–2016 iText Group NV. All rights reserved.