Interface ICommentProcessor
- All Superinterfaces:
CommentProcessor
In a .docx template used by DocxStamper, you can comment paragraphs of text to manipulate them. The comments in the .docx template are passed to an implementation of ICommentProcessor that understands the expression used within the comment. Thus, you can implement your own ICommentProcessor to extend the expression language available in comments in the .docx template.
To implement a comment processor, you have to do the following steps:
- Create an interface that defines the custom method(s) you want to expose to the expression language used in .docx comments
- Create an implementation of your interface
- Register your comment processor with DocxStamper
1. Creating a comment processor interface
For example, if you want to create a comment processor that
makes a paragraph of text bold based on some condition, you would create an interface with the method
boldIf(boolean condition).
2. Creating an implementation of your interface
Your implementation class must also implement the Interface
ICommentProcessor. To stay in the above example, when the boldIf method is called, simply keep track of the paragraphs that are to be made bold.
The currently processed paragraph is passed into the method setCurrentParagraph() before your own method
(in this case boldIf()) is called.
Within the method commitChanges() you then do the manipulations on the word document, i.e. make the paragraphs
that were commented bold.
3. Registering you comment processor with DocxStamper
Register your comment processor in DocxStamper by calling DocxStamperConfiguration#addCommentProcessor().
- Since:
- 1.0.0
- Version:
- ${version}
- Author:
- Joseph Verron, Tom Hombergs
-
Method Summary
Methods inherited from interface pro.verron.officestamper.api.CommentProcessor
commitChanges, reset, setCurrentCommentWrapper, setCurrentRun, setDocument, setParagraph
CommentProcessorclass instead. This class will not be exported in the future releases of the module.