Splitter

Inheritance: java.lang.Object

public class Splitter

Provides methods intended to split the documents into parts using different criteria.

Methods

MethodDescription
extractPages(InputStream inputStream, OutputStream outputStream, int saveFormat, int startPageIndex, int pageCount)
extractPages(String inputFileName, String outputFileName, int startPageIndex, int pageCount)Extracts a specified range of pages from a document file and saves the extracted pages to a new file.
extractPages(String inputFileName, String outputFileName, int saveFormat, int startPageIndex, int pageCount)
removeBlankPages(InputStream inputStream, OutputStream outputStream, int saveFormat)
removeBlankPages(String inputFileName, String outputFileName)Removes empty pages from the document and saves the output.
removeBlankPages(String inputFileName, String outputFileName, int saveFormat)
split(InputStream inputStream, int saveFormat, SplitOptions options)
split(String inputFileName, String outputFileName, SplitOptions options)Splits a document into multiple parts based on the specified split options and saves the resulting parts to files.
split(String inputFileName, String outputFileName, int saveFormat, SplitOptions options)

extractPages(InputStream inputStream, OutputStream outputStream, int saveFormat, int startPageIndex, int pageCount)

public static void extractPages(InputStream inputStream, OutputStream outputStream, int saveFormat, int startPageIndex, int pageCount)

Parameters:

ParameterTypeDescription
inputStreamjava.io.InputStream
outputStreamjava.io.OutputStream
saveFormatint
startPageIndexint
pageCountint

extractPages(String inputFileName, String outputFileName, int startPageIndex, int pageCount)

public static void extractPages(String inputFileName, String outputFileName, int startPageIndex, int pageCount)

Extracts a specified range of pages from a document file and saves the extracted pages to a new file. The output file format is determined by the extension of the output file name.

Examples:

Shows how to extract pages from the document.


 // There is a several ways to extract pages from the document:
 String doc = getMyDir() + "Big document.docx";

 Splitter.extractPages(doc, getArtifactsDir() + "LowCode.ExtractPages.1.docx", 0, 2);
 Splitter.extractPages(doc, getArtifactsDir() + "LowCode.ExtractPages.2.docx", SaveFormat.DOCX, 0, 2);
 

Parameters:

ParameterTypeDescription
inputFileNamejava.lang.StringThe input file name.
outputFileNamejava.lang.StringThe output file name.
startPageIndexintThe zero-based index of the first page to extract.
pageCountintNumber of pages to be extracted.

extractPages(String inputFileName, String outputFileName, int saveFormat, int startPageIndex, int pageCount)

public static void extractPages(String inputFileName, String outputFileName, int saveFormat, int startPageIndex, int pageCount)

Parameters:

ParameterTypeDescription
inputFileNamejava.lang.String
outputFileNamejava.lang.String
saveFormatint
startPageIndexint
pageCountint

removeBlankPages(InputStream inputStream, OutputStream outputStream, int saveFormat)

public static ArrayList removeBlankPages(InputStream inputStream, OutputStream outputStream, int saveFormat)

Parameters:

ParameterTypeDescription
inputStreamjava.io.InputStream
outputStreamjava.io.OutputStream
saveFormatint

Returns: java.util.ArrayList

removeBlankPages(String inputFileName, String outputFileName)

public static ArrayList removeBlankPages(String inputFileName, String outputFileName)

Removes empty pages from the document and saves the output. Returns a list of page numbers that were removed.

Examples:

Shows how to remove empty pages from the document.


 // There is a several ways to remove empty pages from the document:
 String doc = getMyDir() + "Blank pages.docx";

 Splitter.removeBlankPages(doc, getArtifactsDir() + "LowCode.RemoveBlankPages.1.docx");
 Splitter.removeBlankPages(doc, getArtifactsDir() + "LowCode.RemoveBlankPages.2.docx", SaveFormat.DOCX);
 

Parameters:

ParameterTypeDescription
inputFileNamejava.lang.StringThe input file name.
outputFileNamejava.lang.StringThe output file name.

Returns: java.util.ArrayList - List of page numbers has been considered as blank and removed.

removeBlankPages(String inputFileName, String outputFileName, int saveFormat)

public static ArrayList removeBlankPages(String inputFileName, String outputFileName, int saveFormat)

Parameters:

ParameterTypeDescription
inputFileNamejava.lang.String
outputFileNamejava.lang.String
saveFormatint

Returns: java.util.ArrayList

split(InputStream inputStream, int saveFormat, SplitOptions options)

public static InputStream[] split(InputStream inputStream, int saveFormat, SplitOptions options)

Parameters:

ParameterTypeDescription
inputStreamjava.io.InputStream
saveFormatint
optionsSplitOptions

Returns: java.io.InputStream[]

split(String inputFileName, String outputFileName, SplitOptions options)

public static void split(String inputFileName, String outputFileName, SplitOptions options)

Splits a document into multiple parts based on the specified split options and saves the resulting parts to files. The output file format is determined by the extension of the output file name.

Examples:

Shows how to split document by pages.


 String doc = getMyDir() + "Big document.docx";

 SplitOptions options = new SplitOptions();
 options.setSplitCriteria(SplitCriteria.PAGE);
 Splitter.split(doc, getArtifactsDir() + "LowCode.SplitDocument.1.docx", options);
 Splitter.split(doc, getArtifactsDir() + "LowCode.SplitDocument.2.docx", SaveFormat.DOCX, options);
 

Parameters:

ParameterTypeDescription
inputFileNamejava.lang.StringThe input file name.
outputFileNamejava.lang.StringThe output file name used to generate file name for document parts using rule “outputFile_partIndex.extension”
optionsSplitOptionsDocument split options.

split(String inputFileName, String outputFileName, int saveFormat, SplitOptions options)

public static void split(String inputFileName, String outputFileName, int saveFormat, SplitOptions options)

Parameters:

ParameterTypeDescription
inputFileNamejava.lang.String
outputFileNamejava.lang.String
saveFormatint
optionsSplitOptions