Skip to content

groupdocs-watermark/protect-word-documents-using-groupdocs-watermark-dotnet

Repository files navigation

πŸ›‘οΈ 5 Secure Methods to Add Watermarks to Word Documents

Product Page Docs Blog Free Support Temporary License

πŸ“– About This Repository

This repository demonstrates practical implementations of GroupDocs.Watermark for .NET, a tool for protecting Microsoft Word documents using various watermarking techniques.

The examples show how to: - Add simple and tiled text watermarks

  • Lock headers and specific document sections with passwords
  • Use editable content ranges to balance protection and usability
  • Combine Word editing restrictions with GroupDocs.Watermark APIs

These implementations are designed for developers who want to move beyond Microsoft Word's basic watermark feature and use professional .NET routines for document protection.

πŸ’‘ The Challenge

What is GroupDocs.Watermark?

GroupDocs.Watermark for .NET is a powerful document watermarking API that allows developers to protect, brand, and secure Word, PDF, Excel, PowerPoint, and over 40 other file formats programmatically.

Key capabilities: - Add, search, and remove watermarks of any type

  • Lock watermarks with password protection
  • Protect against unauthorized removal
  • Automate watermarking for large-scale document processing
  • Works without Microsoft Office --- pure .NET implementation

It's ideal for legal contracts, confidential reports, and branded client documents.

βš™οΈ Pre-requirements

To protect Word documents effectively, you can use one or more of the following methods:

  1. Header watermark -- Simple watermark added to the document header. Easy to implement, but can be manually removed.
  2. Tiled watermark -- Multiple repeated text instances across the page, making removal tedious.
  3. Password-protected section -- Watermark placed in a locked section, editable only with a password.
  4. Locked header + editable ranges -- Header area (with watermark) locked for editing, while selected body areas remain editable.
  5. Full document restriction -- Document locked using WordProcessingLockType with read-only or form-field access.

These methods are fully demonstrated in the included code examples. Each approach builds upon the previous one, offering increasing levels of security.

πŸ“‚ Repository Structure

Protect-Word-Documents-using-GroupDocs.Watermark-for-.NET/
β”‚
β”œβ”€β”€ GroupDocs.Watermark-for-.NET-Word-Protection-Sample.csproj  # .NET 6 project file
β”œβ”€β”€ Program.cs                                                  # Entry point: runs protection routines
β”‚   β”œβ”€β”€ AddSimpleHeaderWatermark                                # Basic watermark in header
β”‚   β”œβ”€β”€ AddTiledWatermark                                       # Repeated tiled watermark
β”‚   β”œβ”€β”€ AddTiledImageWatermark                                  # Repeated tiled image watermark
β”‚   β”œβ”€β”€ AddLockedSectionWatermark                               # Password-protected hidden section
β”‚   └── AddLockedHeaderWatermark                                # Locked header + editable content
β”œβ”€β”€ Resources/                                                  # Input/output test files
|                                                                   (create this folder where you need)
└── README.md                                                   # This documentation

How to protect a Word document with tiled image watermark

Protection Level: Medium-High | Difficulty: Easy | Best for: Brand protection, copyright claims, and professional documents

Image watermarks take protection to the next level by using your company logo, signature, or custom graphics instead of plain text. When tiled across the document, they create a professional security layer that's harder to replicate or forge than simple text watermarks.

        private static void AddTiledImageWatermark(string imageWatermarkFilePath)
        {        
            using (Watermarker watermarker = new Watermarker(InputFile))
            {
                // Create the image watermark object
                var watermark = new ImageWatermark(imageWatermarkFilePath);

                // Configure tile options
                watermark.TileOptions = new TileOptions()
                {
                    LineSpacing = new MeasureValue()
                    {
                        MeasureType = TileMeasureType.Percent,
                        Value = 10
                    },
                    WatermarkSpacing = new MeasureValue()
                    {
                        MeasureType = TileMeasureType.Percent,
                        Value = 8
                    },
                };

                // Set watermark properties
                watermark.Opacity = 0.7;
                watermark.RotateAngle = -30;

                // Add watermark
                watermarker.Add(watermark);
                watermarker.Save(Path.Combine(OutputDir, "image_tiled_watermark.docx"));
            }
        } 

See the professional image watermark in action:

action

Advanced protection: Locked Header with Editable Content Ranges

Protection Level: Very High | Difficulty: Medium | Best for: Documents requiring both security and user interaction

This sophisticated approach combines locked headers with Microsoft Word's editable ranges feature. The watermark sits in a password-protected header that's completely locked, while specific document areas remain editable for legitimate users.

How it works: The entire header section (containing your watermark) is locked with read-only protection. The document body is then marked with editable ranges, creating a security model where users can only modify pre-approved sections.

        private static void AddLockedHeaderWatermark()
        {
            Console.WriteLine("Adding locked header watermark...");

            var loadOptions = new WordProcessingLoadOptions();
            using (var watermarker = new Watermarker(InputFile, loadOptions))
            {
                var watermark = new TextWatermark("GroupDocs Watermark", new Font("Arial", 19))
                {
                    VerticalAlignment = VerticalAlignment.Center,
                    HorizontalAlignment = HorizontalAlignment.Center,
                    RotateAngle = 25,
                    Opacity = 0.8
                };

                var options = new WordProcessingWatermarkSectionOptions
                {
                    SectionIndex = 0,
                    IsLocked = true,
                    Password = "012345",
                    LockType = WordProcessingLockType.ReadOnly
                };

                watermarker.Add(watermark, options);
                watermarker.Save(Path.Combine(OutputDir, "locked_header_watermark.docx"));
            }

            Console.WriteLine("Locked header watermark added.");
        }

Watch the locked header protection:

action

Related Topics to Explore

If you’re working with document protection or watermarking, the following articles may be helpful:

  • 5 Secure Methods to Add Watermarks to Word Documents – Discover different ways to apply watermarks safely and effectively using GroupDocs.Watermark: Read the article β†’

  • AI-Powered Watermarking: Protect Documents with Smart, Context-Aware Marking – Learn how to integrate GroupDocs.Watermark into your AI agent to generate intelligent, adaptive watermarks: Read the article β†’

  • Python Tiling Watermark Examples: How to Create Repeated Watermarks in Documents – Explore how to apply various tiling watermark patterns using GroupDocs.Watermark for Python: Read the article β†’

πŸ’¬ This repository is part of GroupDocs educational samples. All names and data are automatically generated for demonstration purposes only.

🏷️ Keywords

add watermark to Word Β· Word document security Β· protect Word documents Β· C# watermark code Β· .NET watermark library Β· remove watermark protection Β· locked watermarks Β· password-protected watermarks Β· document protection API Β· GroupDocs.Watermark examples Β· tiled watermarks Β· secure Word documents Β· watermark removal prevention Β· Word DOCX watermark Β· enterprise document security Β· watermark automation Β· programmatic watermarking Β· image watermark Word Β· logo watermark documents Β· watermark API .NET Β· prevent watermark deletion Β· Word document locking Β· confidential document watermark Β· legal document protection Β· batch watermark documents Β· DOCX protection methods

Product Page Docs Blog Free Support Temporary License

About

5 production-ready methods to add password-protected, removal-resistant watermarks to Word documents using C# and GroupDocs.Watermark for .NET. Includes tiled, locked, and image watermarking examples.

Resources

Stars

Watchers

Forks

Contributors

Languages