Reputation: 11
I am using 'docx4j' 3.1.0 version with Java 8 and I have a requirement to hide text while writing it into doc file. How do I go about this?
Upvotes: 0
Views: 325
Reputation: 11
After going through the wml structure of the doc file, I found out that doc has style field called Vanish which, I found from the docx4j source code, which is a method under the run properties object see the example below.
runProperties.setVanish(booleanDefaultTrue);
Full example for creating a hidden text with run is below.
public static R createHiddenTextRun(String data) {
R run=factory.createR();
RPr runProperties = new RPr();
BooleanDefaultTrue booleanDefaultTrue = new BooleanDefaultTrue();
runProperties.setVanish(booleanDefaultTrue);
run.setRPr(runProperties);
run.getContent().add(data);
return run;
}
Above I'm creating Run with Run properties which will hide the text we passed.
Upvotes: 1