Class Splitter
Namespace: Aspose.Words.LowCode
Assembly: Aspose.Words.dll (25.12.0)
Provides methods intended to split the documents into parts using different criteria.
public class Splitter : ProcessorInheritance
Inherited Members
Processor.mResultDocument , Processor.From(string) , Processor.From(string, LoadOptions) , Processor.From(Stream) , Processor.From(Stream, LoadOptions) , Processor.To(string) , Processor.To(string, SaveOptions) , Processor.To(string, SaveFormat) , Processor.To(Stream, SaveOptions) , Processor.To(Stream, SaveFormat) , Processor.To(List<Stream>, SaveOptions) , Processor.To(List<Stream>, SaveFormat) , Processor.Execute() , Processor.Execute(CancellationToken) , Processor.ExecuteCore() , Processor.CheckArgumentsSet() , Processor.GetPartFileName(string, int, SaveFormat) , object.GetType() , object.MemberwiseClone() , object.ToString() , object.Equals(object?) , object.Equals(object?, object?) , object.ReferenceEquals(object?, object?) , object.GetHashCode()
Methods
Create(SplitterContext)
Creates new instance of the splitter processor.
public static Splitter Create(SplitterContext context)Parameters
context SplitterContext
Returns
Examples
Shows how to split document by pages using context.
string doc = MyDir + "Big document.docx";
SplitterContext splitterContext = new SplitterContext();
splitterContext.SplitOptions.SplitCriteria = SplitCriteria.Page;
Splitter.Create(splitterContext)
.From(doc)
.To(ArtifactsDir + "LowCode.SplitContextDocument.docx")
.Execute();Shows how to split document from the stream by pages using context.
using (FileStream streamIn = new FileStream(MyDir + "Big document.docx", FileMode.Open, FileAccess.Read))
{
SplitterContext splitterContext = new SplitterContext();
splitterContext.SplitOptions.SplitCriteria = SplitCriteria.Page;
List<Stream> pages = new List<Stream>();
Splitter.Create(splitterContext)
.From(streamIn)
.To(pages, SaveFormat.Docx)
.Execute();
}ExecuteCore()
protected override void ExecuteCore()ExtractPages(string, string, int, int)
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.
public static void ExtractPages(string inputFileName, string outputFileName, int startPageIndex, int pageCount)Parameters
inputFileName string
The input file name.
outputFileName string
The output file name.
startPageIndex int
The zero-based index of the first page to extract.
pageCount int
Number of pages to be extracted.
Examples
Shows how to extract pages from the document.
// There is a several ways to extract pages from the document:
string doc = MyDir + "Big document.docx";
Splitter.ExtractPages(doc, ArtifactsDir + "LowCode.ExtractPages.1.docx", 0, 2);
Splitter.ExtractPages(doc, ArtifactsDir + "LowCode.ExtractPages.2.docx", SaveFormat.Docx, 0, 2);ExtractPages(string, string, SaveFormat, int, int)
Extracts a specified range of pages from a document file and saves the extracted pages to a new file using the specified save format.
public static void ExtractPages(string inputFileName, string outputFileName, SaveFormat saveFormat, int startPageIndex, int pageCount)Parameters
inputFileName string
The input file name.
outputFileName string
The output file name.
saveFormat SaveFormat
The save format.
startPageIndex int
The zero-based index of the first page to extract.
pageCount int
Number of pages to be extracted.
Examples
Shows how to extract pages from the document.
// There is a several ways to extract pages from the document:
string doc = MyDir + "Big document.docx";
Splitter.ExtractPages(doc, ArtifactsDir + "LowCode.ExtractPages.1.docx", 0, 2);
Splitter.ExtractPages(doc, ArtifactsDir + "LowCode.ExtractPages.2.docx", SaveFormat.Docx, 0, 2);ExtractPages(string, string, SaveOptions, int, int)
Extracts a specified range of pages from a document file and saves the extracted pages to a new file using the specified save format.
public static void ExtractPages(string inputFileName, string outputFileName, SaveOptions saveOptions, int startPageIndex, int pageCount)Parameters
inputFileName string
The input file name.
outputFileName string
The output file name.
saveOptions SaveOptions
The save options.
startPageIndex int
The zero-based index of the first page to extract.
pageCount int
Number of pages to be extracted.
ExtractPages(Stream, Stream, SaveFormat, int, int)
Extracts a specified range of pages from a document stream and saves the extracted pages to an output stream using the specified save format.
public static void ExtractPages(Stream inputStream, Stream outputStream, SaveFormat saveFormat, int startPageIndex, int pageCount)Parameters
inputStream Stream
The input stream.
outputStream Stream
The output stream.
saveFormat SaveFormat
The save format.
startPageIndex int
The zero-based index of the first page to extract.
pageCount int
Number of pages to be extracted.
Examples
Shows how to extract pages from the document from the stream.
using (FileStream streamIn = new FileStream(MyDir + "Big document.docx", FileMode.Open, FileAccess.Read))
{
using (FileStream streamOut = new FileStream(ArtifactsDir + "LowCode.ExtractPagesStream.docx", FileMode.Create, FileAccess.ReadWrite))
Splitter.ExtractPages(streamIn, streamOut, SaveFormat.Docx, 0, 2);
}ExtractPages(Stream, Stream, SaveOptions, int, int)
Extracts a specified range of pages from a document stream and saves the extracted pages to an output stream using the specified save format.
public static void ExtractPages(Stream inputStream, Stream outputStream, SaveOptions saveOptions, int startPageIndex, int pageCount)Parameters
inputStream Stream
The input stream.
outputStream Stream
The output stream.
saveOptions SaveOptions
The save options.
startPageIndex int
The zero-based index of the first page to extract.
pageCount int
Number of pages to be extracted.
RemoveBlankPages(string, string)
Removes empty pages from the document and saves the output. Returns a list of page numbers that were removed.
public static List<int> RemoveBlankPages(string inputFileName, string outputFileName)Parameters
inputFileName string
The input file name.
outputFileName string
The output file name.
Returns
List of page numbers has been considered as blank and 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 = MyDir + "Blank pages.docx";
Splitter.RemoveBlankPages(doc, ArtifactsDir + "LowCode.RemoveBlankPages.1.docx");
Splitter.RemoveBlankPages(doc, ArtifactsDir + "LowCode.RemoveBlankPages.2.docx", SaveFormat.Docx);RemoveBlankPages(string, string, SaveFormat)
Removes empty pages from the document and saves the output in the specified format. Returns a list of page numbers that were removed.
public static List<int> RemoveBlankPages(string inputFileName, string outputFileName, SaveFormat saveFormat)Parameters
inputFileName string
The input file name.
outputFileName string
The output file name.
saveFormat SaveFormat
The save format.
Returns
List of page numbers has been considered as blank and 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 = MyDir + "Blank pages.docx";
Splitter.RemoveBlankPages(doc, ArtifactsDir + "LowCode.RemoveBlankPages.1.docx");
Splitter.RemoveBlankPages(doc, ArtifactsDir + "LowCode.RemoveBlankPages.2.docx", SaveFormat.Docx);RemoveBlankPages(string, string, SaveOptions)
Removes empty pages from the document and saves the output in the specified format. Returns a list of page numbers that were removed.
public static List<int> RemoveBlankPages(string inputFileName, string outputFileName, SaveOptions saveOptions)Parameters
inputFileName string
The input file name.
outputFileName string
The output file name.
saveOptions SaveOptions
The save options.
Returns
List of page numbers has been considered as blank and removed.
RemoveBlankPages(Stream, Stream, SaveFormat)
Removes blank pages from a document provided in an input stream and saves the updated document to an output stream in the specified save format. Returns a list of page numbers that were removed.
public static List<int> RemoveBlankPages(Stream inputStream, Stream outputStream, SaveFormat saveFormat)Parameters
inputStream Stream
The input stream.
outputStream Stream
The output stream.
saveFormat SaveFormat
The save format.
Returns
List of page numbers has been considered as blank and removed.
Examples
Shows how to remove empty pages from the document from the stream.
using (FileStream streamIn = new FileStream(MyDir + "Blank pages.docx", FileMode.Open, FileAccess.Read))
{
using (FileStream streamOut = new FileStream(ArtifactsDir + "LowCode.RemoveBlankPagesStream.docx", FileMode.Create, FileAccess.ReadWrite))
Splitter.RemoveBlankPages(streamIn, streamOut, SaveFormat.Docx);
}RemoveBlankPages(Stream, Stream, SaveOptions)
Removes blank pages from a document provided in an input stream and saves the updated document to an output stream in the specified save format. Returns a list of page numbers that were removed.
public static List<int> RemoveBlankPages(Stream inputStream, Stream outputStream, SaveOptions saveOptions)Parameters
inputStream Stream
The input stream.
outputStream Stream
The output stream.
saveOptions SaveOptions
The save options.
Returns
List of page numbers has been considered as blank and removed.
Split(string, string, SplitOptions)
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.
public static void Split(string inputFileName, string outputFileName, SplitOptions options)Parameters
inputFileName string
The input file name.
outputFileName string
The output file name used to generate file name for document parts using rule “outputFile_partIndex.extension”
options SplitOptions
Document split options.
Examples
Shows how to split document by pages.
string doc = MyDir + "Big document.docx";
SplitOptions options = new SplitOptions();
options.SplitCriteria = SplitCriteria.Page;
Splitter.Split(doc, ArtifactsDir + "LowCode.SplitDocument.1.docx", options);
Splitter.Split(doc, ArtifactsDir + "LowCode.SplitDocument.2.docx", SaveFormat.Docx, options);Split(string, string, SaveFormat, SplitOptions)
Splits a document into multiple parts based on the specified split options and saves the resulting parts to files in the specified save format.
public static void Split(string inputFileName, string outputFileName, SaveFormat saveFormat, SplitOptions options)Parameters
inputFileName string
The input file name.
outputFileName string
The output file name used to generate file name for document parts using rule “outputFile_partIndex.extension”
saveFormat SaveFormat
The save format.
options SplitOptions
Document split options.
Examples
Shows how to split document by pages.
string doc = MyDir + "Big document.docx";
SplitOptions options = new SplitOptions();
options.SplitCriteria = SplitCriteria.Page;
Splitter.Split(doc, ArtifactsDir + "LowCode.SplitDocument.1.docx", options);
Splitter.Split(doc, ArtifactsDir + "LowCode.SplitDocument.2.docx", SaveFormat.Docx, options);Split(string, string, SaveOptions, SplitOptions)
Splits a document into multiple parts based on the specified split options and saves the resulting parts to files in the specified save format.
public static void Split(string inputFileName, string outputFileName, SaveOptions saveOptions, SplitOptions options)Parameters
inputFileName string
The input file name.
outputFileName string
The output file name used to generate file name for document parts using rule “outputFile_partIndex.extension”
saveOptions SaveOptions
The save options.
options SplitOptions
Document split options.
Split(Stream, SaveFormat, SplitOptions)
Splits a document from an input stream into multiple parts based on the specified split options and returns the resulting parts as an array of streams in the specified save format.
public static Stream[] Split(Stream inputStream, SaveFormat saveFormat, SplitOptions options)Parameters
inputStream Stream
The input stream.
saveFormat SaveFormat
The save format.
options SplitOptions
Document split options.
Returns
Stream []
Examples
Shows how to split document from the stream by pages.
using (FileStream streamIn = new FileStream(MyDir + "Big document.docx", FileMode.Open, FileAccess.Read))
{
SplitOptions options = new SplitOptions();
options.SplitCriteria = SplitCriteria.Page;
Stream[] stream = Splitter.Split(streamIn, SaveFormat.Docx, options);
}Split(Stream, SaveOptions, SplitOptions)
Splits a document from an input stream into multiple parts based on the specified split options and returns the resulting parts as an array of streams in the specified save format.
public static Stream[] Split(Stream inputStream, SaveOptions saveOptions, SplitOptions options)Parameters
inputStream Stream
The input stream.
saveOptions SaveOptions
The save options.
options SplitOptions
Document split options.
Returns
Stream []