I have a pptx, in which I've embedded a docx.
Now I update the embedded docx, but the emf which is included in my pptx is not updated.
When I open the modified pptx and double-click the embedded docx, it is updated and the underlying emf will be updated too.
Is there any way to update the embedded docx and also update the emf, so that I can see the update right after opening the pptx?
Code:
- Code: Select all
PresentationMLPackage presentation = (PresentationMLPackage) OpcPackage.load(new ByteArrayInputStream(template));
for (Entry<PartName, Part> part : presentation.getParts().getParts().entrySet()) {
if (part.getKey().getName().equals("/ppt/embeddings/Microsoft_Word_Document1.docx")) {
EmbeddedPackagePart embedded = (EmbeddedPackagePart) part.getValue();
byte[] word = IOUtils.toByteArray(embedded.getBuffer(), embedded.getBuffer().capacity());
WordprocessingMLPackage docx = (WordprocessingMLPackage) OpcPackage.load(new ByteArrayInputStream(word));
Document document = docx.getMainDocumentPart().getJaxbElement();
// do something and modify the docx...
ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
SaveToZipFile saver = new SaveToZipFile(docx);
saver.save(byteArrayOutputStream);
byteArrayOutputStream.close();
embedded.setBinaryData(byteArrayOutputStream.toByteArray());
}
}
presentation.save(new java.io.File("c:/users/hombach/desktop/embedded.pptx"));
}