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.
Java
import com.groupdocs.metadata.Metadata;
import com.groupdocs.watermark.Watermark;
import com.groupdocs.watermark.Watermark.Common;
import com.groupdocs.watermark.Options.HtmlViewOptions;
// Load your document into watermarker
Watermarker watermarker = new Watermarker("contract.docx");
// Set the desired text and font for the watermark
TextWatermark watermark = new TextWatermark("Contract Draft", new Font("Arial", 36));
// Choose font color and text opacity, rotation and alignments
watermark.setForegroundColor(Color.getRed());
watermark.setHorizontalAlignment(HorizontalAlignment.Center);
watermark.setVerticalAlignment(VerticalAlignment.Center);
// Apply the watermark
watermarker.add(watermark);
// Save the resulting document
watermarker.save("watermarked-contract.docx");
Metadata metadata = new Metadata("watermarked-contract.docx");
WordProcessingRootPackage root = metadata.getRootPackageGeneric();
// Update document metadata properties
root.getDocumentProperties().setAuthor("Name Surname");
root.getDocumentProperties().setCreatedTime(new Date());
root.getDocumentProperties().setCompany("Company Name");
root.getDocumentProperties().setCategory("Work materials");
root.getDocumentProperties().setKeywords("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.
Java
import com.groupdocs.redaction.Redaction;
import com.groupdocs.viewer.Viewer;
import com.groupdocs.viewer.options.HtmlViewOptions;
// Load document with private data into redactor
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
Viewer viewer = new Viewer("customer-info.docx");
// Setup PDF as desired viewing format
PdfViewOptions viewOptions = new PdfViewOptions("redacted-info.pdf");
// Save document into PDF
viewer.view(viewOptions);