Splitter

Inheritance: java.lang.Object, com.aspose.words.Processor

public class Splitter extends Processor

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

Methods

MethodDescription
create(SplitterContext context)Creates new instance of the splitter processor.
execute()Execute the processor action.
extractPages(InputStream inputStream, OutputStream outputStream, SaveOptions saveOptions, int startPageIndex, int pageCount)
extractPages(InputStream inputStream, OutputStream outputStream, int saveFormat, int startPageIndex, int pageCount)
extractPages(String inputFileName, String outputFileName, SaveOptions saveOptions, int startPageIndex, int pageCount)Extracts a specified range of pages from a document file and saves the extracted pages to a new file using the specified save format.
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)
from(InputStream input)
from(InputStream input, LoadOptions loadOptions)Specifies input document for processing.
from(String input)
from(String input, LoadOptions loadOptions)Specifies input document for processing.
removeBlankPages(InputStream inputStream, OutputStream outputStream, SaveOptions saveOptions)
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, SaveOptions saveOptions)Removes empty pages from the document and saves the output in the specified format.
removeBlankPages(String inputFileName, String outputFileName, int saveFormat)
split(InputStream inputStream, SaveOptions saveOptions, SplitOptions options)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.
split(InputStream inputStream, int saveFormat, SplitOptions options)
split(String inputFileName, String outputFileName, SaveOptions saveOptions, SplitOptions options)Splits a document into multiple parts based on the specified split options and saves the resulting parts to files in the specified save format.
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)
to(OutputStream output, SaveOptions saveOptions)
to(OutputStream output, int saveFormat)
to(String output)
to(String output, SaveOptions saveOptions)Specifies output file for the processor.
to(String output, int saveFormat)
to(ArrayList output, SaveOptions saveOptions)
to(ArrayList output, int saveFormat)
toOutput(ArrayList output, SaveOptions saveOptions)
toOutput(ArrayList output, int saveFormat)

create(SplitterContext context)

public static Splitter create(SplitterContext context)

Creates new instance of the splitter processor.

Examples:

Shows how to split document by pages using context.


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

 SplitterContext splitterContext = new SplitterContext();
 splitterContext.getSplitOptions().setSplitCriteria(SplitCriteria.PAGE);

 Splitter.create(splitterContext)
         .from(doc)
         .to(getArtifactsDir() + "LowCode.SplitContextDocument.docx")
         .execute();
 

Shows how to split document from the stream by pages using context.


 try (FileInputStream streamIn = new FileInputStream(getMyDir() + "Big document.docx")) {
     SplitterContext splitterContext = new SplitterContext();
     splitterContext.getSplitOptions().setSplitCriteria(SplitCriteria.PAGE);

     ArrayList pages = new ArrayList<>();
     Splitter.create(splitterContext)
             .from(streamIn)
             .toOutput(pages, SaveFormat.DOCX)
             .execute();
 }
 

Parameters:

ParameterTypeDescription
contextSplitterContext

Returns: Splitter

execute()

public void execute()

Execute the processor action.

Examples:

Shows how to convert documents with a single line of code using context.


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

 ConverterContext converterContext = new ConverterContext();

 Converter.create(converterContext)
         .from(doc)
         .to(getArtifactsDir() + "LowCode.ConvertContext.1.pdf")
         .execute();

 Converter.create(converterContext)
         .from(doc)
         .to(getArtifactsDir() + "LowCode.ConvertContext.2.pdf", SaveFormat.RTF)
         .execute();

 OoxmlSaveOptions saveOptions = new OoxmlSaveOptions();
 {
     saveOptions.setPassword("Aspose.Words");
 }
 LoadOptions loadOptions = new LoadOptions();
 {
     loadOptions.setIgnoreOleData(true);
 }
 Converter.create(converterContext)
         .from(doc, loadOptions)
         .to(getArtifactsDir() + "LowCode.ConvertContext.3.docx", saveOptions)
         .execute();

 Converter.create(converterContext)
         .from(doc)
         .to(getArtifactsDir() + "LowCode.ConvertContext.4.png", new ImageSaveOptions(SaveFormat.PNG))
         .execute();
 

