WordProcessingContent
Inheritance: java.lang.Object, com.groupdocs.watermark.contents.ContentPart, com.groupdocs.watermark.contents.Content
All Implemented Interfaces: com.groupdocs.watermark.internal.IEncryptable
public class WordProcessingContent extends Content implements IEncryptable
Class representing Word document (doc, docx etc) where watermark should be placed.
Learn more:
- Add watermarks to word processing documents
- Existing objects in word processing document
- Locking watermark in word processing document
- Protecting word processing documents
- Watermarks in word processing document
The following example demonstrates how to load and save Word document of any supported type.
WordProcessingLoadOptions loadOptions = new WordProcessingLoadOptions(); Watermarker watermarker = new Watermarker(“D:\input.doc”, loadOptions);
// Use add method to add watermark to a particular or all sections.
// Save changes. watermarker.save(“D:\output.doc”); watermarker.close();
Constructors
Methods
WordProcessingContent(StreamContainer stream, IStrategyManager strategyManager, FileFormatInfo fileFormatInfo, WordProcessingLoadOptions wordProcessingLoadOptions, WatermarkerSettings watermarkerSettings)
public WordProcessingContent(StreamContainer stream, IStrategyManager strategyManager, FileFormatInfo fileFormatInfo, WordProcessingLoadOptions wordProcessingLoadOptions, WatermarkerSettings watermarkerSettings)
Parameters:
Parameter | Type | Description |
---|---|---|
stream | StreamContainer | |
strategyManager | IStrategyManager | |
fileFormatInfo | com.aspose.words.FileFormatInfo | |
wordProcessingLoadOptions | WordProcessingLoadOptions | |
watermarkerSettings | WatermarkerSettings |
getSections()
public final WordProcessingSectionCollection getSections()
Gets the collection of all sections of this [WordProcessingContent](../../com.groupdocs.watermark.contents/wordprocessingcontent)
.
Returns:
WordProcessingSectionCollection - The collection of all sections of this [WordProcessingContent](../../com.groupdocs.watermark.contents/wordprocessingcontent)
.
setSections(WordProcessingSectionCollection value)
public final void setSections(WordProcessingSectionCollection value)
Parameters:
Parameter | Type | Description |
---|---|---|
value | WordProcessingSectionCollection |
getPageCount()
public final int getPageCount()
Gets the number of pages in the document.
Returns: int - The number of pages in the document.
getAsposeWordsDocument()
public final Document getAsposeWordsDocument()
Returns: com.aspose.words.Document
encrypt(String password)
public final void encrypt(String password)
Encrypts the document.
Parameters:
Parameter | Type | Description |
---|---|---|
password | java.lang.String | The password that will be required to open the document. |
decrypt()
public final void decrypt()
Decrypts the document.
addWatermark(Watermark watermark, int pageNumber)
public final void addWatermark(Watermark watermark, int pageNumber)
Parameters:
Parameter | Type | Description |
---|---|---|
watermark | Watermark | |
pageNumber | int |
addWatermark(Watermark watermark, IWordProcessingWatermarkEffects effects, WordProcessingShapeSettings shapeSettings)
public final void addWatermark(Watermark watermark, IWordProcessingWatermarkEffects effects, WordProcessingShapeSettings shapeSettings)
Parameters:
Parameter | Type | Description |
---|---|---|
watermark | Watermark | |
effects | IWordProcessingWatermarkEffects | |
shapeSettings | WordProcessingShapeSettings |
protect(int protectionType, String password)
public final void protect(int protectionType, String password)
Protects the document from changes and sets a protection password.
To have the content of the document editable use appropriate method of adding watermark with [WordProcessingLockType.AllowOnlyFormFields](../../com.groupdocs.watermark.options/wordprocessinglocktype#AllowOnlyFormFields)
or [WordProcessingLockType.ReadOnlyWithEditableContent](../../com.groupdocs.watermark.options/wordprocessinglocktype#ReadOnlyWithEditableContent)
parameter.
Parameters:
Parameter | Type | Description |
---|---|---|
protectionType | int | The protection type for the document. |
password | java.lang.String | The password to protect the document with. |
unprotect()
public final void unprotect()
Removes protection from the document regardless of the password.
performSave(String filePath)
public void performSave(String filePath)
Parameters:
Parameter | Type | Description |
---|---|---|
filePath | java.lang.String |
performSave(String filePath, SaveOptions saveOptions)
public void performSave(String filePath, SaveOptions saveOptions)
Parameters:
Parameter | Type | Description |
---|---|---|
filePath | java.lang.String | |
saveOptions | SaveOptions |
performSave(OutputStream stream)
public void performSave(OutputStream stream)
Parameters:
Parameter | Type | Description |
---|---|---|
stream | java.io.OutputStream |
performSave(OutputStream stream, SaveOptions saveOptions)
public void performSave(OutputStream stream, SaveOptions saveOptions)
Parameters:
Parameter | Type | Description |
---|---|---|
stream | java.io.OutputStream | |
saveOptions | SaveOptions |
add(Watermark watermark, WatermarkOptions options)
public void add(Watermark watermark, WatermarkOptions options)
Parameters:
Parameter | Type | Description |
---|---|---|
watermark | Watermark | |
options | WatermarkOptions |
generatePreview(PreviewOptions previewOptions)
public void generatePreview(PreviewOptions previewOptions)
Parameters:
Parameter | Type | Description |
---|---|---|
previewOptions | PreviewOptions |
getDocumentInfo()
public IDocumentInfo getDocumentInfo()
Returns: IDocumentInfo
getFileType()
public FileType getFileType()
Returns: FileType
addWatermark(Watermark watermark)
public void addWatermark(Watermark watermark)
Parameters:
Parameter | Type | Description |
---|---|---|
watermark | Watermark |