Efficiently protect and organize your Word documents with this comprehensive code example. The sample below empowers you to implement robust watermarking and metadata management within your contract workflow for enhanced security and information management. It demonstrates how to:
Apply a Custom Watermark: Add a prominent ‘Contract Draft’ watermark to the document for visual clarity and protection. Customize the watermark with font, color, opacity, and alignment options.
Enhance Metadata: Easily modify document metadata to include essential details like author, creation time, company, category, and keywords for improved organization and searchability.
C#
using GroupDocs.Metadata;
using GroupDocs.Watermark;
using GroupDocs.Watermark.Common;
using GroupDocs.Watermark.Watermarks;
// Load your document into watermarker
using (Watermarker watermarker = new Watermarker("contract.docx"))
{
// Set the desired text and font for the watermark
TextWatermark watermark = new TextWatermark("Contract Draft", new Font("Arial", 60, FontStyle.Bold));
// Choose font color and text opacity, rotation and alignments
watermark.ForegroundColor = Color.DarkGreen;
watermark.Opacity = 0.5;
watermark.HorizontalAlignment = HorizontalAlignment.Center;
watermark.VerticalAlignment = VerticalAlignment.Center;
// Apply the watermark
watermarker.Add(watermark);
// Save the resulting document
watermarker.Save("watermarked-contract.docx");
}
using (Metadata metadata = new Metadata("watermarked-contract.docx"))
{
var root = metadata.GetRootPackage<WordProcessingRootPackage>();
// Update document metadata properties
root.DocumentProperties.Author = "Name Surname";
root.DocumentProperties.CreatedTime = DateTime.Now;
root.DocumentProperties.Company = "Company Name";
root.DocumentProperties.Category = "Work materials";
root.DocumentProperties.Keywords = "contract, watermarked";
// Save document with updated metadata
metadata.Save("contract-final.docx");
}
Scenario: A large legal firm frequently processes diverse documents containing confidential client information that must be redacted before sharing with third-parties or for public disclosure. Manually redacting this sensitive information can be tedious, time-consuming, and prone to human error. To ensure efficiency, accuracy, and compliance with data protection regulations, the legal firm seeks an automated solution to streamline the document redaction process.
Solution:
GroupDocs.Total automates the process, triggering redaction upon receiving a document. Furthermore, flexible options empower customization by allowing you to set rules, choose redaction modes (e.g., blackout, replace with asterisks), and specify specific sections or pages for redaction. Finally, user-friendly output generates redacted documents in PDF format for easy sharing and review, while enhanced security and auditability ensure the entire process is documented for compliance and accountability.
This comprehensive solution empowers legal professionals and other organizations to significantly reduce redaction time and costs, minimize human error, and consistently handle sensitive information with confidence.
C#
using GroupDocs.Redaction;
using GroupDocs.Viewer;
using GroupDocs.Viewer.Options;
// Load document with private data into redactor
using (Redactor redactor = new Redactor("customer-info.docx"))
{
// Setup and customize redaction options
redactor.Apply(new ExactPhraseRedaction("John Smith", new ReplacementOptions("[personal]")));
// Apply redactions and save result
redactor.Save();
}
// Load redacted file for review
using (var viewer = new Viewer("customer-info.docx"))
{
// Setup PDF as desired viewing format
var viewOptions = new PdfViewOptions("redacted-info.pdf");
// Save document into PDF
viewer.View(viewOptions);
}