Merger

Merger class

表示一组用于将各种不同类型的文档合并为单个输出文档的方法。

public class Merger : Processor

方法

姓名描述
static Create()创建邮件合并处理器的新实例。
static Create(MergerContext)创建邮件合并处理器的新实例。
Execute()执行处理器操作。
From(Stream, LoadOptions)指定要处理的输入文档。
From(string, LoadOptions)指定要处理的输入文档。
To(List<Stream>, SaveFormat)指定输出文档流列表。
To(List<Stream>, SaveOptions)指定输出文档流列表。
To(Stream, SaveFormat)指定处理器的输出流。
To(Stream, SaveOptions)指定处理器的输出流。
To(string, SaveFormat)指定处理器的输出文件。
To(string, SaveOptions)指定处理器的输出文件。
static Merge(Document[], MergeFormatMode)将给定的输入文档合并为一个文档并返回Document最终文档的实例。
static Merge(Stream[], MergeFormatMode)将给定的输入文档合并为一个文档并返回Document最终文档的实例。
static Merge(string, string[])使用指定的输入 和输出文件名将给定的输入文档合并为单个输出文档KeepSourceFormatting.
static Merge(string[], MergeFormatMode)将给定的输入文档合并为一个文档并返回Document最终文档的实例。
static Merge(Stream, Stream[], SaveFormat)使用指定的输入输出流和最终文档格式将给定的输入文档合并为单个输出文档。
static Merge(Stream[], LoadOptions[], MergeFormatMode)将给定的输入文档合并为一个文档并返回Document最终文档的实例。
static Merge(string[], LoadOptions[], MergeFormatMode)将给定的输入文档合并为一个文档并返回Document最终文档的实例。
static Merge(Stream, Stream[], SaveOptionsMergeFormatMode)使用指定的输入输出流和保存选项将给定的输入文档合并为单个输出文档。
static Merge(string, string[], SaveFormatMergeFormatMode)使用指定的输入输出文件名和最终文档格式将给定的输入文档合并为单个输出文档。
static Merge(string, string[], SaveOptionsMergeFormatMode)使用指定的输入输出文件名和保存选项将给定的输入文档合并为单个输出文档。
static Merge(Stream, Stream[], LoadOptions[], SaveOptionsMergeFormatMode)使用指定的输入输出流和保存选项将给定的输入文档合并为单个输出文档。
static Merge(string, string[], LoadOptions[], SaveOptionsMergeFormatMode)使用指定的输入输出文件名和保存选项将给定的输入文档合并为单个输出文档。
static MergeToImages(Stream[], ImageSaveOptionsMergeFormatMode)使用指定的图像保存选项将给定的输入文档流合并为单个输出文档。 将输出呈现为图像。
static MergeToImages(string[], ImageSaveOptionsMergeFormatMode)使用指定的输入输出文件名和保存选项将给定的输入文档合并为单个输出文档。 将输出呈现为图像。

评论

指定的输入和输出文件或流以及所需的合并和保存选项 用于将给定的输入文档合并为单个输出文档。

合并功能支持超过 35 种不同的文件格式。

例子

展示如何将文档合并为单个输出文档。

//合并文档有几种方法:
string inputDoc1 = MyDir + "Big document.docx";
string inputDoc2 = MyDir + "Tables.docx";

Merger.Merge(ArtifactsDir + "LowCode.MergeDocument.1.docx", new[] { inputDoc1, inputDoc2 });

OoxmlSaveOptions saveOptions = new OoxmlSaveOptions { Password = "Aspose.Words" };
Merger.Merge(ArtifactsDir + "LowCode.MergeDocument.2.docx", new[] { inputDoc1, inputDoc2 }, saveOptions, MergeFormatMode.KeepSourceFormatting);

Merger.Merge(ArtifactsDir + "LowCode.MergeDocument.3.pdf", new[] { inputDoc1, inputDoc2 }, SaveFormat.Pdf, MergeFormatMode.KeepSourceLayout);

LoadOptions firstLoadOptions = new LoadOptions() { IgnoreOleData = true };
LoadOptions secondLoadOptions = new LoadOptions() { IgnoreOleData = false };
Merger.Merge(ArtifactsDir + "LowCode.MergeDocument.4.docx", new[] { inputDoc1, inputDoc2 }, new[] { firstLoadOptions, secondLoadOptions }, saveOptions, MergeFormatMode.KeepSourceFormatting);

Document doc = Merger.Merge(new[] { inputDoc1, inputDoc2 }, MergeFormatMode.MergeFormatting);
doc.Save(ArtifactsDir + "LowCode.MergeDocument.5.docx");

doc = Merger.Merge(new[] { inputDoc1, inputDoc2 }, new[] { firstLoadOptions, secondLoadOptions }, MergeFormatMode.MergeFormatting);
doc.Save(ArtifactsDir + "LowCode.MergeDocument.6.docx");

也可以看看