Save Presentations in Read-Only Mode Using Python
Introduction
In PowerPoint 2019, Microsoft introduced the Always Open Read-Only setting as one of the options users can use to protect their presentations. You may want to use this Read-Only setting to protect a presentation when:
- You want to prevent accidental edits and keep the content of your presentation safe.
- You want to alert people that the presentation you provided is the final version.
After you select the Always Open Read-Only option for a presentation, when users open the presentation, they see the Read-Only recommendation and may see a message in this form: To prevent accidental changes, the author has set this file to open as read-only.
The Read-Only recommendation is a simple yet effective deterrent that discourages editing because users have to perform a task to remove it before they are allowed to edit a presentation. If you do not want users to make changes to a presentation and want to tell them about this in a polite way, then the Read-Only recommendation may be a good option for you.
If a presentation with the Read-Only protection gets opened in an older Microsoft PowerPoint application—which does not support the recently introduced function—the Read-Only recommendation gets ignored (the presentation is opened normally).
Apply Read-Only Mode
Aspose.Slides for Python via Java allows you to set a presentation to Read-Only, which means users (after they open the presentation) see the Read-Only recommendation. This sample code shows you how to set a presentation to Read-Only in Python using Aspose.Slides:
import jpype
import asposeslides
if not jpype.isJVMStarted():
jpype.startJVM()
from asposeslides.api import Presentation, SaveFormat
presentation = Presentation()
try:
presentation.getProtectionManager().setReadOnlyRecommended(True)
presentation.save("ReadOnlyPresentation.pptx", SaveFormat.Pptx)
finally:
presentation.dispose()
Note
The Read-Only recommendation is simply meant to discourage editing or stop users from making accidental changes to a PowerPoint presentation. If a motivated person—who knows what they are doing—decides to edit your presentation, they can easily remove the Read-Only setting. If you seriously need to prevent unauthorized editing, you are better off using more stringent protections that involve encryption and passwords.FAQ
**How is ‘Read-Only recommended’ different from full password protection? **
‘Read-Only recommended’ only displays a suggestion to open the file in read-only mode and is easy to bypass. Password protection actually restricts opening or editing and is appropriate when you need real security controls.
**Can ‘Read-Only recommended’ be combined with watermarks to further discourage edits? **
Yes. The recommendation can be paired with watermarks as a visual deterrent; they are separate mechanisms and work well together.
**Can a macro or external tool still modify the file when the recommendation is enabled? **
Yes. The recommendation does not block programmatic changes. To prevent automated edits, use passwords and encryption.
**How does ‘Read-Only recommended’ relate to the methods isEncrypted and isWriteProtected? **
They are different signals. ‘Read-Only recommended’ is a soft, optional prompt; isWriteProtected and isEncrypted indicate actual write or read restrictions that depend on passwords or encryption.