Related blog post: Watermark Password Protected Documents using C#
Last active
December 26, 2021 09:35
-
-
Save GroupDocsGists/02f763046a5c3b45f722e88c0ead9029 to your computer and use it in GitHub Desktop.
Add Watermark to PDF, Word, PPT, Excel Documents using C#
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
/* | |
* Apply Image Watermark to document (PDF, Word, PPT, Excel, ...) using C# | |
*/ | |
LoadOptions loadOptions = new LoadOptions(); | |
loadOptions.Password = "P@$$w0rd"; | |
string filePath = "path/document.docx"; | |
using (Watermarker watermarker = new Watermarker(filePath, loadOptions)) | |
{ | |
// Prepare Watermark Text and appearance. | |
ImageWatermark watermark = new ImageWatermark("watermark-logo.png") | |
{ | |
Opacity = 0.7, | |
X = 70, | |
Y = 350 | |
}; | |
// Add image watermark to document and save. | |
watermarker.Add(watermark); | |
watermarker.Save("path/watermark-document.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
/* | |
* Apply Text Watermark to document (PDF, Word, PPT, Excel, ...) using C# | |
*/ | |
LoadOptions loadOptions = new LoadOptions(); | |
loadOptions.Password = "P@$$w0rd"; | |
string filePath = "path/document.pdf"; | |
using (Watermarker watermarker = new Watermarker(filePath, loadOptions)) | |
{ | |
// Prepare Watermark Text and appearance. | |
TextWatermark watermark = new TextWatermark("Watermark", new Font("Arial", 12)) | |
{ | |
RotateAngle = -45, | |
Opacity = .3, | |
ForegroundColor = Color.Red, | |
}; | |
// Add watermark to document and save. | |
watermarker.Add(watermark); | |
watermarker.Save("path/watermark-document.pdf"); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment