GroupDocs.Redaction for .NET 26.6 is now available. This release makes it easier to open documents from streams and files with an explicit format, and introduces a new drawing API that is independent of System.Drawing to improve cross-platform compatibility.
Fixes and enhancements
- [Enhancement] Specify file type when opening a document from a stream or file path. (REDACTIONNET-572)
- [Enhancement] Migrate away from
System.Drawingto enhance cross-platform compatibility. (REDACTIONNET-799)
What’s New?
This release focuses on two areas that simplify integration and prepare the API for broader platform support.
Specify document format with LoadOptions.FileType
When you open a document, GroupDocs.Redaction normally detects its format automatically. That works well for files with a correct extension, but it can fail for streams without a file name or when the extension does not match the actual content.
Version 26.6 adds the LoadOptions.FileType property and a LoadOptions(FileType) constructor. Set FileType to a supported constant such as FileType.DOCX or FileType.PDF, and the library opens the document using that format without running binary format detection. The default behavior is unchanged when FileType is not specified or remains FileType.Unknown.
Cross-platform drawing types in GroupDocs.Redaction.Options.Drawing
Several redaction options previously relied on System.Drawing types (Color, Point, Size, Rectangle, Font). These types are not available on all platforms and can complicate deployment on Linux and in containerized environments.
The new GroupDocs.Redaction.Options.Drawing namespace provides Color, Point, Size, Rectangle, Font, and FontStyle types for use in public API. New overloads accept these types in ReplacementOptions, RegionReplacementOptions, ImageAreaRedaction, PageAreaFilter, TextFragment, and related classes.
Existing code that uses System.Drawing continues to compile and run. The corresponding members are marked obsolete and should be migrated to the new types in future updates.
Public API changes
Added
LoadOptions.FileTypepropertyLoadOptions(FileType fileType)constructor- Drawing types in
GroupDocs.Redaction.Options.Drawing:Color,Point,Size,Rectangle,Font,FontStyle - New overloads that accept
GroupDocs.Redaction.Options.Drawingtypes
Obsolete
ReplacementOptions.BoxColor— useReplacementOptions.BoxFillColorinsteadReplacementOptions(System.Drawing.Color)— useReplacementOptions(GroupDocs.Redaction.Options.Drawing.Color)insteadRegionReplacementOptions.FillColor— useRegionReplacementOptions.AreaFillColorinsteadRegionReplacementOptions.Size— useRegionReplacementOptions.AreaSizeinsteadRegionReplacementOptions(System.Drawing.Color, System.Drawing.Size)— use the overload withGroupDocs.Redaction.Options.Drawing.ColorandGroupDocs.Redaction.Options.Drawing.SizeinsteadRegionReplacementOptions(System.Drawing.Color, System.Drawing.Font, string)— use the overload withGroupDocs.Redaction.Options.Drawing.ColorandGroupDocs.Redaction.Options.Drawing.FontinsteadImageAreaRedaction.TopLeft— useImageAreaRedaction.TopLeftPositioninsteadImageAreaRedaction(System.Drawing.Point, RegionReplacementOptions)— use the overload withGroupDocs.Redaction.Options.Drawing.PointinsteadPageAreaFilter.Rectangle— usePageAreaFilter.AreaRectangleinsteadPageAreaFilter(System.Drawing.Point, System.Drawing.Size)— use the overload withGroupDocs.Redaction.Options.Drawing.PointandGroupDocs.Redaction.Options.Drawing.SizeinsteadTextFragment.Rectangle— useTextFragment.BoundingRectangleinsteadTextFragment(string, System.Drawing.Rectangle)— useTextFragment(string, GroupDocs.Redaction.Options.Drawing.Rectangle)insteadIImageFormatInstance.EditArea(System.Drawing.Point, RegionReplacementOptions)— use the overload withGroupDocs.Redaction.Options.Drawing.Pointinstead
Code examples
Open a document with an explicit file type
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
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();
}
How to get the update
- NuGet – Upgrade to the latest
GroupDocs.Redaction for .NETpackage via NuGet - Direct Download – Download GroupDocs.Redaction assemblies from the GroupDocs.Redaction for .NET 26.6 page
Learn more
- Full Release Notes
- Documentation
- Load document with explicit file type
- GroupDocs.Redaction Free Support Forum