Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
GroupDocs.Watermark for Java 18.6
// For complete examples and data files, please go to https://github.com/groupdocs-watermark/GroupDocs.Watermark-for-Java
WordsDocument doc = Document.load(WordsDocument.class, Common.mapSourceFilePath(FILE_PATH));
TextWatermark watermark = new TextWatermark("Watermark text", new Font("Arial", 19));
watermark.setForegroundColor(Color.getRed());
// Set WordsShapeSettings
WordsShapeSettings settings = new WordsShapeSettings();
settings.setLocked(true);
settings.setLockType(WordsLockType.AllowOnlyFormFields);
settings.setPassword("7654321");
// Add watermark
doc.addWatermark(watermark, settings);
// Save document
doc.save(Common.mapOutputFilePath(FILE_PATH));
doc.close();
// For complete examples and data files, please go to https://github.com/groupdocs-watermark/GroupDocs.Watermark-for-Java
WordsDocument doc = Document.load(WordsDocument.class, Common.mapSourceFilePath(FILE_PATH));
TextWatermark watermark = new TextWatermark("Watermark text", new Font("Arial", 19));
watermark.setForegroundColor(Color.getRed());
// Set WordsShapeSettings
WordsShapeSettings settings = new WordsShapeSettings();
settings.setPageNumbers(new int[] { 1, 3 });
settings.setLocked(true);
settings.setLockType(WordsLockType.AllowOnlyComments);
settings.setPassword("7654321");
// Add watermark
doc.addWatermark(watermark, settings);
// Save document
doc.save(Common.mapOutputFilePath(FILE_PATH));
doc.close();
// For complete examples and data files, please go to https://github.com/groupdocs-watermark/GroupDocs.Watermark-for-Java
WordsDocument doc = Document.load(WordsDocument.class, Common.mapSourceFilePath(FILE_PATH));
TextWatermark watermark = new TextWatermark("Watermark text", new Font("Arial", 19));
watermark.setForegroundColor(Color.getRed());
// Set WordsShapeSettings
WordsShapeSettings settings = new WordsShapeSettings();
settings.setLocked(true);
settings.setLockType(WordsLockType.ReadOnlyWithEditableContent);
settings.setPassword("7654321");
// Add watermark
doc.getSections().get_Item(0).addWatermark(watermark, settings);
// Save document
doc.save(Common.mapOutputFilePath(FILE_PATH));
doc.close();
// For complete examples and data files, please go to https://github.com/groupdocs-watermark/GroupDocs.Watermark-for-Java
WordsDocument doc = Document.load(WordsDocument.class, Common.mapSourceFilePath(FILE_PATH));
doc.protect(WordsProtectionType.ReadOnly, "7654321");
// Save document
doc.save(Common.mapOutputFilePath(FILE_PATH));
doc.close();
// For complete examples and data files, please go to https://github.com/groupdocs-watermark/GroupDocs.Watermark-for-Java
WordsDocument doc = Document.load(WordsDocument.class, Common.mapSourceFilePath(FILE_PATH));
doc.unprotect();
// Save document
doc.save(Common.mapOutputFilePath(FILE_PATH));
doc.close();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.