Shows how to convert documents from a stream with a single line of code using context.


 String doc = getMyDir() + "Document.docx";
 ConverterContext converterContext = new ConverterContext();

 try (FileInputStream streamIn = new FileInputStream(doc)) {
     try (FileOutputStream streamOut = new FileOutputStream(getArtifactsDir() + "LowCode.ConvertContextStream.1.docx")) {
         Converter.create(converterContext)
                 .from(streamIn)
                 .to(streamOut, SaveFormat.RTF)
                 .execute();
     }

     OoxmlSaveOptions saveOptions = new OoxmlSaveOptions();
     {
         saveOptions.setPassword("Aspose.Words");
     }
     LoadOptions loadOptions = new LoadOptions();
     {
         loadOptions.setIgnoreOleData(true);
     }
     try (FileOutputStream streamOut1 = new FileOutputStream(getArtifactsDir() + "LowCode.ConvertContextStream.2.docx")) {
         Converter.create(converterContext)
                 .from(streamIn, loadOptions)
                 .to(streamOut1, saveOptions)
                 .execute();
     }
 }
 

Shows how to merge documents into a single output document using context.


 //There is a several ways to merge documents:
 String inputDoc1 = getMyDir() + "Big document.docx";
 String inputDoc2 = getMyDir() + "Tables.docx";

 MergerContext mergerContext = new MergerContext();
 mergerContext.setMergeFormatMode(MergeFormatMode.KEEP_SOURCE_FORMATTING);

 Merger.create(mergerContext)
         .from(inputDoc1)
         .from(inputDoc2)
         .to(getArtifactsDir() + "LowCode.MergeContextDocuments.1.docx")
         .execute();

 LoadOptions firstLoadOptions = new LoadOptions();
 {
     firstLoadOptions.setIgnoreOleData(true);
 }
 LoadOptions secondLoadOptions = new LoadOptions();
 {
     secondLoadOptions.setIgnoreOleData(false);
 }
 Merger.create(mergerContext)
         .from(inputDoc1, firstLoadOptions)
         .from(inputDoc2, secondLoadOptions)
         .to(getArtifactsDir() + "LowCode.MergeContextDocuments.2.docx", SaveFormat.DOCX)
         .execute();

 OoxmlSaveOptions saveOptions = new OoxmlSaveOptions();
 {
     saveOptions.setPassword("Aspose.Words");
 }
 Merger.create(mergerContext)
         .from(inputDoc1)
         .from(inputDoc2)
         .to(getArtifactsDir() + "LowCode.MergeContextDocuments.3.docx", saveOptions)
         .execute();
 

Shows how to merge documents from stream into a single output document using context.


 //There is a several ways to merge documents:
 String inputDoc1 = getMyDir() + "Big document.docx";
 String inputDoc2 = getMyDir() + "Tables.docx";

 MergerContext mergerContext = new MergerContext();
 mergerContext.setMergeFormatMode(MergeFormatMode.KEEP_SOURCE_FORMATTING);

 try (FileInputStream firstStreamIn = new FileInputStream(inputDoc1)) {
     try (FileInputStream secondStreamIn = new FileInputStream(inputDoc2)) {
         OoxmlSaveOptions saveOptions = new OoxmlSaveOptions();
         {
             saveOptions.setPassword("Aspose.Words");
         }
         try (FileOutputStream streamOut = new FileOutputStream(getArtifactsDir() + "LowCode.MergeStreamContextDocuments.1.docx")) {
             Merger.create(mergerContext)
                     .from(firstStreamIn)
                     .from(secondStreamIn)
                     .to(streamOut, saveOptions)
                     .execute();
         }

         LoadOptions firstLoadOptions = new LoadOptions();
         {
             firstLoadOptions.setIgnoreOleData(true);
         }
         LoadOptions secondLoadOptions = new LoadOptions();
         {
             secondLoadOptions.setIgnoreOleData(false);
         }
         try (FileOutputStream streamOut1 = new FileOutputStream(getArtifactsDir() + "LowCode.MergeStreamContextDocuments.2.docx")) {
             Merger.create(mergerContext)
                     .from(firstStreamIn, firstLoadOptions)
                     .from(secondStreamIn, secondLoadOptions)
                     .to(streamOut1, SaveFormat.DOCX)
                     .execute();
         }
     }
 }
 

extractPages(InputStream inputStream, OutputStream outputStream, SaveOptions saveOptions, int startPageIndex, int pageCount)

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

Parameters:

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

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, SaveOptions saveOptions, int startPageIndex, int pageCount)

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

Extracts a specified range of pages from a document file and saves the extracted pages to a new file using the specified save format.

Parameters:

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

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

from(InputStream input)

public Processor from(InputStream input)

