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
|
<T1> T1 |
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 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 Document add(IBlockElement element)
RootElement
add
in class RootElement<Document>
element
- an element with spacial margins, tabbing, and alignmentBlockElement
public PdfDocument getPdfDocument()
public void setRenderer(DocumentRenderer documentRenderer)
DocumentRenderer
at runtime. Use this to customize
the Document's IRenderer
behavior.documentRenderer
- the DocumentRenderer to setpublic void flush()
public void relayout()
Do not use when you have set RootElement.immediateFlush
to true
.
public float getLeftMargin()
float
containing the left margin valuepublic void setLeftMargin(float leftMargin)
leftMargin
- a float
containing the new left margin valuepublic float getRightMargin()
float
containing the right margin valuepublic void setRightMargin(float rightMargin)
rightMargin
- a float
containing the new right margin valuepublic float getTopMargin()
float
containing the top margin valuepublic void setTopMargin(float topMargin)
topMargin
- a float
containing the new top margin valuepublic float getBottomMargin()
float
containing the bottom margin valuepublic void setBottomMargin(float bottomMargin)
bottomMargin
- a float
containing the new bottom margin valuepublic 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 pointpublic <T1> T1 getDefaultProperty(int property)
IPropertyContainer
getDefaultProperty
in interface IPropertyContainer
getDefaultProperty
in class RootElement<Document>
T1
- the return type associated with the propertyproperty
- the property to be retrievednull
will be returnedprotected RootRenderer ensureRootRendererNotNull()
ensureRootRendererNotNull
in class RootElement<Document>
protected void checkClosingStatus()
Copyright © 1998–2021 iText Group NV. All rights reserved.