Created
March 22, 2019 16:14
-
-
Save GroupDocsGists/e2ed425ec7b856a1889c084019f2ddec to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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