Skip to content

Instantly share code, notes, and snippets.

GroupDocs GroupDocsGists

Block or report user

Report or block GroupDocsGists

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
View DynamicBookmarkInsertionWord.cs
//setting up source
const String strDocumentTemplate = "Word Templates/Dynamic bookmarks.docx";
//Setting up destination
const String strDocumentReport = "Word Reports/Dynamic bookmarks.docx";
//Setting up Uri Expression
const String bookmark_expression = "gd_bookmark";
//Setting up Display Text Expression
const String displayTextExpression = "GroupDocs";
try
{
View PasswordProtection.cs
// For complete examples and data files, please go to https://github.com/groupdocs-redaction/GroupDocs.Redaction-for-.NET
public override void Load(System.IO.Stream input)
{
try
{
// check security and load document
SetAccessGranted(true);
}
catch (SomeSecurityException)
View DocumentFormatInstanceUsage.cs
// For complete examples and data files, please go to https://github.com/groupdocs-redaction/GroupDocs.Redaction-for-.NET
var config = RedactorConfiguration.GetInstance();
config.AvailableFormats.Add(new DocumentFormatConfiguration()
{
ExtensionFilter = ".log",
DocumentType = typeof(PlainTextDocument)
});
View DocumentFormatInstance .cs
// For complete examples and data files, please go to https://github.com/groupdocs-redaction/GroupDocs.Redaction-for-.NET
public class PlainTextDocument : DocumentFormatInstance, ITextualFormatInstance
{
private RedactorSettings Settings { get; set; }
private List<string> FileContent { get; set; }
public PlainTextDocument()
{
FileContent = new List<string>();
}
View ExtendSupportedExtensionList.cs
// For complete examples and data files, please go to https://github.com/groupdocs-redaction/GroupDocs.Redaction-for-.NET
var config = RedactorConfiguration.GetInstance();
var docxSettings = config.FindFormat(".docx");
docxSettings.ExtensionFilter = docxSettings.ExtensionFilter + ",.log";
using (Redactor redactor = new Redactor(@"C:\sample.log"))
{
// Here we can use document instance to perform redactions
}
View CustomLoggerUsage.cs
// For complete examples and data files, please go to https://github.com/groupdocs-redaction/GroupDocs.Redaction-for-.NET
using (Stream stream = File.Open(@"sample.docx", FileMode.Open, FileAccess.ReadWrite))
{
var logger = new CustomLogger();
using (Redactor redactor = new Redactor(stream, new LoadOptions(), new RedactorSettings(logger)))
{
// Here we can use document instance to make redactions
redactor.Apply(new DeleteAnnotationRedaction());
if (!logger.HasErrors)
{
View CustomLogger.cs
// For complete examples and data files, please go to https://github.com/groupdocs-redaction/GroupDocs.Redaction-for-.NET
using GroupDocs.Redaction.Options;
/// <summary>
/// This is an example of ILogger implementation, tracking count of error messages.
/// </summary>
public class CustomLogger : ILogger
{
public List<string> Errors { get; private set; }
public List<string> Traces { get; private set; }
public List<string> Warnings { get; private set; }
View RedactionPoliciesUsage.cs
// For complete examples and data files, please go to https://github.com/groupdocs-redaction/GroupDocs.Redaction-for-.NET
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))
{
View RedactionPolicies.xml
// For complete examples and data files, please go to https://github.com/groupdocs-redaction/GroupDocs.Redaction-for-.NET
<?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" />
View UsageOfRedactionDump.cs
// For complete examples and data files, please go to https://github.com/groupdocs-redaction/GroupDocs.Redaction-for-.NET
using (Redactor redactor = new Redactor("\\Sample.docx", new LoadOptions(), new RedactorSettings(new RedactionDump())))
{
// Assign an instance before using Redactor
redactor.Apply(new ExactPhraseRedaction("John Doe", new ReplacementOptions("[personal]")));
redactor.Save();
}
You can’t perform that action at this time.