Apply

Apply(Redaction)

Past een redactie toe op het document.

public RedactorChangeLog Apply(Redaction redaction)
Parameter Type Beschrijving
redaction Redaction Een voorbeeld vanRedaction toepassen

Winstwaarde

Geslaagd of mislukt en foutmelding in dit geval

Voorbeelden

In het volgende voorbeeld ziet u hoe u een enkele redactie op het document toepast.

using (Redactor redactor = new Redactor(@"D:\\test.docx"))
{
   RedactorChangeLog result = redactor.Apply(new RegexRedaction(LookupStrings.SSNRegexPattern, new ReplacementOptions("[ssn]")));
   if (result.Status != RedactionStatus.Failed)
   {
      redactor.Save();
   };
}

Zie ook


Apply(Redaction[])

Past een reeks redacties toe op het document.

public RedactorChangeLog Apply(Redaction[] redactions)
Parameter Type Beschrijving
redactions Redaction[] Een reeks redacties om toe te passen

Winstwaarde

Geslaagd of mislukt en foutmelding in dit geval

Voorbeelden

In het volgende voorbeeld ziet u hoe u een lijst met redacties toepast op het document.

using (Redactor redactor = new Redactor(@"D:\\test.docx"))
{
   var redactionList = new Redaction[] 
   {
      new ExactPhraseRedaction(LookupStrings.ClientName, new ReplacementOptions("[client]")),
      new ExactPhraseRedaction(LookupStrings.ClientAddress, new ReplacementOptions(System.Drawing.Color.Red)),
      new RegexRedaction(LookupStrings.SSNRegexPattern, new ReplacementOptions("[ssn]")),
      new RegexRedaction(LookupStrings.BankCardRegexPattern, new ReplacementOptions(System.Drawing.Color.Blue)),
      // ... andere redacties
      new DeleteAnnotationRedaction("(?im:(use|show|describe))"),
      new EraseMetadataRedaction(MetadataFilter.Author),
      new MetadataSearchRedaction(LookupStrings.CompanyName, "--company--") 
   }; 
   RedactorChangeLog result = redactor.Apply(redactionList);
   // false, als ten minste één redactie is mislukt
   if (result.Status != RedactionStatus.Failed)
   {
      redactor.Save();
   };
}

Zie ook


Apply(RedactionPolicy)

Past een redactiebeleid toe op het document.

public RedactorChangeLog Apply(RedactionPolicy policy)
Parameter Type Beschrijving
policy RedactionPolicy Redactiebeleid

Winstwaarde

Geslaagd of mislukt en foutmelding in dit geval

Voorbeelden

Het volgende voorbeeld laat zien hoe u een redactiebeleid toepast op alle bestanden in een bepaalde inkomende map en opslaat in een van de uitgaande mappen - voor succesvol bijgewerkte bestanden en voor mislukte bestanden.

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 });
   	     }        
     }
}   

Zie ook