Skip to content

Commit 7f70d77

Browse files
authored
Add files via upload
1 parent e891c85 commit 7f70d77

File tree

4 files changed

+98
-1
lines changed

4 files changed

+98
-1
lines changed
Original file line numberDiff line numberDiff line change
@@ -1 +1,35 @@
1-
1+
from spire.presentation import *
2+
3+
inputFile = "./Data/GetProperties.pptx"
4+
outputFile = "GetBuiltinProperties.txt"
5+
6+
#Create PPT document
7+
presentation = Presentation()
8+
#Load the PPT document from disk
9+
presentation.LoadFromFile(inputFile)
10+
#Get the builtin properties
11+
application = presentation.DocumentProperty.Application
12+
author = presentation.DocumentProperty.Author
13+
company = presentation.DocumentProperty.Company
14+
keywords = presentation.DocumentProperty.Keywords
15+
comments = presentation.DocumentProperty.Comments
16+
category = presentation.DocumentProperty.Category
17+
title = presentation.DocumentProperty.Title
18+
subject = presentation.DocumentProperty.Subject
19+
#Create StringBuilder to save
20+
content = []
21+
content.append ("DocumentProperty.Application: " + application +"\r")
22+
content.append("DocumentProperty.Author: " + author+"\r")
23+
content.append("DocumentProperty.Company " + company+"\r")
24+
content.append("DocumentProperty.Keywords: " + keywords+"\r")
25+
content.append("DocumentProperty.Comments: " + comments+"\r")
26+
content.append("DocumentProperty.Category: " + category+"\r")
27+
content.append("DocumentProperty.Title: " + title+"\r")
28+
content.append("DocumentProperty.Subject: " + subject+"\r")
29+
#Save them to a txt file
30+
#Save the result file
31+
f2=open(outputFile,'w', encoding='UTF-8')
32+
for item in content:
33+
f2.write(item)
34+
f2.close()
35+
presentation.Dispose()
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
from spire.presentation import *
2+
3+
inputFile = "./Data/MarkAsFinal.pptx"
4+
outputFile = "MarkAsFinal_out.pptx"
5+
6+
#Create a PPT document
7+
presentation = Presentation()
8+
#Load the document from disk
9+
presentation.LoadFromFile(inputFile)
10+
#Mark the document as final
11+
presentation.DocumentProperty.MarkAsFinal = True
12+
#Save the document
13+
presentation.SaveToFile(outputFile, FileFormat.Pptx2010)
14+
presentation.Dispose()
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
from spire.presentation import *
2+
3+
inputFile = "./Data/Properties.pptx"
4+
outputFile = "Properties_out.pptx"
5+
6+
#Create a PPT document
7+
presentation = Presentation()
8+
presentation.LoadFromFile(inputFile)
9+
#Set the DocumentProperty of PPT document
10+
presentation.DocumentProperty.Application = "Spire.Presentation"
11+
presentation.DocumentProperty.Author = "E-iceblue"
12+
presentation.DocumentProperty.Company = "E-iceblue Co., Ltd."
13+
presentation.DocumentProperty.Keywords = "Demo File"
14+
presentation.DocumentProperty.Comments = "This file is used to test Spire.Presentation."
15+
presentation.DocumentProperty.Category = "Demo"
16+
presentation.DocumentProperty.Title = "This is a demo file."
17+
presentation.DocumentProperty.Subject = "Test"
18+
#Save the document
19+
presentation.SaveToFile(outputFile, FileFormat.Pptx2010)
20+
presentation.Dispose()
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
from spire.presentation import *
2+
3+
outputFile_pptx = "SetPropertiesForTemplate.pptx"
4+
outputFile_ppt = "SetPropertiesForTemplate.ppt"
5+
outputFile_odp = "SetPropertiesForTemplate.odp"
6+
7+
def SetPropertiesForTemplate(filePath, fileFormat):
8+
#Create a document
9+
presentation = Presentation()
10+
#Set the DocumentProperty
11+
presentation.DocumentProperty.Application = "Spire.Presentation"
12+
presentation.DocumentProperty.Author = "E-iceblue"
13+
presentation.DocumentProperty.Company = "E-iceblue Co., Ltd."
14+
presentation.DocumentProperty.Keywords = "Demo File"
15+
presentation.DocumentProperty.Comments = "This file is used to test Spire.Presentation."
16+
presentation.DocumentProperty.Category = "Demo"
17+
presentation.DocumentProperty.Title = "This is a demo file."
18+
presentation.DocumentProperty.Subject = "Test"
19+
#Save to template file
20+
presentation.SaveToFile(filePath, fileFormat)
21+
presentation.Dispose()
22+
23+
24+
#Create the .pptx template
25+
SetPropertiesForTemplate(outputFile_pptx, FileFormat.Pptx2013)
26+
#Create the .odp template
27+
SetPropertiesForTemplate(outputFile_odp, FileFormat.ODP)
28+
#Create the .ppt template
29+
SetPropertiesForTemplate(outputFile_ppt, FileFormat.PPT)

0 commit comments

Comments
 (0)