Skip to content

Instantly share code, notes, and snippets.

@GroupDocsGists
Created March 22, 2019 16:14
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save GroupDocsGists/e2ed425ec7b856a1889c084019f2ddec to your computer and use it in GitHub Desktop.
Save GroupDocsGists/e2ed425ec7b856a1889c084019f2ddec to your computer and use it in GitHub Desktop.
// For complete examples and data files, please go to https://github.com/groupdocs-redaction/GroupDocs.Redaction-for-.NET
//Initialize RedactionPolicy
RedactionPolicy policy = RedactionPolicy.Load(Common.MapSourceFilePath("Documents/Bulk/RedactionPolicy.xml"));
foreach (var fileEntry in Directory.GetFiles(Common.MapSourceFilePath(Inbound_Path)))
{
using (Document doc = Redactor.Load( fileEntry))
{
//Apply redaction
RedactionSummary result = doc.RedactWith(policy.Redactions);
// Set output directory path
String resultFolder = result.Status != RedactionStatus.Failed ? Common.MapSourceFilePath(Outbound_Done_Path) : Common.MapSourceFilePath(Outbound_Failed_Path);
// Save the ouput files after applying redactions
using (Stream fileStream = File.Create(Path.Combine(resultFolder, Path.GetFileName(fileEntry))))
{
doc.Save(fileStream, new SaveOptions() { RasterizeToPDF = false, RedactedFileSuffix = DateTime.Now.ToString() });
fileStream.Close();
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment