Skip to content

Instantly share code, notes, and snippets.

@GroupDocsGists
Last active May 22, 2024 21:15
Show Gist options
  • Save GroupDocsGists/721f5c545848637db15ba69a97d6393f to your computer and use it in GitHub Desktop.
Save GroupDocsGists/721f5c545848637db15ba69a97d6393f to your computer and use it in GitHub Desktop.
How To Add Text Watermark to a Document in Node.js solutions
// require the GroupDocs.Watermark module
const groupdocsWatermark = require('@groupdocs/groupdocs.watermark')
// Initialize the Watermarker class
const watermarker = new groupdocsWatermark.Watermarker(inDocumentPath);
// Create a Text Watermark
const watermark = new groupdocsWatermark.TextWatermark('top secret', new groupdocsWatermark.Font('Arial', 36));
// Set Watermark Properties
watermark.setForegroundColor(groupdocsWatermark.Color.getRed());
watermark.setHorizontalAlignment(groupdocsWatermark.HorizontalAlignment.Center);
watermark.setVerticalAlignment(groupdocsWatermark.VerticalAlignment.Center);
// Add the Watermark to the Document
watermarker.add(watermark);
// Save the Watermarked Document
watermarker.save(outDocumentPath);
// Close the Watermarker
watermarker.close();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment