The link on the homepage (https://www.docx4java.org/trac/docx4j) for the addin leads to this page: https://www.docx4java.org/blog/2014/12/ ... ord-addin/.
But the “download the installer” link there doesn’t work.
TextMetaItem tmi1 = arr[replaceCommand.getFoundResult().getStart()];
TextMetaItem tmi2 = arr[replaceCommand.getFoundResult().getEnd()];
ObjectFactory factory = Context.getWmlObjectFactory();
Br br = factory.createBr();
// do replacement inside a single Text-object
String t1 = tmi1.getText().getValue();
LOGGER.debug("tmi1.getText().getValue() :" + tmi1.getText().getValue());
int beginIndex = tmi1.getPositionInsideTextObject(replaceCommand.getFoundResult().getStart());
int endIndex = tmi2.getPositionInsideTextObject(replaceCommand.getFoundResult().getEnd());
String keepBefore = t1.substring(0, beginIndex);
String keepAfter = t1.substring(endIndex + 1);
tmi1.getText().setValue(keepBefore + replaceCommand.getNewValue() + keepAfter);
Users browsing this forum: Google [Bot] and 54 guests