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
Deprecated.
To be removed in 7.2. Use
Property.MARGIN_BOTTOM instead.
|
protected float |
leftMargin
Deprecated.
To be removed in 7.2. Use
Property.MARGIN_LEFT instead.
|
protected float |
rightMargin
Deprecated.
To be removed in 7.2. Use
Property.MARGIN_RIGHT instead.
|
protected float |
topMargin
Deprecated.
To be removed in 7.2. Use
Property.MARGIN_TOP instead.
|
childElements, defaultFont, defaultFontProvider, defaultSplitCharacters, immediateFlush, pdfDocument, rootRenderer
properties
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
|
|
getDefaultProperty(int property)
Gets the default property from this entity.
|
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, createAndAddRendererSubTree, deleteOwnProperty, getFontProvider, getOwnProperty, getProperty, getRenderer, hasOwnProperty, hasProperty, setFontProvider, setProperty, showTextAligned, showTextAligned, showTextAligned, showTextAligned, showTextAligned, showTextAligned, showTextAlignedKerned
getSplitCharacters, getStrokeColor, getStrokeWidth, getTextRenderingMode, setBackgroundColor, setBackgroundColor, setBackgroundColor, setBackgroundColor, setBackgroundImage, setBackgroundImage, setBaseDirection, setBold, setBorder, setBorderBottom, setBorderBottomLeftRadius, setBorderBottomRightRadius, setBorderLeft, setBorderRadius, setBorderRight, setBorderTop, setBorderTopLeftRadius, setBorderTopRightRadius, setCharacterSpacing, setDestination, setFixedPosition, setFixedPosition, setFixedPosition, setFixedPosition, setFont, setFont, setFontColor, setFontColor, setFontFamily, setFontFamily, setFontKerning, setFontScript, setFontSize, setHorizontalAlignment, setHyphenation, setItalic, setLineThrough, setOpacity, setRelativePosition, setSplitCharacters, setStrokeColor, setStrokeWidth, setTextAlignment, setTextRenderingMode, setUnderline, setUnderline, setUnderline, setUnderline, setWordSpacing
@Deprecated protected float leftMargin
Property.MARGIN_LEFT
instead.
@Deprecated protected float rightMargin
Property.MARGIN_RIGHT
instead.
@Deprecated protected float topMargin
Property.MARGIN_TOP
instead.
@Deprecated protected float bottomMargin
Property.MARGIN_BOTTOM
instead.
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
- the DocumentRenderer to set
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
publicT1 getDefaultProperty(int property)
IPropertyContainer
getDefaultProperty
in interface IPropertyContainer
getDefaultProperty
in class RootElement<Document>
T1
- the return type associated with the property
property
- the property to be retrieved
null
will be returned
protected RootRenderer ensureRootRendererNotNull()
ensureRootRendererNotNull
in class RootElement<Document>
protected void checkClosingStatus()
Copyright © 1998–2023 iText Group NV. All rights reserved.