I'm new to the docx4j world and this is my first post!
I'm building a small java program to test all the "document related" features i need to cover to fulfill my project requirements. That is, being able to create templates with "content controls" that will offer as raw template to the users. Let the user enhance them, to finally populate them with data. I'm dealing with "docx4j" because of the "repeating and conditional" features.
This has been my progress:
I want to, programmatically:
1) Create a blank document (DONE)
2) Add a custom xml part with the xml data (the part3.xml in the invoice example). (DONE)
3) Add a custom xml part with the xml xpaths reference (the part4.xml in the invoice example). (DONE)
4) Add the content control <w:sdt> (PENDING)
Something similar to this extract from the invoice example:
- Code: Select all
<w:sdt>
<w:sdtPr>
<w:alias w:val="Customer name" />
<w:tag w:val="od:xpath=x1&customer name=customer name" />
<w:id w:val="1418037941" />
<w:placeholder>
<w:docPart w:val="DefaultPlaceholder_22675703" />
</w:placeholder>
<w:dataBinding w:xpath="/invoice[1]/customer[1]/name[1]" w:storeItemID="{8B049945-9DFE-4726-9DE9-CF5691E53858}" />
<w:text />
</w:sdtPr>
<w:sdtContent>
<w:p>
<w:r>
<w:t>Joe Bloggs</w:t>
</w:r>
</w:p>
</w:sdtContent>
</w:sdt>
And here is my question: How to generate this xml ? Can be done by Java code or only from Word? What are and how are generated the "1418037941" and the "DefaultPlaceholder_22675703" values? I guess i cannot "invent" them, and are referenced somewhere else.
I was looking for some method in MainDocumentPart class to do so but was unable to find it.
Am i misunderstandig something?
The other steps are almost ok:
5) Perform "preprocess" (DONE)
6) Perform "process" (DONE)
7) Perform "strip" (DONE, except removing repat tags)
Thank you very much for your help!
David