Python: Protect or Unprotect PowerPoint Presentations

PowerPoint presentations often contain sensitive information, such as financial data, trade secrets, or personal details. When sharing these files via email or cloud storage, it is important to prevent unauthorized individuals from accessing or viewing them. To protect the content of your PowerPoint presentation, there are various security measures you can employ. For instance, you can implement password protection, or make the presentation as final or read-only. In certain situations, you may find the need to unprotect a password-protected or encrypted PowerPoint presentation. This may be necessary when you need to share the file with the public or when the password is no longer needed. In this article, we will explain how to protect or unprotect a PowerPoint presentation in Python using Spire.Presentation for Python.

Install Spire.Presentation for Python

This scenario requires Spire.Presentation for Python and plum-dispatch v1.7.4. They can be easily installed in your Windows through the following pip command.

pip install Spire.Presentation

If you are unsure how to install, please refer to this tutorial: How to Install Spire.Presentation for Python on Windows

Protect a PowerPoint Presentation with a Password

You can protect a PowerPoint presentation with a password to ensure that only the people who have the right password can view and edit it.

The following steps demonstrate how to protect a PowerPoint presentation with a password:

  • Create an object of the Presentation class.
  • Load a PowerPoint presentation using Presentation.LoadFromFile() method.
  • Encrypt the presentation with a password using Presentation.Encrypt() method.
  • Save the resulting presentation using Presentation.SaveToFile() method.
  • Python
from spire.presentation import *

# Create a Presentation object
presentation = Presentation()
# Load a PowerPoint presentation
presentation.LoadFromFile("Sample.pptx")

# Encrypy the presentation with a password
presentation.Encrypt("your password")

# Save the resulting presentation
presentation.SaveToFile("Encrypted.pptx", FileFormat.Pptx2016)
presentation.Dispose()

Python: Protect or Unprotect PowerPoint Presentations

Mark a PowerPoint Presentation as Final

You can mark a PowerPoint presentation as final to inform readers that the document is final and no further editing is expected.

The following steps demonstrate how to mark a PowerPoint presentation as final:

  • Create an object of the Presentation class.
  • Load a PowerPoint presentation using Presentation.LoadFromFile() method.
  • Mark the presentation as final using presentation.DocumentProperty.MarkAsFinal property.
  • Save the resulting presentation using Presentation.SaveToFile() method.
  • Python
from spire.presentation import *

# Create a Presentation object
presentation = Presentation()
# Load a PowerPoint presentation
presentation.LoadFromFile("Sample.pptx")

# Mark the presentation as final
presentation.DocumentProperty.MarkAsFinal = True

# Save the resulting presentation
presentation.SaveToFile("MarkAsFinal.pptx", FileFormat.Pptx2016)
presentation.Dispose()

Python: Protect or Unprotect PowerPoint Presentations

Make a PowerPoint Presentation Read-Only

You can make a PowerPoint presentation read-only to allow others to view it while preventing them from making any changes to the content.

The following steps demonstrate how to make a PowerPoint presentation read-only:

  • Create an object of the Presentation class.
  • Load a PowerPoint presentation using Presentation.LoadFromFile() method.
  • Make the presentation read-only using Presentation.Protect() method.
  • Save the resulting presentation using Presentation.SaveToFile() method.
  • Python
from spire.presentation import *

# Create a Presentation object
presentation = Presentation()
# Load a PowerPoint presentation
presentation.LoadFromFile("Sample.pptx")

# Make the presentation read-only by protecting it with a password 
presentation.Protect("your password")

# Save the resulting presentation
presentation.SaveToFile("ReadOnly.pptx", FileFormat.Pptx2016)
presentation.Dispose()

Python: Protect or Unprotect PowerPoint Presentations

Remove Password Protection from a PowerPoint Presentation

You can remove password protection from a PowerPoint presentation by loading the presentation with the correct password and then removing the password protection from it.

The following steps demonstrate how to remove password protection from a PowerPoint presentation:

  • Create an object of the Presentation class.
  • Load a password-protected PowerPoint presentation with its password using Presentation.LoadFromFile() method.
  • Remove password protection from the presentation using Presentation.RemoveEncryption() method.
  • Save the resulting presentation using Presentation.SaveToFile() method.
  • Python
from spire.presentation import *

# Create a Presentation object
presentation = Presentation()
# Load an encrypted PowerPoint presentation with its password
presentation.LoadFromFile("Encrypted.pptx", "your password")

# Remove password encryption from the presentation
presentation.RemoveEncryption()

# Save the resulting presentation
presentation.SaveToFile("Decrypted.pptx", FileFormat.Pptx2016)
presentation.Dispose()

Python: Protect or Unprotect PowerPoint Presentations

Remove Mark as Final Option from a PowerPoint Presentation

The mark as final feature makes a PowerPoint presentation read-only to prevent further changes, if you decide to make changes to the presentation later, you can remove the mark as final option from it.

The following steps demonstrate how to remove the mark as final option from a PowerPoint presentation:

  • Create an object of the Presentation class.
  • Load a PowerPoint presentation that has been marked as final using Presentation.LoadFromFile() method.
  • Remove the mark as final option from the presentation using presentation.DocumentProperty.MarkAsFinal property.
  • Save the resulting presentation using Presentation.SaveToFile() method.
  • Python
from spire.presentation import *

# Create a Presentation object
presentation = Presentation()
# Load a PowerPoint presentation that has been marked as final
presentation.LoadFromFile("MarkAsFinal.pptx")

# Remove the mark as final option from the presentation
presentation.DocumentProperty.MarkAsFinal = False

# Save the resulting presentation
presentation.SaveToFile("RemoveMarkAsFinal.pptx", FileFormat.Pptx2016)
presentation.Dispose()

Python: Protect or Unprotect PowerPoint Presentations

Remove Read-Only Option from a PowerPoint Presentation

Removing the read-only option from a PowerPoint presentation allows you to regain full editing capabilities, enabling you to modify, add, or delete content within the presentation as needed.

The following steps demonstrate how to remove the read-only option from a PowerPoint presentation:

  • Create an object of the Presentation class.
  • Load a PowerPoint presentation that has been made as read-only using Presentation.LoadFromFile() method.
  • Remove the read-only option from the presentation using Presentation.RemoveProtect() method.
  • Save the resulting presentation using Presentation.SaveToFile() method.
  • Python
from spire.presentation import *

# Create a Presentation object
presentation = Presentation()
# Load a PowerPoint presentation that has been made as read-only
presentation.LoadFromFile("ReadOnly.pptx")

# Remove the read-only option from the presentation
presentation.RemoveProtect()

# Save the resulting presentation
presentation.SaveToFile("RemoveReadOnly.pptx", FileFormat.Pptx2016)
presentation.Dispose()

Python: Protect or Unprotect PowerPoint Presentations

Apply for a Temporary License

If you'd like to remove the evaluation message from the generated documents, or to get rid of the function limitations, please request a 30-day trial license for yourself.