DocumentSplitCriteria

Inheritance: java.lang.Object

public class DocumentSplitCriteria

Specifies how the document is split into parts when saving to SaveFormat.HTML, SaveFormat.EPUB or SaveFormat.AZW_3 format.

Remarks:

DocumentSplitCriteria is a set of flags which can be combined. For instance you can split the document at page breaks and heading paragraphs in the same export operation.

Different criteria can partially overlap. For instance, Heading 1 style is frequently given ParagraphFormat.getPageBreakBefore() / ParagraphFormat.setPageBreakBefore(boolean) property so it falls under two criteria: PAGE_BREAK and HEADING_PARAGRAPH. Some section breaks can cause page breaks and so on. In typical cases specifying only one flag is the most practical option.

Examples:

Shows how to use a specific encoding when saving a document to .epub.


 Document doc = new Document(getMyDir() + "Rendering.docx");

 // Use a SaveOptions object to specify the encoding for a document that we will save.
 HtmlSaveOptions saveOptions = new HtmlSaveOptions();
 saveOptions.setSaveFormat(SaveFormat.EPUB);
 saveOptions.setEncoding(StandardCharsets.UTF_8);

 // By default, an output .epub document will have all of its contents in one HTML part.
 // A split criterion allows us to segment the document into several HTML parts.
 // We will set the criteria to split the document into heading paragraphs.
 // This is useful for readers who cannot read HTML files more significant than a specific size.
 saveOptions.setDocumentSplitCriteria(DocumentSplitCriteria.HEADING_PARAGRAPH);

 // Specify that we want to export document properties.
 saveOptions.setExportDocumentProperties(true);

 doc.save(getArtifactsDir() + "HtmlSaveOptions.Doc2EpubSaveOptions.epub", saveOptions);
 

Fields

FieldDescription
COLUMN_BREAKThe document is split into parts at column breaks.
HEADING_PARAGRAPHThe document is split into parts at a paragraph formatted using a heading style Heading 1, Heading 2 etc.
NONEThe document is not split.
PAGE_BREAKThe document is split into parts at explicit page breaks.
SECTION_BREAKThe document is split into parts at a section break of any type.
length

Methods

MethodDescription
fromName(String documentSplitCriteriaName)
fromNames(Set documentSplitCriteriaNames)
getName(int documentSplitCriteria)
getNames(int documentSplitCriteria)
getValues()
toString(int documentSplitCriteria)
toStringSet(int attr)

COLUMN_BREAK

public static int COLUMN_BREAK

The document is split into parts at column breaks. A column break can be specified by a ControlChar.COLUMN_BREAK character or a section break specifying start of new section in a new column.

HEADING_PARAGRAPH

public static int HEADING_PARAGRAPH

The document is split into parts at a paragraph formatted using a heading style Heading 1, Heading 2 etc. Use together with HtmlSaveOptions.getDocumentSplitHeadingLevel() / HtmlSaveOptions.setDocumentSplitHeadingLevel(int) to specify the heading levels (from 1 to the specified level) at which to split.

NONE

public static int NONE

The document is not split.

PAGE_BREAK

public static int PAGE_BREAK

The document is split into parts at explicit page breaks. A page break can be specified by a ControlChar.PAGE_BREAK character, a section break specifying start of new section on a new page, or a paragraph that has its ParagraphFormat.getPageBreakBefore() / ParagraphFormat.setPageBreakBefore(boolean) property set to true .

SECTION_BREAK

public static int SECTION_BREAK

The document is split into parts at a section break of any type.

length

public static int length

fromName(String documentSplitCriteriaName)

public static int fromName(String documentSplitCriteriaName)

Parameters:

ParameterTypeDescription
documentSplitCriteriaNamejava.lang.String

Returns: int

fromNames(Set documentSplitCriteriaNames)

public static int fromNames(Set documentSplitCriteriaNames)

Parameters:

ParameterTypeDescription
documentSplitCriteriaNamesjava.util.Set

Returns: int

getName(int documentSplitCriteria)

public static String getName(int documentSplitCriteria)

Parameters:

ParameterTypeDescription
documentSplitCriteriaint

Returns: java.lang.String

getNames(int documentSplitCriteria)

public static Set getNames(int documentSplitCriteria)

Parameters:

ParameterTypeDescription
documentSplitCriteriaint

Returns: java.util.Set

getValues()

public static int[] getValues()

Returns: int[]

toString(int documentSplitCriteria)

public static String toString(int documentSplitCriteria)

Parameters:

ParameterTypeDescription
documentSplitCriteriaint

Returns: java.lang.String

toStringSet(int attr)

public static String toStringSet(int attr)

Parameters:

ParameterTypeDescription
attrint

Returns: java.lang.String