Hi,
I’d like to insert content control and choose a formatting style for the content.
After inserting the value of content, I’d like to have my formatting style preserved.
Right now I do something like:
for (StructuredDocumentTag sdt : (Iterable) doc
.getChildNodes(NodeType.STRUCTURED_DOCUMENT_TAG, true)) {
if (sdt.getSdtType() == SdtType.PLAIN_TEXT
|| sdt.getSdtType() == SdtType.RICH_TEXT) {
String value = nomeVariabili.get(sdt.getTag());
if (value != null) {
sdt.removeAllChildren();
if (sdt.getLevel() == MarkupLevel.BLOCK) {
Paragraph para = (Paragraph) sdt
.appendChild(new Paragraph(doc));
Run run = new Run(doc, value);
para.appendChild(run);
} else if (sdt.getLevel() == MarkupLevel.INLINE) {
sdt.appendChild(new Run(doc, value));
}
}
}
}
I also tried to clone the first child of the sdt, before removing all children and paste it with my updated content, without the expected result.
Thank you for your help.