Saving a Presentation Twice after Removing the Password Results in Two Different Binaries

This is very similar to CELLSJAVA-45271, which you already fixed (thanks for that), just for Microsoft pptx files.

We’re using Aspose Slides for Java to remove passwords from Powerpoint (pptx) documents. We noticed that when we process the same password protected file twice, we get two unprotected files whose content isn’t binary identical. When comparing the contents of the created pptx files, we found a different dcterms:modified date in the core.xml. The date is set to the time when we removed the password.

I guess, technically the created pptx file is a new and modified pptx file. So, a new modification date might be expected. For our usecase (search engine with de-duplication, etc.) this is problematic.

Is the “current” date as modification date intended?

Our code looks likes this

  LoadOptions loadOptions = new LoadOptions();
            loadOptions.setPassword(pw);
            Presentation presentation = new Presentation(is, loadOptions);
            try {
                presentation.getProtectionManager().removeEncryption();
                try (OutputStream os = new FileOutputStream(...)) {
                    int saveFormat;
                    switch (presentation.getSourceFormat()) {
                        case SourceFormat.Pptx:
                        case SourceFormat.Ppt:
                            saveFormat = SaveFormat.Pptx;
                            break;
                        case SourceFormat.Odp:
                            saveFormat = SaveFormat.Odp;
                            break;
                        default:
                            throw new UnsupportedOperationException();
                    }

                    presentation.save(os, saveFormat);

                } catch (Exception e) {
                    unprotected.release();
                    throw e;
                }
                return Optional.of(...);
            } finally {
                presentation.dispose();
            }

input.zip (3.8 MB)
output.zip (7.1 MB)

@spfaff when you use Aspose.Slides to save a presentation it updates the modification date, this is the expected behavior. You can use the following workaround to deal with this if it is a problem for you:

// Right after load the presentation preserve source presentation LastSavedTime
Date tempLastSavedTime = presentation.getDocumentProperties().getLastSavedTime();
// After save the presentation
// Read and correct saved presentation properties
IPresentationInfo pInfo = PresentationFactory.getInstance().getPresentationInfo(destPath);

IDocumentProperties docProps = pInfo.readDocumentProperties();
// restore source LastSavedTime value
docProps.setLastSavedTime(tempLastSavedTime);

pInfo.updateDocumentProperties(docProps);
pInfo.writeBindedPresentation(destPath);