Parameters:

ParameterTypeDescription
inputjava.io.InputStream

Returns: Processor

from(InputStream input, LoadOptions loadOptions)

public Processor from(InputStream input, LoadOptions loadOptions)

Specifies input document for processing.

Remarks:

If the processor accepts only one file as an input, only the last specified file will be processed. Merger processor accepts multiple files as an input, as the result all the specified documents will be merged. Converter processor accepts only one file as an input, so only the last specified file will be converted.

Examples:

Shows how to convert documents from a stream with a single line of code using context.


 String doc = getMyDir() + "Document.docx";
 ConverterContext converterContext = new ConverterContext();

 try (FileInputStream streamIn = new FileInputStream(doc)) {
     try (FileOutputStream streamOut = new FileOutputStream(getArtifactsDir() + "LowCode.ConvertContextStream.1.docx")) {
         Converter.create(converterContext)
                 .from(streamIn)
                 .to(streamOut, SaveFormat.RTF)
                 .execute();
     }

     OoxmlSaveOptions saveOptions = new OoxmlSaveOptions();
     {
         saveOptions.setPassword("Aspose.Words");
     }
     LoadOptions loadOptions = new LoadOptions();
     {
         loadOptions.setIgnoreOleData(true);
     }
     try (FileOutputStream streamOut1 = new FileOutputStream(getArtifactsDir() + "LowCode.ConvertContextStream.2.docx")) {
         Converter.create(converterContext)
                 .from(streamIn, loadOptions)
                 .to(streamOut1, saveOptions)
                 .execute();
     }
 }
 

Shows how to merge documents from stream into a single output document using context.


 //There is a several ways to merge documents:
 String inputDoc1 = getMyDir() + "Big document.docx";
 String inputDoc2 = getMyDir() + "Tables.docx";

 MergerContext mergerContext = new MergerContext();
 mergerContext.setMergeFormatMode(MergeFormatMode.KEEP_SOURCE_FORMATTING);

 try (FileInputStream firstStreamIn = new FileInputStream(inputDoc1)) {
     try (FileInputStream secondStreamIn = new FileInputStream(inputDoc2)) {
         OoxmlSaveOptions saveOptions = new OoxmlSaveOptions();
         {
             saveOptions.setPassword("Aspose.Words");
         }
         try (FileOutputStream streamOut = new FileOutputStream(getArtifactsDir() + "LowCode.MergeStreamContextDocuments.1.docx")) {
             Merger.create(mergerContext)
                     .from(firstStreamIn)
                     .from(secondStreamIn)
                     .to(streamOut, saveOptions)
                     .execute();
         }

         LoadOptions firstLoadOptions = new LoadOptions();
         {
             firstLoadOptions.setIgnoreOleData(true);
         }
         LoadOptions secondLoadOptions = new LoadOptions();
         {
             secondLoadOptions.setIgnoreOleData(false);
         }
         try (FileOutputStream streamOut1 = new FileOutputStream(getArtifactsDir() + "LowCode.MergeStreamContextDocuments.2.docx")) {
             Merger.create(mergerContext)
                     .from(firstStreamIn, firstLoadOptions)
                     .from(secondStreamIn, secondLoadOptions)
                     .to(streamOut1, SaveFormat.DOCX)
                     .execute();
         }
     }
 }
 

Parameters:

ParameterTypeDescription
inputjava.io.InputStreamInput document stream.
loadOptionsLoadOptionsOptional load options used to load the document.

Returns: Processor - Returns processor with specified input file stream.

from(String input)

public Processor from(String input)

Parameters:

ParameterTypeDescription
inputjava.lang.String

Returns: Processor

from(String input, LoadOptions loadOptions)

public Processor from(String input, LoadOptions loadOptions)

Specifies input document for processing.

Remarks:

If the processor accepts only one file as an input, only the last specified file will be processed. Merger processor accepts multiple files as an input, as the result all the specified documents will be merged. Converter processor accepts only one file as an input, so only the last specified file will be converted.

Examples:

