iText 7 7.1.9 API
iText.Layout.Document Class Reference

Document is the default root element when creating a self-sufficient PDF. More...

Inheritance diagram for iText.Layout.Document:
iText.Layout.RootElement< iText.Layout.Document >

Public Member Functions

  Document (PdfDocument pdfDoc)
  Creates a document from a iText.Kernel.Pdf.PdfDocument. More...
 
  Document (PdfDocument pdfDoc, PageSize pageSize)
  Creates a document from a iText.Kernel.Pdf.PdfDocument with a manually set iText.Kernel.Geom.PageSize. More...
 
  Document (PdfDocument pdfDoc, PageSize pageSize, bool immediateFlush)
  Creates a document from a iText.Kernel.Pdf.PdfDocument with a manually set iText.Kernel.Geom.PageSize. More...
 
override void  Close ()
  Closes the document and associated PdfDocument. More...
 
virtual iText.Layout.Document  Add (AreaBreak areaBreak)
  Terminates the current element, usually a page. More...
 
override iText.Layout.Document  Add (IBlockElement element)
 
virtual PdfDocument  GetPdfDocument ()
  Gets PDF document. More...
 
virtual void  SetRenderer (DocumentRenderer documentRenderer)
  Changes the iText.Layout.Renderer.DocumentRenderer at runtime. More...
 
virtual void  Flush ()
  Forces all registered renderers (including child element renderers) to flush their contents to the content stream. More...
 
virtual void  Relayout ()
  Performs an entire recalculation of the document flow, taking into account all its current child elements. More...
 
virtual float  GetLeftMargin ()
  Gets the left margin, measured in points More...
 
virtual void  SetLeftMargin (float leftMargin)
  Sets the left margin, measured in points More...
 
virtual float  GetRightMargin ()
  Gets the right margin, measured in points More...
 
virtual void  SetRightMargin (float rightMargin)
  Sets the right margin, measured in points More...
 
virtual float  GetTopMargin ()
  Gets the top margin, measured in points More...
 
virtual void  SetTopMargin (float topMargin)
  Sets the top margin, measured in points More...
 
virtual float  GetBottomMargin ()
  Gets the bottom margin, measured in points More...
 
virtual void  SetBottomMargin (float bottomMargin)
  Sets the bottom margin, measured in points More...
 
virtual void  SetMargins (float topMargin, float rightMargin, float bottomMargin, float leftMargin)
  Convenience method to set all margins with one method. More...
 
virtual Rectangle  GetPageEffectiveArea (PageSize pageSize)
  Returns the area that will actually be used to write on the page, given the current margins. More...
 
override T1  GetDefaultProperty< T1 > (int property)
 
- Public Member Functions inherited from iText.Layout.RootElement< iText.Layout.Document >
virtual T  Add (IBlockElement element)
  Adds an element to the root. More...
 
virtual T  Add (Image image)
  Adds an image to the root. More...
 
virtual FontProvider  GetFontProvider ()
  Gets iText.Layout.Font.FontProvider if presents. More...
 
virtual void  SetFontProvider (FontProvider fontProvider)
  Sets iText.Layout.Font.FontProvider. More...
 
override bool  HasProperty (int property)
  Checks if this entity has the specified property. More...
 
override bool  HasOwnProperty (int property)
  Checks if this entity has the specified property, i.e. if it was set to this very element earlier More...
 
override T1  GetProperty< T1 > (int property)
  Gets the property from this entity. More...
 
override T1  GetOwnProperty< T1 > (int property)
  Gets own property from this entity. More...
 
override T1  GetDefaultProperty< T1 > (int property)
  Gets the default property from this entity. More...
 
override void  DeleteOwnProperty (int property)
  Deletes the own property of this entity. More...
 
override void  SetProperty (int property, Object value)
  Sets a property for this entity. More...
 
virtual RootRenderer  GetRenderer ()
  Gets the rootRenderer attribute, a specialized iText.Layout.Renderer.IRenderer that acts as the root object that other renderers descend from. More...
 
virtual T  ShowTextAligned (String text, float x, float y, TextAlignment? textAlign)
  Convenience method to write a text aligned about the specified point More...
 
virtual T  ShowTextAligned (String text, float x, float y, TextAlignment? textAlign, float angle)
  Convenience method to write a text aligned about the specified point More...
 
virtual T  ShowTextAligned (String text, float x, float y, TextAlignment? textAlign, VerticalAlignment? vertAlign, float angle)
  Convenience method to write a text aligned about the specified point More...
 
virtual T  ShowTextAligned (Paragraph p, float x, float y, TextAlignment? textAlign)
  Convenience method to write a text aligned about the specified point More...
 
virtual T  ShowTextAligned (Paragraph p, float x, float y, TextAlignment? textAlign, VerticalAlignment? vertAlign)
  Convenience method to write a text aligned about the specified point More...
 
virtual T  ShowTextAligned (Paragraph p, float x, float y, int pageNumber, TextAlignment? textAlign, VerticalAlignment? vertAlign, float radAngle)
  Convenience method to write a text aligned about the specified point More...
 
virtual T  ShowTextAlignedKerned (String text, float x, float y, TextAlignment? textAlign, VerticalAlignment? vertAlign, float radAngle)
  Convenience method to write a kerned text aligned about the specified point More...
 

Detailed Description

Document is the default root element when creating a self-sufficient PDF.

Document is the default root element when creating a self-sufficient PDF. It mainly operates high-level operations e.g. setting page size and rotation, adding elements, and writing text at specific coordinates. It has no knowledge of the actual PDF concepts and syntax.

