GroupDocs.Redaction for .NET 26.6 Release Notes

Major Features

There are the following improvements in this release:

  • Implemented the ability to specify document format explicitly when redacting a file or stream. Set LoadOptions.FileType to a supported FileType constant (for example, FileType.DOCX or FileType.PDF) to provide proper file format. This is especially useful for streams without a file name or when the file extension does not match the actual content.
  • Added GroupDocs.Readaction types in order to substitute System.Drawing in the future releases. The GroupDocs.Redaction.Options.Drawing namespace contains Color, Point, Size, Rectangle, Font, FontStyle types that are independent of System.Drawing and may be used to increase cross-platform compatibility.

Full List of Issues Covering all Changes in this Release

KeySummaryCategory
REDACTIONNET-572Specify file type when opening document (stream or file)Enhancement
REDACTIONNET-799Migrate Away from System.Drawing to Enhance Cross-Platform CompatibilityEnhancement

Public API and Backward Incompatible Changes

Public API changes
  • Added LoadOptions.FileType property.
  • Added LoadOptions(FileType fileType) constructor.
  • Added drawing types in GroupDocs.Redaction.Options.Drawing namespace: Color, Point, Size, Rectangle, Font, FontStyle.
  • Added new overloads that accept GroupDocs.Redaction.Options.Drawing types in ReplacementOptions, RegionReplacementOptions, ImageAreaRedaction, PageAreaFilter, TextFragment, and related APIs.
  • Marked ReplacementOptions.BoxColor as obsolete. Use ReplacementOptions.BoxFillColor instead.
  • Marked ReplacementOptions(System.Drawing.Color) constructor as obsolete. Use ReplacementOptions(GroupDocs.Redaction.Options.Drawing.Color) instead.
  • Marked RegionReplacementOptions.FillColor as obsolete. Use RegionReplacementOptions.AreaFillColor instead.
  • Marked RegionReplacementOptions.Size as obsolete. Use RegionReplacementOptions.AreaSize instead.
  • Marked RegionReplacementOptions(System.Drawing.Color, System.Drawing.Size) constructor as obsolete. Use RegionReplacementOptions(GroupDocs.Redaction.Options.Drawing.Color, GroupDocs.Redaction.Options.Drawing.Size) instead.
  • Marked RegionReplacementOptions(System.Drawing.Color, System.Drawing.Font, string) constructor as obsolete. Use RegionReplacementOptions(GroupDocs.Redaction.Options.Drawing.Color, GroupDocs.Redaction.Options.Drawing.Font, string) instead.
  • Marked ImageAreaRedaction.TopLeft as obsolete. Use ImageAreaRedaction.TopLeftPosition instead.
  • Marked ImageAreaRedaction(System.Drawing.Point, RegionReplacementOptions) constructor as obsolete. Use ImageAreaRedaction(GroupDocs.Redaction.Options.Drawing.Point, RegionReplacementOptions) instead.
  • Marked PageAreaFilter.Rectangle as obsolete. Use PageAreaFilter.AreaRectangle instead.
  • Marked PageAreaFilter(System.Drawing.Point, System.Drawing.Size) constructor as obsolete. Use PageAreaFilter(GroupDocs.Redaction.Options.Drawing.Point, GroupDocs.Redaction.Options.Drawing.Size) instead.
  • Marked TextFragment.Rectangle as obsolete. Use TextFragment.BoundingRectangle instead.
  • Marked TextFragment(string, System.Drawing.Rectangle) constructor as obsolete. Use TextFragment(string, GroupDocs.Redaction.Options.Drawing.Rectangle) instead.
  • Marked IImageFormatInstance.EditArea(System.Drawing.Point, RegionReplacementOptions) as obsolete. Use IImageFormatInstance.EditArea(GroupDocs.Redaction.Options.Drawing.Point, RegionReplacementOptions) instead.
Usage

Open a document from a stream or file path while explicitly specifying its format:

using System.IO;
using GroupDocs.Redaction.Options;
using GroupDocs.Redaction.Redactions;

using (Stream stream = File.OpenRead("sample.docx"))
{
    using (Redactor redactor = new Redactor(stream, new LoadOptions(FileType.DOCX)))
    {
        redactor.Apply(new DeleteAnnotationRedaction());
        redactor.Save();
    }
}

using (Redactor redactor = new Redactor("sample.pdf", new LoadOptions(FileType.PDF)))
{
    redactor.Apply(new ExactPhraseRedaction("Test", new ReplacementOptions("[redacted]")));
    redactor.Save();
}

Use GroupDocs.Redaction.Options.Drawing instead of System.Drawing for colored boxes and image-area redactions:

using GroupDocs.Redaction.Options.Drawing;
using GroupDocs.Redaction.Redactions;

// Previously: new ReplacementOptions(System.Drawing.Color.Red)
using (Redactor redactor = new Redactor("sample.docx"))
{
    redactor.Apply(new ExactPhraseRedaction("John Doe", new ReplacementOptions(Color.Red)));
    redactor.Save();
}

// Previously: new ImageAreaRedaction(new System.Drawing.Point(516, 311),
//     new RegionReplacementOptions(System.Drawing.Color.Blue, new System.Drawing.Size(170, 35)))
using (Redactor redactor = new Redactor("sample.jpg"))
{
    redactor.Apply(new ImageAreaRedaction(new Point(516, 311),
        new RegionReplacementOptions(Color.Blue, new Size(170, 35))));
    redactor.Save();
}

When LoadOptions.FileType is set to a value other than FileType.Unknown, GroupDocs.Redaction skips binary format detection and opens the document using the specified type. The default behavior is unchanged when FileType is not specified.