Skip to content

Instantly share code, notes, and snippets.

@aspose-com-gists
Last active January 21, 2022 09:43
Show Gist options
  • Save aspose-com-gists/e85c3aff6d89f31923cc608394e28090 to your computer and use it in GitHub Desktop.
Save aspose-com-gists/e85c3aff6d89f31923cc608394e28090 to your computer and use it in GitHub Desktop.
Add Digital Signature to PowerPoint PPT in Python

Learn how to add and verify digital signatures in PowerPoint PPT in Python:

import aspose.slides as slides
# Load presentation
with slides.Presentation("presentation.pptx") as pres:
# Create DigitalSignature object with PFX file and PFX password
signature = slides.DigitalSignature("certificate.pfx", "password")
# Comment new digital signature
signature.comments = "Signing with Aspose.Slides"
# Add digital signature to presentation
pres.digital_signatures.add(signature)
# Save presentation
pres.save("SignedPPT.pptx", slides.export.SaveFormat.PPTX)
import aspose.slides as slides
# Load presentation
with slides.Presentation("presentation.pptx") as pres:
if len(pres.digital_signatures) > 0:
allSignaturesAreValid = True
print("Signatures used to sign the presentation: ")
# Check if all digital signatures are valid
for signature in pres.digital_signatures :
print(signature.certificate.subject_name.name + ", "
+ signature.sign_time.strftime("yyyy-MM-dd HH:mm") + " -- " + "VALID" if signature.is_valid else "INVALID")
allSignaturesAreValid = allSignaturesAreValid and signature.is_valid
if allSignaturesAreValid:
print("Presentation is original, all signatures are valid.")
else:
print("Presentation has been modified.")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment