Removing content from docx model
Posted:
Thu Nov 21, 2013 3:34 am
by adilturbo
Dear beautifull mind,
I have a docx document model, i want to generate new document from it, but i'm blocked to remove :
1- some lines from an existing table
2- a sub column (not all column).
3- an image
I don't know if the library is able to do that. if there is a route, please give me some hints.
Thanks in advance
Re: Removing content from docx model
Posted:
Thu Nov 21, 2013 8:35 am
by jason
You can use the OpenDoPE approach to wrap these things in conditional content controls, in which case docx4j will remove them for you if the condition evaluates to false.
Or you can implement your own logic to find the thing you want to remove, and then manually remove it from the Java list which contains it. See Getting Started for more details.
Re: Removing content from docx model
Posted:
Thu Nov 21, 2013 10:58 pm
by adilturbo
Thanks jason.
According to your experience what is the easiest and sure way to choose? can you please provide some guiding code or objects that may help me fulfill the task.
Special thanks
Re: Removing content from docx model
Posted:
Fri Nov 22, 2013 7:27 am
by jason
OpenDoPE content control data binding.
1. Read the spec at opendope.org, then browse posts in this forum.
2. Experiment with the samples docx at
https://github.com/plutext/docx4j/tree/ ... atabindingand the sample code named ContentControl* at
https://github.com/plutext/docx4j/tree/ ... 4j/samples3. Install the Word Add-In to author an OpenDoPE template, then apply the sample code in step 2 to your own template