Shows how to convert documents with a single line of code using context.


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

 ConverterContext converterContext = new ConverterContext();

 Converter.create(converterContext)
         .from(doc)
         .to(getArtifactsDir() + "LowCode.ConvertContext.1.pdf")
         .execute();

 Converter.create(converterContext)
         .from(doc)
         .to(getArtifactsDir() + "LowCode.ConvertContext.2.pdf", SaveFormat.RTF)
         .execute();

 OoxmlSaveOptions saveOptions = new OoxmlSaveOptions();
 {
     saveOptions.setPassword("Aspose.Words");
 }
 LoadOptions loadOptions = new LoadOptions();
 {
     loadOptions.setIgnoreOleData(true);
 }
 Converter.create(converterContext)
         .from(doc, loadOptions)
         .to(getArtifactsDir() + "LowCode.ConvertContext.3.docx", saveOptions)
         .execute();

 Converter.create(converterContext)
         .from(doc)
         .to(getArtifactsDir() + "LowCode.ConvertContext.4.png", new ImageSaveOptions(SaveFormat.PNG))
         .execute();
 

Shows how to merge documents into a single output document using context.


 //There is a several ways to merge documents:
 String inputDoc1 = getMyDir() + "Big document.docx";
 String inputDoc2 = getMyDir() + "Tables.docx";

 MergerContext mergerContext = new MergerContext();
 mergerContext.setMergeFormatMode(MergeFormatMode.KEEP_SOURCE_FORMATTING);

 Merger.create(mergerContext)
         .from(inputDoc1)
         .from(inputDoc2)
         .to(getArtifactsDir() + "LowCode.MergeContextDocuments.1.docx")
         .execute();

 LoadOptions firstLoadOptions = new LoadOptions();
 {
     firstLoadOptions.setIgnoreOleData(true);
 }
 LoadOptions secondLoadOptions = new LoadOptions();
 {
     secondLoadOptions.setIgnoreOleData(false);
 }
 Merger.create(mergerContext)
         .from(inputDoc1, firstLoadOptions)
         .from(inputDoc2, secondLoadOptions)
         .to(getArtifactsDir() + "LowCode.MergeContextDocuments.2.docx", SaveFormat.DOCX)
         .execute();

 OoxmlSaveOptions saveOptions = new OoxmlSaveOptions();
 {
     saveOptions.setPassword("Aspose.Words");
 }
 Merger.create(mergerContext)
         .from(inputDoc1)
         .from(inputDoc2)
         .to(getArtifactsDir() + "LowCode.MergeContextDocuments.3.docx", saveOptions)
         .execute();
 

Parameters:

ParameterTypeDescription
inputjava.lang.StringInput document file name.
loadOptionsLoadOptionsOptional load options used to load the document.

Returns: Processor - Returns processor with specified input file.

removeBlankPages(InputStream inputStream, OutputStream outputStream, SaveOptions saveOptions)

public static ArrayList removeBlankPages(InputStream inputStream, OutputStream outputStream, SaveOptions saveOptions)

Parameters:

ParameterTypeDescription
inputStreamjava.io.InputStream
outputStreamjava.io.OutputStream
saveOptionsSaveOptions

Returns: java.util.ArrayList

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, SaveOptions saveOptions)

public static ArrayList removeBlankPages(String inputFileName, String outputFileName, SaveOptions saveOptions)

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

Parameters:

ParameterTypeDescription
inputFileNamejava.lang.StringThe input file name.
outputFileNamejava.lang.StringThe output file name.
saveOptionsSaveOptionsThe save options.

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, SaveOptions saveOptions, SplitOptions options)

public static OutputStream[] split(InputStream inputStream, SaveOptions saveOptions, SplitOptions options)

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.

Parameters:

ParameterTypeDescription
inputStreamjava.io.InputStreamThe input stream.
saveOptionsSaveOptionsThe save options.
optionsSplitOptionsDocument split options.

Returns: java.io.OutputStream[]

split(InputStream inputStream, int saveFormat, SplitOptions options)

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

Parameters:

ParameterTypeDescription
inputStreamjava.io.InputStream
saveFormatint
optionsSplitOptions

Returns: java.io.OutputStream[]

split(String inputFileName, String outputFileName, SaveOptions saveOptions, SplitOptions options)

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

Splits a document into multiple parts based on the specified split options and saves the resulting parts to files in the specified save format.

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”
saveOptionsSaveOptionsThe save options.
optionsSplitOptionsDocument split options.

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

to(OutputStream output, SaveOptions saveOptions)

public Processor to(OutputStream output, SaveOptions saveOptions)

Parameters:

ParameterTypeDescription
outputjava.io.OutputStream
saveOptionsSaveOptions

Returns: Processor

to(OutputStream output, int saveFormat)

public Processor to(OutputStream output, int saveFormat)

Parameters:

