Related Article(s):
Last active
August 29, 2023 15:27
-
-
Save GroupDocsGists/d89ff02dc1b020a13eac8a375f16e86e to your computer and use it in GitHub Desktop.
Add Watermarks to Word Documents using C# | Text and Image Watermarks
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Add Watermark Image to specific page(s) of Word document using C# | |
using (Watermarker watermarker = new Watermarker("path/multipage-document.docx")) | |
{ | |
ImageWatermark watermark = new ImageWatermark("path/image.png") | |
{ | |
Opacity = .5, | |
HorizontalAlignment = HorizontalAlignment.Center, | |
VerticalAlignment = VerticalAlignment.Center | |
}; | |
WordProcessingWatermarkPagesOptions options = new WordProcessingWatermarkPagesOptions(); | |
options.PageNumbers = new int[] { 1 }; | |
watermarker.Add(watermark, options); | |
watermarker.Save("path/first-page-watermark.docx"); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Add Watermark Text to page(s) of Word file using C# | |
using (Watermarker watermarker = new Watermarker("path/document.docx")) | |
{ | |
TextWatermark watermark = new TextWatermark("Watermark", new Font("Arial", 80)) | |
{ | |
RotateAngle = -45, | |
Opacity = .3, | |
ForegroundColor = Color.DarkBlue, | |
HorizontalAlignment = HorizontalAlignment.Center, | |
VerticalAlignment = VerticalAlignment.Center | |
}; | |
watermarker.Add(watermark); | |
watermarker.Save("path/watermarked.docx"); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment