I have this piece of code that merges the main part of a "parent" doc with a "secondary" doc.
Document parentDoc = cmis.getFile(parentFilePath);
WordprocessingMLPackage wordMLPackageParent = WordprocessingMLPackage.load(parentDoc.getContentStream().getStream());
WordprocessingMLPackage wordMLPackageOriginal = WordprocessingMLPackage.load(originalFile.inputStream());
wordMLPackageParent.getMainDocumentPart().getContent().addAll(wordMLPackageOriginal.getMainDocumentPart().getContent());
ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
wordMLPackageParent.save(byteArrayOutputStream);
return byteArrayOutputStream.toByteArray();
Although the merge is performed correctly, all my images are lost in the resulting file:
Initially, I suspected that there might be an issue with the images in the original file. However, when I simply execute:
wordMLPackageOriginal.save(byteArrayOutputStream);
return byteArrayOutputStream.toByteArray();
the resulting file has the correct images. Why they are being lost on the merged file?
