String replace from a PowerPoint pptx file using docx4j
Posted: Thu Sep 10, 2015 5:01 am
I am trying to replace some placeholder texts from a PowerPoint .pptx file. They are in the format ${key} as described in the github sample code . However the following code only strips the curly braces off but does not replace the "key" with "green". Thanks for the help in advance.
- Code: Select all
PresentationMLPackage ppt = (PresentationMLPackage) OpcPackage.load(inputPptxFile);
SlidePart slide = ppt.getMainPresentationPart().getSlide(0);
HashMap h = new HashMap<String, String>();
h.put("key", "green");
slide.variableReplace(h);