I am using Docx4J library to merge xml data into a docx file and get a new docx file with all the data present in the xml file. It is working really well. But when I do not have data in a particular xml element; I get "Click here to enter text." in that particular content container. Is there a way I could delete that content container if there is not data for that from the XML file I supply.
example xml used in docx template:
- Code: Select all
<myxml>
<firstline>data in first line</firstline>
<secondline>data in second line</secondline>
<thirdline>data in third line</thirdline>
</myxml>
example xml used to merge with docx and get a new docx:
- Code: Select all
<myxml>
<firstline>data in first line</firstline>
<secondline>data in second line</secondline>
<thirdline></thirdline>
</myxml>
As you can see above that the xml provided to merge with the docx template has no data for the <thirdline> element. when the same is merged the output docx file; it has "Click here to enter text." at the place where data of <thirdline> is supposed to be present. Is there a way to remove that particular content control from the docx or prevent Docx4J from printing "Click here to enter text." at a place where the xml element has no data for that particular content control.