ParameterTypeDescription
outputjava.io.OutputStream
saveFormatint

Returns: Processor

to(String output)

public Processor to(String output)

Parameters:

ParameterTypeDescription
outputjava.lang.String

Returns: Processor

to(String output, SaveOptions saveOptions)

public Processor to(String output, SaveOptions saveOptions)

Specifies output file for the processor.

Remarks:

If the output consists of multiple files, the specified output file name is used to generate the file name for each part following the rule: ‘outputFile_partIndex.extension’.

Examples:

Shows how to convert documents with a single line of code using context.


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

 ConverterContext converterContext = new ConverterContext();

 Converter.create(converterContext)
         .from(doc)
         .to(getArtifactsDir() + "LowCode.ConvertContext.1.pdf")
         .execute();

 Converter.create(converterContext)
         .from(doc)
         .to(getArtifactsDir() + "LowCode.ConvertContext.2.pdf", SaveFormat.RTF)
         .execute();

 OoxmlSaveOptions saveOptions = new OoxmlSaveOptions();
 {
     saveOptions.setPassword("Aspose.Words");
 }
 LoadOptions loadOptions = new LoadOptions();
 {
     loadOptions.setIgnoreOleData(true);
 }
 Converter.create(converterContext)
         .from(doc, loadOptions)
         .to(getArtifactsDir() + "LowCode.ConvertContext.3.docx", saveOptions)
         .execute();

 Converter.create(converterContext)
         .from(doc)
         .to(getArtifactsDir() + "LowCode.ConvertContext.4.png", new ImageSaveOptions(SaveFormat.PNG))
         .execute();
 

Shows how to merge documents into a single output document using context.


 //There is a several ways to merge documents:
 String inputDoc1 = getMyDir() + "Big document.docx";
 String inputDoc2 = getMyDir() + "Tables.docx";

 MergerContext mergerContext = new MergerContext();
 mergerContext.setMergeFormatMode(MergeFormatMode.KEEP_SOURCE_FORMATTING);

 Merger.create(mergerContext)
         .from(inputDoc1)
         .from(inputDoc2)
         .to(getArtifactsDir() + "LowCode.MergeContextDocuments.1.docx")
         .execute();

 LoadOptions firstLoadOptions = new LoadOptions();
 {
     firstLoadOptions.setIgnoreOleData(true);
 }
 LoadOptions secondLoadOptions = new LoadOptions();
 {
     secondLoadOptions.setIgnoreOleData(false);
 }
 Merger.create(mergerContext)
         .from(inputDoc1, firstLoadOptions)
         .from(inputDoc2, secondLoadOptions)
         .to(getArtifactsDir() + "LowCode.MergeContextDocuments.2.docx", SaveFormat.DOCX)
         .execute();

 OoxmlSaveOptions saveOptions = new OoxmlSaveOptions();
 {
     saveOptions.setPassword("Aspose.Words");
 }
 Merger.create(mergerContext)
         .from(inputDoc1)
         .from(inputDoc2)
         .to(getArtifactsDir() + "LowCode.MergeContextDocuments.3.docx", saveOptions)
         .execute();
 

Parameters:

ParameterTypeDescription
outputjava.lang.StringOutput file name.
saveOptionsSaveOptionsOptional save options. If not specified, save format is determined by the file extension.

Returns: Processor - Returns processor with specified output file.

to(String output, int saveFormat)

public Processor to(String output, int saveFormat)

Parameters:

ParameterTypeDescription
outputjava.lang.String
saveFormatint

Returns: Processor

to(ArrayList output, SaveOptions saveOptions)

public Processor to(ArrayList output, SaveOptions saveOptions)

Parameters:

ParameterTypeDescription
outputjava.util.ArrayList
saveOptionsSaveOptions

Returns: Processor

to(ArrayList output, int saveFormat)

public Processor to(ArrayList output, int saveFormat)

Parameters:

ParameterTypeDescription
outputjava.util.ArrayList
saveFormatint

Returns: Processor

toOutput(ArrayList output, SaveOptions saveOptions)

public Processor toOutput(ArrayList output, SaveOptions saveOptions)

Parameters:

ParameterTypeDescription
outputjava.util.ArrayList
saveOptionsSaveOptions

Returns: Processor

toOutput(ArrayList output, int saveFormat)

public Processor toOutput(ArrayList output, int saveFormat)

Parameters:

ParameterTypeDescription
outputjava.util.ArrayList
saveFormatint

Returns: Processor