Replacing text inside text boxes
Posted: Thu Apr 28, 2016 10:42 pm
Hi everyone,
I am a novice in docx4j. I'm trying to replace text inside text boxes.
I already saw this topic docx-java-f6/changing-text-in-a-textbox-t1523.html
But when i tried, not only the strings were not replaced, the text boxes were deleted in the output file. The same occurs with other shapes like some horizontal lines. My code is very simple.
In template.docx have 4 text boxes. two of them contains ${RAZON} and {DIR} texts. But the 4 are deleted during processing.
Im using 3.2.2 version.
Any help i really appreciate. Thanks.
I am a novice in docx4j. I'm trying to replace text inside text boxes.
I already saw this topic docx-java-f6/changing-text-in-a-textbox-t1523.html
But when i tried, not only the strings were not replaced, the text boxes were deleted in the output file. The same occurs with other shapes like some horizontal lines. My code is very simple.
- Code: Select all
WordprocessingMLPackage wordMLPackage = WordprocessingMLPackage.load(new java.io.File("template.docx"));
MainDocumentPart documentPart = wordMLPackage.getMainDocumentPart();
HashMap<String, String> map = new HashMap<String, String>();
map.put("RAZON", RAZON);
map.put("DIR", DIR);
documentPart.variableReplace(map);
File f = new File("output2.docx");
wordMLPackage.save(f);
In template.docx have 4 text boxes. two of them contains ${RAZON} and {DIR} texts. But the 4 are deleted during processing.
Im using 3.2.2 version.
Any help i really appreciate. Thanks.