GroupDocs.Redaction for .NET 26.6 Release Notes
This page contains release notes for GroupDocs.Redaction for .NET 26.6
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.FileTypeto a supportedFileTypeconstant (for example,FileType.DOCXorFileType.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.Drawingnamespace containsColor,Point,Size,Rectangle,Font,FontStyletypes that are independent ofSystem.Drawingand may be used to increase cross-platform compatibility.
Full List of Issues Covering all Changes in this Release
| Key | Summary | Category |
|---|---|---|
| REDACTIONNET-572 | Specify file type when opening document (stream or file) | Enhancement |
| REDACTIONNET-799 | Migrate Away from System.Drawing to Enhance Cross-Platform Compatibility | Enhancement |
Public API and Backward Incompatible Changes
This section lists the public API changes introduced in GroupDocs.Redaction for .NET 26.6. It includes not only new and obsolete public methods but also descriptions of any behind-the-scenes changes in GroupDocs.Redaction that may affect existing code. Any modifications that could be considered regressions or alter existing behavior are particularly important and are documented here.
Public API changes
- Added
LoadOptions.FileTypeproperty. - Added
LoadOptions(FileType fileType)constructor. - Added drawing types in
GroupDocs.Redaction.Options.Drawingnamespace:Color,Point,Size,Rectangle,Font,FontStyle. - Added new overloads that accept
GroupDocs.Redaction.Options.Drawingtypes inReplacementOptions,RegionReplacementOptions,ImageAreaRedaction,PageAreaFilter,TextFragment, and related APIs. - Marked
ReplacementOptions.BoxColoras obsolete. UseReplacementOptions.BoxFillColorinstead. - Marked
ReplacementOptions(System.Drawing.Color)constructor as obsolete. UseReplacementOptions(GroupDocs.Redaction.Options.Drawing.Color)instead. - Marked
RegionReplacementOptions.FillColoras obsolete. UseRegionReplacementOptions.AreaFillColorinstead. - Marked
RegionReplacementOptions.Sizeas obsolete. UseRegionReplacementOptions.AreaSizeinstead. - Marked
RegionReplacementOptions(System.Drawing.Color, System.Drawing.Size)constructor as obsolete. UseRegionReplacementOptions(GroupDocs.Redaction.Options.Drawing.Color, GroupDocs.Redaction.Options.Drawing.Size)instead. - Marked
RegionReplacementOptions(System.Drawing.Color, System.Drawing.Font, string)constructor as obsolete. UseRegionReplacementOptions(GroupDocs.Redaction.Options.Drawing.Color, GroupDocs.Redaction.Options.Drawing.Font, string)instead. - Marked
ImageAreaRedaction.TopLeftas obsolete. UseImageAreaRedaction.TopLeftPositioninstead. - Marked
ImageAreaRedaction(System.Drawing.Point, RegionReplacementOptions)constructor as obsolete. UseImageAreaRedaction(GroupDocs.Redaction.Options.Drawing.Point, RegionReplacementOptions)instead. - Marked
PageAreaFilter.Rectangleas obsolete. UsePageAreaFilter.AreaRectangleinstead. - Marked
PageAreaFilter(System.Drawing.Point, System.Drawing.Size)constructor as obsolete. UsePageAreaFilter(GroupDocs.Redaction.Options.Drawing.Point, GroupDocs.Redaction.Options.Drawing.Size)instead. - Marked
TextFragment.Rectangleas obsolete. UseTextFragment.BoundingRectangleinstead. - Marked
TextFragment(string, System.Drawing.Rectangle)constructor as obsolete. UseTextFragment(string, GroupDocs.Redaction.Options.Drawing.Rectangle)instead. - Marked
IImageFormatInstance.EditArea(System.Drawing.Point, RegionReplacementOptions)as obsolete. UseIImageFormatInstance.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.