T
- the class of the context object used to resolve expressions against.public class DocxStamper<T> extends Object
Main class of the docx-stamper library. This class can be used to "stamp" .docx templates to create a .docx document filled with custom data at runtime.
Constructor and Description |
---|
DocxStamper()
|
Modifier and Type | Method and Description |
---|---|
CommentProcessorRegistry
|
getCommentProcessorRegistry()
Returns the registry in which all ICommentProcessors are
registeres.
|
TypeResolverRegistry
|
getTypeResolverRegistry()
Returns the registry in which all ITypeResolvers are registered.
|
void |
stamp(InputStream template,
T contextRoot,
OutputStream out)
Reads in a .docx template and "stamps" it into the given OutputStream, using the
specified context object to
fill out any expressions it finds.
|
void |
stamp(org.docx4j.openpackaging.packages.WordprocessingMLPackage document,
T contextRoot,
OutputStream out)
Same as stamp(InputStream, T, OutputStream) except that you may pass
in a DOCX4J document as a template instead
of an InputStream.
|
public void stamp(InputStream template, T contextRoot, OutputStream out) throws DocxStamperException
Reads in a .docx template and "stamps" it into the given OutputStream, using the specified context object to fill out any expressions it finds.
In the .docx template you have the following options to influence the "stamping" process:
Within comments, you can put expressions in which you can use the following methods by default:
If you need a wider vocabulary of methods available in the comments, you can create your own ICommentProcessor and register it via getCommentProcessorRegistry().registerCommentProcessor().
template
- the .docx template.contextRoot
- the context root object against which all expressions
found in the template are evaluated.
out
- the output stream in which to write the resulting .docx document.
DocxStamperException
- in case of an error.
public void stamp(org.docx4j.openpackaging.packages.WordprocessingMLPackage document, T contextRoot, OutputStream out) throws DocxStamperException
document
- the .docx template.contextRoot
- the context root object against which all expressions
found in the template are evaluated.
out
- the output stream in which to write the resulting .docx document.
DocxStamperException
- in case of an error.
public TypeResolverRegistry getTypeResolverRegistry()
public CommentProcessorRegistry getCommentProcessorRegistry()
Copyright © 2016. All rights reserved.