Class VariablePrepare
java.lang.Object
org.docx4j.model.datastorage.migration.VariablePrepare
public class VariablePrepare
extends java.lang.Object
There are at least 3 approaches for replacing variables in
a docx.
1. text replacement on the document surface.
2. using Merge Fields (see org.docx4j.model.fields.merge.MailMerger)
3. binding content controls to an XML Part (via XPath)
Approach 3 is the recommended one when using docx4j. See the
ContentControl* examples, Getting Started, and the subforum.
Approach 1, works in simple cases only.
It won't work if your KEY is split across separate
runs in your docx (which often happens), or if you want
to insert images, or multiple rows in a table.
This class tidies up your document, so your keys should
not be split across separate runs.
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classVariablePrepare.TraversalUtilParagraphVisitor -
Field Summary
Fields Modifier and Type Field Description static intFLAG_NONEstatic intFLAG_REMOVE_BOOKMARKSstatic intFLAG_REMOVE_CONTENT_CONTROLSstatic intFLAG_REMOVE_PROOF_ERRORSstatic intFLAG_REMOVE_RSIDS -
Constructor Summary
Constructors Constructor Description VariablePrepare() -
Method Summary
Modifier and Type Method Description static voidjoinupRuns(P p)static voidprepare(WordprocessingMLPackage wmlPackage)static voidprepare(WordprocessingMLPackage wmlPackage, int flags)
-
Field Details
-
FLAG_NONE
public static final int FLAG_NONE- See Also:
- Constant Field Values
-
FLAG_REMOVE_PROOF_ERRORS
public static final int FLAG_REMOVE_PROOF_ERRORS- See Also:
- Constant Field Values
-
FLAG_REMOVE_CONTENT_CONTROLS
public static final int FLAG_REMOVE_CONTENT_CONTROLS- See Also:
- Constant Field Values
-
FLAG_REMOVE_RSIDS
public static final int FLAG_REMOVE_RSIDS- See Also:
- Constant Field Values
-
FLAG_REMOVE_BOOKMARKS
public static final int FLAG_REMOVE_BOOKMARKS- See Also:
- Constant Field Values
-
-
Constructor Details
-
VariablePrepare
public VariablePrepare()
-
-
Method Details
-
prepare
- Parameters:
wmlPackage-- Throws:
java.lang.Exception
-
prepare
public static void prepare(WordprocessingMLPackage wmlPackage, int flags) throws java.lang.Exception- Parameters:
wmlPackage-- Throws:
java.lang.Exception- Since:
- 8.1.0
-
joinupRuns
-