MergerContext
内容
[
隐藏
]MergerContext class
文档合并上下文。
public class MergerContext : ProcessorContext
构造函数
姓名 | 描述 |
---|---|
MergerContext() | 默认构造函数。 |
特性
姓名 | 描述 |
---|---|
FontSettings { get; set; } | 处理器使用的字体设置。 |
LayoutOptions { get; } | 处理器使用的文档布局选项。 |
MergeFormatMode { get; set; } | 指定如何合并冲突的格式。 |
WarningCallback { get; set; } | 处理器使用的警告回调。 |
例子
展示如何使用上下文将文档合并为单个输出文档。
//合并文档有几种方法:
string inputDoc1 = MyDir + "Big document.docx";
string inputDoc2 = MyDir + "Tables.docx";
Merger.Create(new MergerContext() { MergeFormatMode = MergeFormatMode.KeepSourceFormatting })
.From(inputDoc1)
.From(inputDoc2)
.To(ArtifactsDir + "LowCode.MergeContextDocuments.1.docx")
.Execute();
LoadOptions firstLoadOptions = new LoadOptions() { IgnoreOleData = true };
LoadOptions secondLoadOptions = new LoadOptions() { IgnoreOleData = false };
Merger.Create(new MergerContext() { MergeFormatMode = MergeFormatMode.KeepSourceFormatting })
.From(inputDoc1, firstLoadOptions)
.From(inputDoc2, secondLoadOptions)
.To(ArtifactsDir + "LowCode.MergeContextDocuments.2.docx", SaveFormat.Docx)
.Execute();
OoxmlSaveOptions saveOptions = new OoxmlSaveOptions { Password = "Aspose.Words" };
Merger.Create(new MergerContext() { MergeFormatMode = MergeFormatMode.KeepSourceFormatting })
.From(inputDoc1)
.From(inputDoc2)
.To(ArtifactsDir + "LowCode.MergeContextDocuments.3.docx", saveOptions)
.Execute();
展示如何使用上下文将流中的文档合并为单个输出文档。
//合并文档有几种方法:
string inputDoc1 = MyDir + "Big document.docx";
string inputDoc2 = MyDir + "Tables.docx";
using (FileStream firstStreamIn = new FileStream(MyDir + "Big document.docx", FileMode.Open, FileAccess.Read))
{
using (FileStream secondStreamIn = new FileStream(MyDir + "Tables.docx", FileMode.Open, FileAccess.Read))
{
OoxmlSaveOptions saveOptions = new OoxmlSaveOptions { Password = "Aspose.Words" };
using (FileStream streamOut = new FileStream(ArtifactsDir + "LowCode.MergeStreamContextDocuments.1.docx", FileMode.Create, FileAccess.ReadWrite))
Merger.Create(new MergerContext() { MergeFormatMode = MergeFormatMode.KeepSourceFormatting })
.From(firstStreamIn)
.From(secondStreamIn)
.To(streamOut, saveOptions)
.Execute();
LoadOptions firstLoadOptions = new LoadOptions() { IgnoreOleData = true };
LoadOptions secondLoadOptions = new LoadOptions() { IgnoreOleData = false };
using (FileStream streamOut = new FileStream(ArtifactsDir + "LowCode.MergeStreamContextDocuments.2.docx", FileMode.Create, FileAccess.ReadWrite))
Merger.Create(new MergerContext() { MergeFormatMode = MergeFormatMode.KeepSourceFormatting })
.From(firstStreamIn, firstLoadOptions)
.From(secondStreamIn, secondLoadOptions)
.To(streamOut, SaveFormat.Docx)
.Execute();
}
}
也可以看看
- class ProcessorContext
- 命名空间 Aspose.Words.LowCode
- 部件 Aspose.Words