public class

FlowDocument

extends ContentContainer
implements AutoCloseable
java.lang.Object
   ↳ com.pdftron.layout.ContentElement
     ↳ com.pdftron.layout.ContentNode
       ↳ com.pdftron.layout.ContentContainer
         ↳ com.pdftron.layout.FlowDocument

Class Overview

The class FlowDocument. Encapsulates document creation API.

A FlowDocument is a content container: paragraphs, tables and lists added to it are added to the current (last) section of the document.

Summary

Public Constructors
FlowDocument()
Creates an empty document containing a single section.
Public Methods
Section addSection()
Adds a new section at the end of the document and makes it the current section.
void close()
Frees the native memory of the object.
void destroy()
Frees the native memory of the object.
Section getCurrentSection()
Gets the current section, i.e.
int getNumSections()
Section getSection(int index)
Gets the section at the given index.
PDFDoc paginateToPDF()
Paginates the content tree into a PDFDoc object.
void setDefaultMargins(double leftPoints, double topPoints, double rightPoints, double bottomPoints)
Set the default margins for the document.
void setDefaultPageSize(double widthPoints, double heightPoints)
Set the default page size for the document.
[Expand]
Inherited Methods
From class com.pdftron.layout.ContentContainer
From class com.pdftron.layout.ContentNode
From class com.pdftron.layout.ContentElement
From class java.lang.Object
From interface java.lang.AutoCloseable

Public Constructors

public FlowDocument ()

Creates an empty document containing a single section.

Public Methods

public Section addSection ()

Adds a new section at the end of the document and makes it the current section.

The content of the new section starts on a new page. Content added directly to the FlowDocument afterwards is added to the newly created section.

Returns
  • The newly created section

public void close ()

Frees the native memory of the object. This can be explicity called to control the deallocation of native memory and avoid situations where the garbage collector does not free the object in a timely manner.

public void destroy ()

Frees the native memory of the object. This can be explicitly called to control the deallocation of native memory and avoid situations where the garbage collector does not free the object in a timely manner.

public Section getCurrentSection ()

Gets the current section, i.e. the section that content added directly to the FlowDocument goes into.

Returns
  • The current section of the document

public int getNumSections ()

Returns
  • The number of sections of the document

public Section getSection (int index)

Gets the section at the given index.

Parameters
index The zero based index of the section
Returns
  • The section at the given index

public PDFDoc paginateToPDF ()

Paginates the content tree into a PDFDoc object.

Returns
  • The PDFDoc object

public void setDefaultMargins (double leftPoints, double topPoints, double rightPoints, double bottomPoints)

Set the default margins for the document.

Parameters
leftPoints The left margin in points
topPoints The top margin in points
rightPoints The right margin in points
bottomPoints The bottom margin in points

public void setDefaultPageSize (double widthPoints, double heightPoints)

Set the default page size for the document.

Parameters
widthPoints The width in points
heightPoints The height in points