Load
内容
[
隐藏
]
Load(string)
加载一个实例RedactionPolicy
来自文件路径.
public static RedactionPolicy Load(string filePath)
范围 | 类型 | 描述 |
---|---|---|
filePath | String | XML 文件的路径 |
返回值
编辑政策
例子
以下示例演示如何将编辑策略应用于给定入站文件夹中的所有文件,并保存到出站文件夹之一 - 用于成功更新的文件和失败的文件。
以下示例包含一个示例 XML 策略文件,其中包含适用于所有类型的编辑的示例配置。
RedactionPolicy policy = RedactionPolicy.Load("RedactionPolicy.xml");
foreach (var fileEntry in Directory.GetFileNames("C:\\Inbound"))
{
using (Redactor redactor = new Redactor(Path.Combine("C:\\Inbound\\", fileEntry)))
{
RedactorChangeLog result = redactor.Apply(policy);
String resultFolder = result.Status != RedactionStatus.Failed ? "C:\\Outbound\\Done\\" : "C:\\Outbound\\Failed\\";
using (Stream fileStream = File.Open(Path.Combine(resultFolder, fileEntry), FileMode.Open, FileAccess.ReadWrite))
{
redactor.Save(fileStream, new RasterizationOptions() { Enabled = false });
}
}
}
<?xml version="1.0" encoding="utf-8"?>
<redactionPolicy xmlns = "http://www.groupdocs.com/redaction" >
<regexRedaction regularExpression="(dolor)" actionType="ReplaceString" replacement="foobar" />
<exactPhraseRedaction searchPhrase = "dolor" caseSensitive="true" actionType="DrawBox" color="Red" />
<cellColumnRedaction regularExpression = "(foo)bar1" replacement="[red1]" columnIndex="1" worksheetIndex="2" />
<cellColumnRedaction regularExpression = "(foo)bar2" replacement="[red2]" wokrsheetName="Sample" />
<eraseMetadataRedaction filter = "All" />
<metadataSearchRedaction filter="Title, Author" replacement="foobar" valueExpression="(metasearch)" keyExpression="" />
<annotationRedaction regularExpression = "(anno1)" replacement="foobar" />
<deleteAnnotationRedaction regularExpression = "(anno2)" />
<imageAreaRedaction pointX="15" pointY="17" width="200" height="10" color="#AA50FC" />
<imageAreaRedaction pointX = "110" pointY="120" width="60" height="20" color="Magenta" />
</redactionPolicy>
也可以看看
- class RedactionPolicy
- 命名空间 GroupDocs.Redaction
- 部件 GroupDocs.Redaction
Load(Stream)
加载一个实例RedactionPolicy
来自流.
public static RedactionPolicy Load(Stream input)
范围 | 类型 | 描述 |
---|---|---|
input | Stream | 包含 XML 配置的流 |
返回值
编辑政策
例子
以下示例演示如何将编辑策略应用于给定入站文件夹中的所有文件,并保存到出站文件夹之一 - 用于成功更新的文件和失败的文件。
以下示例包含一个示例 XML 策略文件,其中包含适用于所有类型的编辑的示例配置。
RedactionPolicy policy = RedactionPolicy.Load("RedactionPolicy.xml");
foreach (var fileEntry in Directory.GetFileNames("C:\\Inbound"))
{
using (Redactor redactor = new Redactor(Path.Combine("C:\\Inbound\\", fileEntry)))
{
RedactorChangeLog result = redactor.Apply(policy);
String resultFolder = result.Status != RedactionStatus.Failed ? "C:\\Outbound\\Done\\" : "C:\\Outbound\\Failed\\";
using (Stream fileStream = File.Open(Path.Combine(resultFolder, fileEntry), FileMode.Open, FileAccess.ReadWrite))
{
redactor.Save(fileStream, new RasterizationOptions() { Enabled = false });
}
}
}
<?xml version="1.0" encoding="utf-8"?>
<redactionPolicy xmlns = "http://www.groupdocs.com/redaction" >
<regexRedaction regularExpression="(dolor)" actionType="ReplaceString" replacement="foobar" />
<exactPhraseRedaction searchPhrase = "dolor" caseSensitive="true" actionType="DrawBox" color="Red" />
<cellColumnRedaction regularExpression = "(foo)bar1" replacement="[red1]" columnIndex="1" worksheetIndex="2" />
<cellColumnRedaction regularExpression = "(foo)bar2" replacement="[red2]" wokrsheetName="Sample" />
<eraseMetadataRedaction filter = "All" />
<metadataSearchRedaction filter="Title, Author" replacement="foobar" valueExpression="(metasearch)" keyExpression="" />
<annotationRedaction regularExpression = "(anno1)" replacement="foobar" />
<deleteAnnotationRedaction regularExpression = "(anno2)" />
<imageAreaRedaction pointX="15" pointY="17" width="200" height="10" color="#AA50FC" />
<imageAreaRedaction pointX = "110" pointY="120" width="60" height="20" color="Magenta" />
</redactionPolicy>
也可以看看
- class RedactionPolicy
- 命名空间 GroupDocs.Redaction
- 部件 GroupDocs.Redaction