A Document 's rendering behavior can be modified by extending iText.Layout.Renderer.DocumentRenderer and setting an instance of this newly created with SetRenderer(iText.Layout.Renderer.DocumentRenderer).

Constructor & Destructor Documentation

◆ Document() [1/3]

iText.Layout.Document.Document ( PdfDocument  pdfDoc )
inline

Creates a document from a iText.Kernel.Pdf.PdfDocument.

Creates a document from a iText.Kernel.Pdf.PdfDocument . Initializes the first page with the iText.Kernel.Pdf.PdfDocument 's current default iText.Kernel.Geom.PageSize.

Parameters
pdfDoc the in-memory representation of the PDF document

◆ Document() [2/3]

iText.Layout.Document.Document ( PdfDocument  pdfDoc,
PageSize  pageSize 
)
inline

Creates a document from a iText.Kernel.Pdf.PdfDocument with a manually set iText.Kernel.Geom.PageSize.

Parameters
pdfDoc the in-memory representation of the PDF document
pageSize the page size

◆ Document() [3/3]

iText.Layout.Document.Document ( PdfDocument  pdfDoc,
PageSize  pageSize,
bool  immediateFlush 
)
inline

Creates a document from a iText.Kernel.Pdf.PdfDocument with a manually set iText.Kernel.Geom.PageSize.

Parameters
pdfDoc the in-memory representation of the PDF document
pageSize the page size
immediateFlush if true, write pages and page-related instructions to the iText.Kernel.Pdf.PdfDocument as soon as possible.

Member Function Documentation

◆ Add()

virtual iText.Layout.Document iText.Layout.Document.Add ( AreaBreak  areaBreak )
inlinevirtual

Terminates the current element, usually a page.

Terminates the current element, usually a page. Sets the next element to be the size specified in the argument.

Parameters
areaBreak an iText.Layout.Element.AreaBreak , optionally with a specified size
Returns
this element

◆ Close()

override void iText.Layout.Document.Close ( )
inlinevirtual

Closes the document and associated PdfDocument.

Implements iText.Layout.RootElement< iText.Layout.Document >.

◆ Flush()

virtual void iText.Layout.Document.Flush ( )
inlinevirtual

Forces all registered renderers (including child element renderers) to flush their contents to the content stream.

◆ GetBottomMargin()

virtual float iText.Layout.Document.GetBottomMargin ( )
inlinevirtual

Gets the bottom margin, measured in points

Returns
a float containing the bottom margin value

◆ GetLeftMargin()

virtual float iText.Layout.Document.GetLeftMargin ( )
inlinevirtual

Gets the left margin, measured in points

Returns
a float containing the left margin value

◆ GetPageEffectiveArea()

virtual Rectangle iText.Layout.Document.GetPageEffectiveArea ( PageSize  pageSize )
inlinevirtual

Returns the area that will actually be used to write on the page, given the current margins.

Returns the area that will actually be used to write on the page, given the current margins. Does not have any side effects on the document.

Parameters
pageSize the size of the page to
Returns
a iText.Kernel.Geom.Rectangle with the required dimensions and origin point

◆ GetPdfDocument()

virtual PdfDocument iText.Layout.Document.GetPdfDocument ( )
inlinevirtual

Gets PDF document.

Returns
the in-memory representation of the PDF document

◆ GetRightMargin()

virtual float iText.Layout.Document.GetRightMargin ( )
inlinevirtual

Gets the right margin, measured in points

Returns
a float containing the right margin value

◆ GetTopMargin()

virtual float iText.Layout.Document.GetTopMargin ( )
inlinevirtual

Gets the top margin, measured in points

Returns
a float containing the top margin value

◆ Relayout()

virtual void iText.Layout.Document.Relayout ( )
inlinevirtual

Performs an entire recalculation of the document flow, taking into account all its current child elements.

Performs an entire recalculation of the document flow, taking into account all its current child elements. May become very resource-intensive for large documents.

Do not use when you have set RootElement<T>.immediateFlush to true.

◆ SetBottomMargin()

virtual void iText.Layout.Document.SetBottomMargin ( float  bottomMargin )
inlinevirtual

Sets the bottom margin, measured in points

Parameters
bottomMargin a float containing the new bottom margin value

◆ SetLeftMargin()

virtual void iText.Layout.Document.SetLeftMargin ( float  leftMargin )
inlinevirtual

Sets the left margin, measured in points

Parameters
leftMargin a float containing the new left margin value

◆ SetMargins()

virtual void iText.Layout.Document.SetMargins ( float  topMargin,
float  rightMargin,
float  bottomMargin,
float  leftMargin 
)
inlinevirtual

Convenience method to set all margins with one method.

Parameters
topMargin the upper margin
rightMargin the right margin
leftMargin the left margin
bottomMargin the lower margin

◆ SetRenderer()

virtual void iText.Layout.Document.SetRenderer ( DocumentRenderer  documentRenderer )
inlinevirtual

Changes the iText.Layout.Renderer.DocumentRenderer at runtime.

Changes the iText.Layout.Renderer.DocumentRenderer at runtime. Use this to customize the Document's iText.Layout.Renderer.IRenderer behavior.

Parameters
documentRenderer the DocumentRenderer to set

◆ SetRightMargin()

virtual void iText.Layout.Document.SetRightMargin ( float  rightMargin )
inlinevirtual

Sets the right margin, measured in points

Parameters
rightMargin a float containing the new right margin value

◆ SetTopMargin()

virtual void iText.Layout.Document.SetTopMargin ( float  topMargin )
inlinevirtual

Sets the top margin, measured in points

Parameters
topMargin a float containing the new top margin value