Skip to content

Instantly share code, notes, and snippets.

@aspose-words
Last active April 9, 2017 19:26
Show Gist options
  • Save aspose-words/0d2824be27de65c1b51db2f28f4069a0 to your computer and use it in GitHub Desktop.
Save aspose-words/0d2824be27de65c1b51db2f28f4069a0 to your computer and use it in GitHub Desktop.
Aspose_Words_Cloud_Python
import asposewordscloud
from asposewordscloud.WordsApi import WordsApi
from asposewordscloud.WordsApi import RevisionsModificationResponse
import asposestoragecloud
from asposestoragecloud.StorageApi import StorageApi
from asposestoragecloud.StorageApi import ResponseMessage
apiKey = "XXXXX" #sepcify App Key
appSid = "XXXXX" #sepcify App SID
apiServer = "http://api.aspose.com/v1.1"
data_folder = "../../data/"
#Instantiate Aspose Storage API SDK
storage_apiClient = asposestoragecloud.ApiClient.ApiClient(apiKey, appSid, True)
storageApi = StorageApi(storage_apiClient)
#Instantiate Aspose Words API SDK
api_client = asposewordscloud.ApiClient.ApiClient(apiKey, appSid, True)
wordsApi = WordsApi(api_client);
#set input file name
filename = "SampleWordDocument.docx"
#upload file to aspose cloud storage
storageApi.PutCreate(Path=filename, file=data_folder + filename)
try:
#invoke Aspose.Words Cloud SDK API to accept all revisions
response = wordsApi.AcceptAllRevisions(name=filename)
if response.Status == "OK":
print "Document track changes have been accepted successfully"
except ApiException as ex:
print "ApiException:"
print "Code:" + str(ex.code)
print "Message:" + ex.message
import asposewordscloud
from asposewordscloud.WordsApi import WordsApi
from asposewordscloud.WordsApi import ApiException
from asposewordscloud.models import FormField
from asposewordscloud.models import FormFieldResponse
import asposestoragecloud
from asposestoragecloud.StorageApi import StorageApi
from asposestoragecloud.StorageApi import ResponseMessage
apiKey = "XXXXX" #sepcify App Key
appSid = "XXXXX" #sepcify App SID
apiServer = "http://api.aspose.com/v1.1"
data_folder = "../../data/"
#Instantiate Aspose Storage API SDK
storage_apiClient = asposestoragecloud.ApiClient.ApiClient(apiKey, appSid, True)
storageApi = StorageApi(storage_apiClient)
#Instantiate Aspose Words API SDK
api_client = asposewordscloud.ApiClient.ApiClient(apiKey, appSid, True)
wordsApi = WordsApi(api_client)
#set input file name
filename = "SampleBlankWordDocument.docx"
destfilename = "updated-" + filename
sectionindex = 0
paragraphindex = 0
body = FormField.FormField()
body.Name = "MyName"
body.Enabled = True
body.OwnStatus = False
body.CalculateOnExit = True
body.TextInputFormat = "UPPERCASE"
body.TextInputType = "Regular"
body.TextInputDefault = "Farooq Sheikh"
#upload file to aspose cloud storage
storageApi.PutCreate(Path=filename, file=data_folder + filename)
try:
#invoke Aspose.Words Cloud SDK API to add field in the document
response = wordsApi.PutFormField(name=filename, sectionIndex=sectionindex, paragraphIndex=paragraphindex, body=body, destFileName=destfilename)
if response.Status == "OK":
print "Form field has been added successfully"
#download updated document from storage server
response = storageApi.GetDownload(Path=destfilename)
outfilename = "c:/temp/" + destfilename
with open(outfilename, 'wb') as f:
for chunk in response.InputStream:
f.write(chunk)
except ApiException as ex:
print "ApiException:"
print "Code:" + str(ex.code)
print "Message:" + ex.message
import asposewordscloud
from asposewordscloud.WordsApi import WordsApi
from asposewordscloud.WordsApi import ApiException
from asposewordscloud.models import ProtectionRequest
import asposestoragecloud
from asposestoragecloud.StorageApi import StorageApi
from asposestoragecloud.StorageApi import ResponseMessage
apiKey = "XXXXX" #sepcify App Key
appSid = "XXXXX" #sepcify App SID
apiServer = "http://api.aspose.com/v1.1"
data_folder = "../../data/"
#Instantiate Aspose Storage API SDK
storage_apiClient = asposestoragecloud.ApiClient.ApiClient(apiKey, appSid, True)
storageApi = StorageApi(storage_apiClient)
#Instantiate Aspose Words API SDK
api_client = asposewordscloud.ApiClient.ApiClient(apiKey, appSid, True)
wordsApi = WordsApi(api_client)
#set input file name
filename = "SampleBlankWordDocument.docx"
destfilename = "updated-" + filename
rotationAngle = 0.0
image = "aspose-cloud.png"
#upload file to aspose cloud storage
storageApi.PutCreate(Path=filename, file=data_folder + filename)
try:
#invoke Aspose.Words Cloud SDK API to remove add watermark image in a word document
response = wordsApi.PostInsertWatermarkImage(name=filename, file=data_folder + image, filename=destfilename, rotationAngle=rotationAngle)
if response.Status == "OK":
print "Watermark image has been added successfully"
#download updated document from storage server
response = storageApi.GetDownload(Path=destfilename)
outfilename = "c:/temp/" + destfilename
with open(outfilename, 'wb') as f:
for chunk in response.InputStream:
f.write(chunk)
except ApiException as ex:
print "ApiException:"
print "Code:" + str(ex.code)
print "Message:" + ex.message
import asposewordscloud
from asposewordscloud.WordsApi import WordsApi
from asposewordscloud.WordsApi import ApiException
from asposewordscloud.models import WatermarkText
import asposestoragecloud
from asposestoragecloud.StorageApi import StorageApi
from asposestoragecloud.StorageApi import ResponseMessage
apiKey = "XXXXX" #sepcify App Key
appSid = "XXXXX" #sepcify App SID
apiServer = "http://api.aspose.com/v1.1"
data_folder = "../../data/"
#Instantiate Aspose Storage API SDK
storage_apiClient = asposestoragecloud.ApiClient.ApiClient(apiKey, appSid, True)
storageApi = StorageApi(storage_apiClient)
#Instantiate Aspose Words API SDK
api_client = asposewordscloud.ApiClient.ApiClient(apiKey, appSid, True)
wordsApi = WordsApi(api_client)
#set input file name
filename = "SampleBlankWordDocument.docx"
destfilename = "updated-" + filename
rotationAngle = 0.0
text = "New"
body = WatermarkText.WatermarkText()
body.Text = "aspose.com"
#upload file to aspose cloud storage
storageApi.PutCreate(Path=filename, file=data_folder + filename)
try:
#invoke Aspose.Words Cloud SDK API to add watermark text in a word document
response = wordsApi.PostInsertWatermarkText(name=filename, body=body, filename=destfilename, rotationAngle=rotationAngle)
if response.Status == "OK":
print "Watermark text has been added successfully"
#download updated document from storage server
response = storageApi.GetDownload(Path=destfilename)
outfilename = "c:/temp/" + destfilename
with open(outfilename, 'wb') as f:
for chunk in response.InputStream:
f.write(chunk)
except ApiException as ex:
print "ApiException:"
print "Code:" + str(ex.code)
print "Message:" + ex.message
import asposewordscloud
from asposewordscloud.WordsApi import WordsApi
from asposewordscloud.models import DocumentEntry
from asposewordscloud.models import DocumentEntryList
from asposewordscloud.models import DocumentResponse
import asposestoragecloud
from asposestoragecloud.StorageApi import StorageApi
from asposestoragecloud.StorageApi import ResponseMessage
apiKey = "XXXXX" #sepcify App Key
appSid = "XXXXX" #sepcify App SID
apiServer = "http://api.aspose.com/v1.1"
data_folder = "../../data/"
try:
#Instantiate Aspose Storage API SDK
storageapiClient = asposestoragecloud.ApiClient.ApiClient(apiKey, appSid, debug = True)
storageApi = StorageApi(storageapiClient)
#Instantiate Aspose Words API SDK
apiClient = asposewordscloud.ApiClient.ApiClient(apiKey, appSid, debug = True)
wordsApi = WordsApi(apiClient);
#set destination file name
source_file_name = "AppendWordDocumentsExample-TestFile-Source.doc"
#set source file name
dest_file_name = "AppendWordDocumentsExample-TestFile-Destination.doc"
#upload source file to aspose cloud storage
storageApi.PutCreate(source_file_name, data_folder + source_file_name)
#upload destination file to aspose cloud storage
storageApi.PutCreate(dest_file_name, data_folder + dest_file_name)
document_entry_1 = DocumentEntry.DocumentEntry()
document_entry_1.Href = source_file_name
document_entry_1.ImportFormatMode = "KeepSourceFormatting"
body = DocumentEntryList.DocumentEntryList()
body.DocumentEntries = [document_entry_1]
#invoke Aspose.Words Cloud SDK API to append word document
response = wordsApi.PostAppendDocument(dest_file_name, body)
if(response.Status == 'OK'):
print "Documents have been appended successfully"
#download appended document from storage server
response = storageApi.GetDownload(Path=dest_file_name)
outfilename = "c:/temp/" + dest_file_name
with open(outfilename, 'wb') as f:
for chunk in response.InputStream:
f.write(chunk)
except ApiException as ex:
print "ApiException:"
print "Code:" + str(ex.code)
print "Message:" + ex.message
import asposewordscloud
from asposewordscloud.WordsApi import WordsApi
from asposewordscloud.WordsApi import ApiException
import asposestoragecloud
from asposestoragecloud.StorageApi import StorageApi
from asposestoragecloud.StorageApi import ResponseMessage
apiKey = "XXXXX" #sepcify App Key
appSid = "XXXXX" #sepcify App SID
apiServer = "http://api.aspose.com/v1.1"
data_folder = "../../data/"
try:
#Instantiate Aspose Storage API SDK
storageapiClient = asposestoragecloud.ApiClient.ApiClient(apiKey, appSid, debug = True)
storageApi = StorageApi(storageapiClient)
#Instantiate Aspose Words API SDK
apiClient = asposewordscloud.ApiClient.ApiClient(apiKey, appSid, debug = True)
wordsApi = WordsApi(apiClient);
#set input file name
name = "SampleWordDocument"
filename = name + ".docx"
format = "pdf"
#upload file to aspose cloud storage
storageApi.PutCreate(filename, data_folder + filename)
#invoke Aspose.Words Cloud SDK API to convert words document to required format
response = wordsApi.GetDocumentWithFormat(name=filename, format=format)
if response.Status == 'OK':
outfilename = "c:/temp/" + name + "." + format
with open(outfilename, 'wb') as f:
for chunk in response.InputStream:
f.write(chunk)
except ApiException as ex:
print "ApiException:"
print "Code:" + str(ex.code)
print "Message:" + ex.message
aas
asa
sas
import asposewordscloud
from asposewordscloud.WordsApi import WordsApi
from asposewordscloud.models import SaveOptionsData
import asposestoragecloud
from asposestoragecloud.StorageApi import StorageApi
from asposestoragecloud.StorageApi import ResponseMessage
apiKey = "XXXXX" #sepcify App Key
appSid = "XXXXX" #sepcify App SID
apiServer = "http://api.aspose.com/v1.1"
data_folder = "../../data/"
#Instantiate Aspose Storage API SDK
storageapiClient = asposestoragecloud.ApiClient.ApiClient(apiKey, appSid, debug = True)
storageApi = StorageApi(storageapiClient)
#Instantiate Aspose Words API SDK
apiClient = asposewordscloud.ApiClient.ApiClient(apiKey, appSid, debug = True)
wordsApi = WordsApi(apiClient)
#set input file name
name = "SampleWordDocument"
filename = name + ".docx"
format = "pdf"
storage="AsposeDropboxStorage"
#upload file to 3rd Party (like dropbox cloud storage)
storageApi.PutCreate(Path = filename, file = data_folder + filename, storage=storage)
#invoke Aspose.Words Cloud SDK API to convert words document to required format
response = wordsApi.GetDocumentWithFormat(name=filename, format=format, storage=storage)
if response.Status == 'OK':
outfilename = "c:/temp/" + name + "." + format
with open(outfilename, 'wb') as f:
for chunk in response.InputStream:
f.write(chunk)
import asposewordscloud
from asposewordscloud.WordsApi import WordsApi
from asposewordscloud.WordsApi import ApiException
from asposewordscloud.models import LoadWebDocumentData
from asposewordscloud.models import SaveOptionsData
import asposestoragecloud
from asposestoragecloud.StorageApi import StorageApi
from asposestoragecloud.StorageApi import ResponseMessage
apiKey = "XXXXX" #sepcify App Key
appSid = "XXXXX" #sepcify App SID
apiServer = "http://api.aspose.com/v1.1"
data_folder = "../../data/"
try:
#Instantiate Aspose Storage API SDK
storage_apiClient = asposestoragecloud.ApiClient.ApiClient(apiKey, appSid, True)
storageApi = StorageApi(storage_apiClient)
#Instantiate Aspose Words API SDK
api_client = asposewordscloud.ApiClient.ApiClient(apiKey, appSid, True)
wordsApi = WordsApi(api_client);
#set output file name
filename ="WebPageConverterExample.doc"
loadWebDocumentData = LoadWebDocumentData.LoadWebDocumentData()
loadWebDocumentData.LoadingDocumentUrl = "http://www.aspose.com/corporate/default.aspx"
saveOptionsData = SaveOptionsData.SaveOptionsData()
saveOptionsData.FileName = filename
saveOptionsData.SaveFormat = "doc"
loadWebDocumentData.SaveOptions=saveOptionsData
#invoke Aspose.Words Cloud SDK API to convert live web page into words document
response = wordsApi.PostLoadWebDocument(body=loadWebDocumentData)
if(response.Status == 'OK'):
print "Document has been generated successfully"
#download output document from storage server
response = storageApi.GetDownload(Path=filename)
outfilename = "c:/temp/" + filename
with open(outfilename, 'wb') as f:
for chunk in response.InputStream:
f.write(chunk)
except ApiException as ex:
print "ApiException:"
print "Code:" + str(ex.code)
print "Message:" + ex.message
import asposewordscloud
from asposewordscloud.WordsApi import WordsApi
from asposewordscloud.models import SaveOptionsData
from asposewordscloud.models import SaveResult
import asposestoragecloud
from asposestoragecloud.StorageApi import StorageApi
from asposestoragecloud.StorageApi import ResponseMessage
apiKey = "XXXXX" #sepcify App Key
appSid = "XXXXX" #sepcify App SID
apiServer = "http://api.aspose.com/v1.1"
data_folder = "../../data/"
try:
#Instantiate Aspose Storage API SDK
storageapiClient = asposestoragecloud.ApiClient.ApiClient(apiKey, appSid, debug = True)
storageApi = StorageApi(storageapiClient)
#Instantiate Aspose Words API SDK
apiClient = asposewordscloud.ApiClient.ApiClient(apiKey, appSid, debug = True)
wordsApi = WordsApi(apiClient);
#set input file name
filename = "SampleWordDocument.docx"
format = "pdf"
outfilename = "SampleWordDocumentOutput.pdf"
body = SaveOptionsData.SaveOptionsData()
body.FileName = outfilename
body.SaveFormat = "pdf"
# invoke Aspose.Words Cloud SDK API to save document to required format
response = wordsApi.PostDocumentSaveAs(filename, body)
if(response.Status == 'OK'):
outputfilename = response.SaveResult.DestDocument.Href;
response = storageApi.GetDownload(Path= outputfilename)
outfilename = "c:/temp/" + outputfilename
with open(outfilename, 'wb') as f:
for chunk in response.InputStream:
f.write(chunk)
except ApiException as ex:
print "ApiException:"
print "Code:" + str(ex.code)
print "Message:" + ex.message
import asposewordscloud
from asposewordscloud.WordsApi import WordsApi
from asposewordscloud.WordsApi import ApiException
import asposestoragecloud
from asposestoragecloud.StorageApi import StorageApi
from asposestoragecloud.StorageApi import ResponseMessage
apiKey = "XXXXX" #sepcify App Key
appSid = "XXXXX" #sepcify App SID
apiServer = "http://api.aspose.com/v1.1"
data_folder = "../../data/"
try:
#Instantiate Aspose Storage API SDK
storageapiClient = asposestoragecloud.ApiClient.ApiClient(apiKey, appSid, debug = True)
storageApi = StorageApi(storageapiClient)
#Instantiate Aspose Words API SDK
apiClient = asposewordscloud.ApiClient.ApiClient(apiKey, appSid, debug = True)
wordsApi = WordsApi(apiClient);
#set input file name
name = "SampleWordDocument"
filename = name + ".docx"
format = "pdf"
#upload file to aspose cloud storage
storageApi.PutCreate(filename, data_folder + filename)
#invoke Aspose.Words Cloud SDK API to convert words document to required format
response = wordsApi.GetDocumentWithFormat(name=filename, format=format)
if response.Status == 'OK':
outfilename = "c:/temp/" + name + "." + format
with open(outfilename, 'wb') as f:
for chunk in response.InputStream:
f.write(chunk)
except ApiException as ex:
print "ApiException:"
print "Code:" + str(ex.code)
print "Message:" + ex.message
import asposewordscloud
from asposewordscloud.WordsApi import WordsApi
from asposewordscloud.WordsApi import ApiException
from asposewordscloud.models import ResponseMessage
apiKey = "XXXXX" #sepcify App Key
appSid = "XXXXX" #sepcify App SID
apiServer = "http://api.aspose.com/v1.1"
data_folder = "../../data/"
try:
#Instantiate Aspose Words API SDK
apiClient = asposewordscloud.ApiClient.ApiClient(apiKey, appSid, debug=True)
wordsApi = WordsApi(apiClient);
#set input file name
name = "SampleWordDocument"
filename = name + ".docx"
format = "pdf"
#invoke Aspose.Words Cloud SDK API to convert words document to required format using file
response = wordsApi.PutConvertDocument(file=data_folder + filename, format="pdf")
if(response.Status == "OK"):
outfilename = "c:/temp/" + name + "." + format
with open(outfilename, 'wb') as f:
for chunk in response.InputStream:
f.write(chunk)
except ApiException as ex:
print "ApiException:"
print "Code:" + str(ex.code)
print "Message:" + ex.message
import asposewordscloud
from asposewordscloud.WordsApi import WordsApi
from asposewordscloud.WordsApi import ApiException
from asposewordscloud.models import ProtectionRequest
import asposestoragecloud
from asposestoragecloud.StorageApi import StorageApi
from asposestoragecloud.StorageApi import ResponseMessage
apiKey = "XXXXX" #sepcify App Key
appSid = "XXXXX" #sepcify App SID
apiServer = "http://api.aspose.com/v1.1"
data_folder = "../../data/"
#Instantiate Aspose Storage API SDK
storage_apiClient = asposestoragecloud.ApiClient.ApiClient(apiKey, appSid, True)
storageApi = StorageApi(storage_apiClient)
#Instantiate Aspose Words API SDK
api_client = asposewordscloud.ApiClient.ApiClient(apiKey, appSid, True)
wordsApi = WordsApi(api_client)
#set input file name
filename = "SampleExecuteTemplate.docx"
destfilename = "updated-" + filename
#set input file data name
filedataname = "SampleExecuteTemplateData.txt"
#upload file to aspose cloud storage
storageApi.PutCreate(Path=filename, file=data_folder + filename)
try:
#invoke Aspose.Words Cloud SDK API to execute mail merge template and populate a word document from XML data
response = wordsApi.PostExecuteTemplate(name=filename, file=data_folder + filedataname, filename=destfilename)
if response.Status == "OK":
print "mail merge template has been executed successfully"
#download updated document from storage server
response = storageApi.GetDownload(Path=destfilename)
outfilename = "c:/temp/" + destfilename
with open(outfilename, 'wb') as f:
for chunk in response.InputStream:
f.write(chunk)
except ApiException as ex:
print "ApiException:"
print "Code:" + str(ex.code)
print "Message:" + ex.message
import asposewordscloud
from asposewordscloud.WordsApi import WordsApi
from asposewordscloud.WordsApi import ApiException
from asposewordscloud.models import ProtectionRequest
import asposestoragecloud
from asposestoragecloud.StorageApi import StorageApi
from asposestoragecloud.StorageApi import ResponseMessage
apiKey = "XXXXX" #sepcify App Key
appSid = "XXXXX" #sepcify App SID
apiServer = "http://api.aspose.com/v1.1"
data_folder = "../../data/"
#Instantiate Aspose Storage API SDK
storage_apiClient = asposestoragecloud.ApiClient.ApiClient(apiKey, appSid, True)
storageApi = StorageApi(storage_apiClient)
#Instantiate Aspose Words API SDK
api_client = asposewordscloud.ApiClient.ApiClient(apiKey, appSid, True)
wordsApi = WordsApi(api_client)
#set input file name
filename = "SampleExecuteTemplate.docx"
destfilename = "updated-" + filename
storage = "AsposeDropboxStorage"
#set input file data name
filedataname = "SampleExecuteTemplateData.txt"
#upload file to aspose cloud storage
storageApi.PutCreate(Path=filename, file=data_folder + filename, storage=storage)
try:
#invoke Aspose.Words Cloud SDK API to execute mail merge template and populate a word document from XML data
response = wordsApi.PostExecuteTemplate(name=filename, file=data_folder + filedataname, filename=destfilename, storage=storage)
if response.Status == "OK":
print "mail merge template has been executed successfully"
#download updated document from storage server
response = storageApi.GetDownload(Path=destfilename, storage=storage)
outfilename = "c:/temp/" + destfilename
with open(outfilename, 'wb') as f:
for chunk in response.InputStream:
f.write(chunk)
except ApiException as ex:
print "ApiException:"
print "Code:" + str(ex.code)
print "Message:" + ex.message
import asposewordscloud
from asposewordscloud.WordsApi import WordsApi
from asposewordscloud.WordsApi import ApiException
from asposewordscloud.models import ProtectionRequest
import asposestoragecloud
from asposestoragecloud.StorageApi import StorageApi
from asposestoragecloud.StorageApi import ResponseMessage
apiKey = "XXXXX" #sepcify App Key
appSid = "XXXXX" #sepcify App SID
apiServer = "http://api.aspose.com/v1.1"
data_folder = "../../data/"
#Instantiate Aspose Storage API SDK
storage_apiClient = asposestoragecloud.ApiClient.ApiClient(apiKey, appSid, True)
storageApi = StorageApi(storage_apiClient)
#Instantiate Aspose Words API SDK
api_client = asposewordscloud.ApiClient.ApiClient(apiKey, appSid, True)
wordsApi = WordsApi(api_client)
#set input file name
filename = "SampleMailMergeTemplate.docx"
destfilename = "updated-" + filename
#set input file data name
filedataname = "SampleMailMergeTemplateData.txt"
#upload file to aspose cloud storage
storageApi.PutCreate(Path=filename, file=data_folder + filename)
try:
#invoke Aspose.Words Cloud SDK API to execute mail merge and populate a word document from XML data
response = wordsApi.PostDocumentExecuteMailMerge(name=filename, withRegions=False, file=data_folder + filedataname, filename=destfilename)
if response.Status == "OK":
print "mail merge template has been executed successfully"
#download updated document from storage server
response = storageApi.GetDownload(Path=destfilename)
outfilename = "c:/temp/" + destfilename
with open(outfilename, 'wb') as f:
for chunk in response.InputStream:
f.write(chunk)
except ApiException as ex:
print "ApiException:"
print "Code:" + str(ex.code)
print "Message:" + ex.message
import asposewordscloud
from asposewordscloud.WordsApi import WordsApi
from asposewordscloud.WordsApi import ApiException
from asposewordscloud.models import ProtectionRequest
import asposestoragecloud
from asposestoragecloud.StorageApi import StorageApi
from asposestoragecloud.StorageApi import ResponseMessage
apiKey = "XXXXX" #sepcify App Key
appSid = "XXXXX" #sepcify App SID
apiServer = "http://api.aspose.com/v1.1"
data_folder = "../../data/"
#Instantiate Aspose Storage API SDK
storage_apiClient = asposestoragecloud.ApiClient.ApiClient(apiKey, appSid, True)
storageApi = StorageApi(storage_apiClient)
#Instantiate Aspose Words API SDK
api_client = asposewordscloud.ApiClient.ApiClient(apiKey, appSid, True)
wordsApi = WordsApi(api_client)
#set input file name
filename = "SampleMailMergeTemplate.docx"
destfilename = "updated-" + filename
#set input file data name
filedataname = "SampleMailMergeTemplateData.txt"
#upload file to aspose cloud storage
#storageApi.PutCreate(Path=filename, file=data_folder + filename)
try:
#invoke Aspose.Words Cloud SDK API to execute mail merge online and populate a word document from XML data
response = wordsApi.PutExecuteMailMergeOnline(withRegions=False, file=data_folder + filename, data=data_folder + filedataname)
if response.Status == "OK":
print "mail merge online template has been executed successfully"
#download updated document from response
outfilename = "c:/temp/" + destfilename
with open(outfilename, 'wb') as f:
for chunk in response.InputStream:
f.write(chunk)
except ApiException as ex:
print "ApiException:"
print "Code:" + str(ex.code)
print "Message:" + ex.message
import asposewordscloud
from asposewordscloud.WordsApi import WordsApi
from asposewordscloud.WordsApi import ApiException
from asposewordscloud.models import ProtectionRequest
import asposestoragecloud
from asposestoragecloud.StorageApi import StorageApi
from asposestoragecloud.StorageApi import ResponseMessage
apiKey = "XXXXX" #sepcify App Key
appSid = "XXXXX" #sepcify App SID
apiServer = "http://api.aspose.com/v1.1"
data_folder = "../../data/"
#Instantiate Aspose Storage API SDK
storage_apiClient = asposestoragecloud.ApiClient.ApiClient(apiKey, appSid, True)
storageApi = StorageApi(storage_apiClient)
#Instantiate Aspose Words API SDK
api_client = asposewordscloud.ApiClient.ApiClient(apiKey, appSid, True)
wordsApi = WordsApi(api_client)
#set input file name
filename = "SampleMailMergeTemplate.docx"
destfilename = "updated-" + filename
storage = "AsposeDropboxStorage"
#set input file data name
filedataname = "SampleMailMergeTemplateData.txt"
#upload file to aspose cloud storage
storageApi.PutCreate(Path=filename, file=data_folder + filename, storage=storage)
try:
#invoke Aspose.Words Cloud SDK API to execute mail merge and populate a word document from XML data
response = wordsApi.PostDocumentExecuteMailMerge(name=filename, withRegions=False, file=data_folder + filedataname, filename=destfilename, storage=storage)
if response.Status == "OK":
print "mail merge template has been executed successfully"
#download updated document from storage server
response = storageApi.GetDownload(Path=destfilename, storage=storage)
outfilename = "c:/temp/" + destfilename
with open(outfilename, 'wb') as f:
for chunk in response.InputStream:
f.write(chunk)
except ApiException as ex:
print "ApiException:"
print "Code:" + str(ex.code)
print "Message:" + ex.message
import asposewordscloud
from asposewordscloud.WordsApi import WordsApi
from asposewordscloud.WordsApi import ApiException
from asposewordscloud.models import ProtectionRequest
import asposestoragecloud
from asposestoragecloud.StorageApi import StorageApi
from asposestoragecloud.StorageApi import ResponseMessage
apiKey = "XXXXX" #sepcify App Key
appSid = "XXXXX" #sepcify App SID
apiServer = "http://api.aspose.com/v1.1"
data_folder = "../../data/"
#Instantiate Aspose Storage API SDK
storage_apiClient = asposestoragecloud.ApiClient.ApiClient(apiKey, appSid, True)
storageApi = StorageApi(storage_apiClient)
#Instantiate Aspose Words API SDK
api_client = asposewordscloud.ApiClient.ApiClient(apiKey, appSid, True)
wordsApi = WordsApi(api_client)
#set input file name
filename = "SampleInvoiceTemplate.doc"
destfilename = "updated-" + filename
#set input file data name
filedataname = "SampleInvoiceTemplateData.txt"
#upload file to aspose cloud storage
storageApi.PutCreate(Path=filename, file=data_folder + filename)
try:
#invoke Aspose.Words Cloud SDK API to execute mail merge and populate a word document from XML data
response = wordsApi.PostDocumentExecuteMailMerge(name=filename, withRegions=True, file=data_folder + filedataname, filename=destfilename)
if response.Status == "OK":
print "mail merge template has been executed successfully"
#download updated document from storage server
response = storageApi.GetDownload(Path=destfilename)
outfilename = "c:/temp/" + destfilename
with open(outfilename, 'wb') as f:
for chunk in response.InputStream:
f.write(chunk)
except ApiException as ex:
print "ApiException:"
print "Code:" + str(ex.code)
print "Message:" + ex.message
import asposewordscloud
from asposewordscloud.WordsApi import WordsApi
from asposewordscloud.WordsApi import ApiException
from asposewordscloud.models import ProtectionRequest
import asposestoragecloud
from asposestoragecloud.StorageApi import StorageApi
from asposestoragecloud.StorageApi import ResponseMessage
apiKey = "XXXXX" #sepcify App Key
appSid = "XXXXX" #sepcify App SID
apiServer = "http://api.aspose.com/v1.1"
data_folder = "../../data/"
#Instantiate Aspose Storage API SDK
storage_apiClient = asposestoragecloud.ApiClient.ApiClient(apiKey, appSid, True)
storageApi = StorageApi(storage_apiClient)
#Instantiate Aspose Words API SDK
api_client = asposewordscloud.ApiClient.ApiClient(apiKey, appSid, True)
wordsApi = WordsApi(api_client)
#set input file name
filename = "SampleInvoiceTemplate.doc"
destfilename = "updated-" + filename
storage = "AsposeDropboxStorage"
#set input file data name
filedataname = "SampleInvoiceTemplateData.txt"
#upload file to aspose cloud storage
storageApi.PutCreate(Path=filename, file=data_folder + filename, storage=storage)
try:
#invoke Aspose.Words Cloud SDK API to execute mail merge and populate a word document from XML data
response = wordsApi.PostDocumentExecuteMailMerge(name=filename, withRegions=True, file=data_folder + filedataname, filename=destfilename, storage=storage)
if response.Status == "OK":
print "mail merge template has been executed successfully"
#download updated document from storage server
response = storageApi.GetDownload(Path=destfilename, storage=storage)
outfilename = "c:/temp/" + destfilename
with open(outfilename, 'wb') as f:
for chunk in response.InputStream:
f.write(chunk)
except ApiException as ex:
print "ApiException:"
print "Code:" + str(ex.code)
print "Message:" + ex.message
import asposewordscloud
from asposewordscloud.WordsApi import WordsApi
from asposewordscloud.WordsApi import ApiException
from asposewordscloud.models import SectionPageSetupResponse
import asposestoragecloud
from asposestoragecloud.StorageApi import StorageApi
from asposestoragecloud.StorageApi import ResponseMessage
apiKey = "XXXXX" #sepcify App Key
appSid = "XXXXX" #sepcify App SID
apiServer = "http://api.aspose.com/v1.1"
data_folder = "../../data/"
#Instantiate Aspose Storage API SDK
storage_apiClient = asposestoragecloud.ApiClient.ApiClient(apiKey, appSid, True)
storageApi = StorageApi(storage_apiClient)
#Instantiate Aspose Words API SDK
api_client = asposewordscloud.ApiClient.ApiClient(apiKey, appSid, True)
wordsApi = WordsApi(api_client)
#set input file name
filename = "SampleExecuteTemplate.docx"
sectionIndex = 0
#upload file to aspose cloud storage
storageApi.PutCreate(Path=filename, file=data_folder + filename)
try:
#invoke Aspose.Words Cloud SDK API to get page setup properties by given section index from a word document
response = wordsApi.GetSectionPageSetup(name=filename, sectionIndex=sectionIndex)
if response.Status == "OK":
secPageSetup = response.PageSetup
if(secPageSetup is not None):
#display section page setup info
print "PaperSize :" + response.PageSetup.PaperSize + " Orientation: " + response.PageSetup.Orientation
except ApiException as ex:
print "ApiException:"
print "Code:" + str(ex.code)
print "Message:" + ex.message
import asposewordscloud
from asposewordscloud.WordsApi import WordsApi
from asposewordscloud.WordsApi import ApiException
from asposewordscloud.models import ProtectionRequest
import asposestoragecloud
from asposestoragecloud.StorageApi import StorageApi
from asposestoragecloud.StorageApi import ResponseMessage
apiKey = "XXXXX" #sepcify App Key
appSid = "XXXXX" #sepcify App SID
apiServer = "http://api.aspose.com/v1.1"
data_folder = "../../data/"
#Instantiate Aspose Storage API SDK
storage_apiClient = asposestoragecloud.ApiClient.ApiClient(apiKey, appSid, True)
storageApi = StorageApi(storage_apiClient)
#Instantiate Aspose Words API SDK
api_client = asposewordscloud.ApiClient.ApiClient(apiKey, appSid, True)
wordsApi = WordsApi(api_client)
#set input file name
filename = "SampleWordDocument.docx"
#upload file to aspose cloud storage
storageApi.PutCreate(Path=filename, file=data_folder + filename)
try:
#invoke Aspose.Words Cloud SDK API to get all the bookmarks from a word document
response = wordsApi.GetDocumentBookmarks(name=filename)
if response.Status == "OK":
#display the bookmarks info
for bookmark in response.Bookmarks.BookmarkList:
print "Name: " + bookmark.Name + " Text: " + bookmark.Text + " link: " + bookmark.link.Href
except ApiException as ex:
print "ApiException:"
print "Code:" + str(ex.code)
print "Message:" + ex.message
import asposewordscloud
from asposewordscloud.WordsApi import WordsApi
from asposewordscloud.WordsApi import ApiException
from asposewordscloud.models import ProtectionRequest
import asposestoragecloud
from asposestoragecloud.StorageApi import StorageApi
from asposestoragecloud.StorageApi import ResponseMessage
apiKey = "XXXXX" #sepcify App Key
appSid = "XXXXX" #sepcify App SID
apiServer = "http://api.aspose.com/v1.1"
data_folder = "../../data/"
#Instantiate Aspose Storage API SDK
storage_apiClient = asposestoragecloud.ApiClient.ApiClient(apiKey, appSid, True)
storageApi = StorageApi(storage_apiClient)
#Instantiate Aspose Words API SDK
api_client = asposewordscloud.ApiClient.ApiClient(apiKey, appSid, True)
wordsApi = WordsApi(api_client)
#set input file name
filename = "SampleWordDocument.docx"
#upload file to aspose cloud storage
storageApi.PutCreate(Path=filename, file=data_folder + filename)
try:
#invoke Aspose.Words Cloud SDK API to get all document properties from a word document
response = wordsApi.GetDocumentProperties(name=filename)
if response.Status == "OK":
#display document property info
for docProperty in response.DocumentProperties.List:
print docProperty.Name + " : " + docProperty.Value
except ApiException as ex:
print "ApiException:"
print "Code:" + str(ex.code)
print "Message:" + ex.message
import asposewordscloud
from asposewordscloud.WordsApi import WordsApi
from asposewordscloud.WordsApi import ApiException
from asposewordscloud.models import FormField
from asposewordscloud.models import FormFieldResponse
import asposestoragecloud
from asposestoragecloud.StorageApi import StorageApi
from asposestoragecloud.StorageApi import ResponseMessage
apiKey = "XXXXX" #sepcify App Key
appSid = "XXXXX" #sepcify App SID
apiServer = "http://api.aspose.com/v1.1"
data_folder = "../../data/"
#Instantiate Aspose Storage API SDK
storage_apiClient = asposestoragecloud.ApiClient.ApiClient(apiKey, appSid, True)
storageApi = StorageApi(storage_apiClient)
#Instantiate Aspose Words API SDK
api_client = asposewordscloud.ApiClient.ApiClient(apiKey, appSid, True)
wordsApi = WordsApi(api_client)
#set input file name
filename = "SampleMailMergeTemplate.docx"
#upload file to aspose cloud storage
storageApi.PutCreate(Path=filename, file=data_folder + filename)
try:
#invoke Aspose.Words Cloud SDK API to get merge field names from a word document
response = wordsApi.GetDocumentFieldNames(name=filename)
if response.Status == "OK":
#Get all merge field names from document
for fieldName in response.FieldNames.Names:
print fieldName
except ApiException as ex:
print "ApiException:"
print "Code:" + str(ex.code)
print "Message:" + ex.message
import asposewordscloud
from asposewordscloud.WordsApi import WordsApi
from asposewordscloud.WordsApi import ApiException
from asposewordscloud.models import SectionResponse
import asposestoragecloud
from asposestoragecloud.StorageApi import StorageApi
from asposestoragecloud.StorageApi import ResponseMessage
apiKey = "XXXXX" #sepcify App Key
appSid = "XXXXX" #sepcify App SID
apiServer = "http://api.aspose.com/v1.1"
data_folder = "../../data/"
#Instantiate Aspose Storage API SDK
storage_apiClient = asposestoragecloud.ApiClient.ApiClient(apiKey, appSid, True)
storageApi = StorageApi(storage_apiClient)
#Instantiate Aspose Words API SDK
api_client = asposewordscloud.ApiClient.ApiClient(apiKey, appSid, True)
wordsApi = WordsApi(api_client)
#set input file name
filename = "SampleWordDocument.docx"
#upload file to aspose cloud storage
storageApi.PutCreate(Path=filename, file=data_folder + filename)
sectionIndex = 0
try:
#invoke Aspose.Words Cloud SDK API to get a specific section present from a word document
response = wordsApi.GetSection(name=filename, sectionIndex=sectionIndex)
if response.Status == "OK":
#get section href
print "Section Href :: " + response.Section.link.Href
except ApiException as ex:
print "ApiException:"
print "Code:" + str(ex.code)
print "Message:" + ex.message
import asposewordscloud
from asposewordscloud.WordsApi import WordsApi
from asposewordscloud.WordsApi import ApiException
from asposewordscloud.models import ProtectionDataResponse
import asposestoragecloud
from asposestoragecloud.StorageApi import StorageApi
from asposestoragecloud.StorageApi import ResponseMessage
from pip._vendor.pkg_resources import null_ns_handler
apiKey = "XXXXX" #sepcify App Key
appSid = "XXXXX" #sepcify App SID
apiServer = "http://api.aspose.com/v1.1"
data_folder = "../../data/"
#Instantiate Aspose Storage API SDK
storage_apiClient = asposestoragecloud.ApiClient.ApiClient(apiKey, appSid, True)
storageApi = StorageApi(storage_apiClient)
#Instantiate Aspose Words API SDK
api_client = asposewordscloud.ApiClient.ApiClient(apiKey, appSid, True)
wordsApi = WordsApi(api_client)
#set input file name
filename = "SampleWordDocument.docx"
#upload file to aspose cloud storage
storageApi.PutCreate(Path=filename, file=data_folder + filename)
try:
#invoke Aspose.Words Cloud SDK API to get current protection of a word document
response = wordsApi.GetDocumentProtection(name=filename)
if response.Status == "OK":
docProtectionData = response.ProtectionData
#display document protection info
if docProtectionData is not None:
print "Protection Type: " + docProtectionData.ProtectionType
except ApiException as ex:
print "ApiException:"
print "Code:" + str(ex.code)
print "Message:" + ex.message
import asposewordscloud
from asposewordscloud.WordsApi import WordsApi
from asposewordscloud.WordsApi import ApiException
from asposewordscloud.models import FontResponse
import asposestoragecloud
from asposestoragecloud.StorageApi import StorageApi
from asposestoragecloud.StorageApi import ResponseMessage
apiKey = "XXXXX" #sepcify App Key
appSid = "XXXXX" #sepcify App SID
apiServer = "http://api.aspose.com/v1.1"
data_folder = "../../data/"
#Instantiate Aspose Storage API SDK
storage_apiClient = asposestoragecloud.ApiClient.ApiClient(apiKey, appSid, True)
storageApi = StorageApi(storage_apiClient)
#Instantiate Aspose Words API SDK
api_client = asposewordscloud.ApiClient.ApiClient(apiKey, appSid, True)
wordsApi = WordsApi(api_client)
#set input file name
filename = "SampleWordDocument.docx"
index = 1
runIndex = 0
#upload file to aspose cloud storage
storageApi.PutCreate(Path=filename, file=data_folder + filename)
try:
#invoke Aspose.Words Cloud SDK API to get a font related information of a specific run of a paragraph from a word document
response = wordsApi.GetDocumentParagraphRunFont(name=filename, index=index, runIndex=runIndex)
if response.Status == "OK":
runFont = response.Font
#display run font info
if runFont is not None:
print "Font Name : " + runFont.Name
print "Style : " + runFont.StyleName
print "Size : " + str(runFont.Size)
except ApiException as ex:
print "ApiException:"
print "Code:" + str(ex.code)
print "Message:" + ex.message
import asposewordscloud
from asposewordscloud.WordsApi import WordsApi
from asposewordscloud.WordsApi import ApiException
from asposewordscloud.models import ParagraphLinkCollectionResponse
import asposestoragecloud
from asposestoragecloud.StorageApi import StorageApi
from asposestoragecloud.StorageApi import ResponseMessage
apiKey = "XXXXX" #sepcify App Key
appSid = "XXXXX" #sepcify App SID
apiServer = "http://api.aspose.com/v1.1"
data_folder = "../../data/"
#Instantiate Aspose Storage API SDK
storage_apiClient = asposestoragecloud.ApiClient.ApiClient(apiKey, appSid, True)
storageApi = StorageApi(storage_apiClient)
#Instantiate Aspose Words API SDK
api_client = asposewordscloud.ApiClient.ApiClient(apiKey, appSid, True)
wordsApi = WordsApi(api_client)
#set input file name
filename = "SampleWordDocument.docx"
#upload file to aspose cloud storage
storageApi.PutCreate(Path=filename, file=data_folder + filename)
try:
#invoke Aspose.Words Cloud SDK API to get list of paragraphs from a word document
response = wordsApi.GetDocumentParagraphs(name=filename)
if response.Status == "OK":
#docProperty = response.Paragraphs.ParagraphLinkList[0]
#display document paragraphs info
for docParagraphLink in response.Paragraphs.ParagraphLinkList:
print "Link Href: " + docParagraphLink.link.Href
print "Text : " + docParagraphLink.Text
except ApiException as ex:
print "ApiException:"
print "Code:" + str(ex.code)
print "Message:" + ex.message
import asposewordscloud
from asposewordscloud.WordsApi import WordsApi
from asposewordscloud.WordsApi import ApiException
from asposewordscloud.models import SectionLinkCollectionResponse
import asposestoragecloud
from asposestoragecloud.StorageApi import StorageApi
from asposestoragecloud.StorageApi import ResponseMessage
apiKey = "XXXXX" #sepcify App Key
appSid = "XXXXX" #sepcify App SID
apiServer = "http://api.aspose.com/v1.1"
data_folder = "../../data/"
#Instantiate Aspose Storage API SDK
storage_apiClient = asposestoragecloud.ApiClient.ApiClient(apiKey, appSid, True)
storageApi = StorageApi(storage_apiClient)
#Instantiate Aspose Words API SDK
api_client = asposewordscloud.ApiClient.ApiClient(apiKey, appSid, True)
wordsApi = WordsApi(api_client)
#set input file name
filename = "SampleWordDocument.docx"
#upload file to aspose cloud storage
storageApi.PutCreate(Path=filename, file=data_folder + filename)
try:
#invoke Aspose.Words Cloud SDK API to get list of all sections present from a word document
response = wordsApi.GetSections(name=filename);
if response.Status == "OK":
#get sections href
for sectionLink in response.Sections.SectionLinkList:
print "Section Href :: " + sectionLink.link.Href
except ApiException as ex:
print "ApiException:"
print "Code:" + str(ex.code)
print "Message:" + ex.message
import asposewordscloud
from asposewordscloud.WordsApi import WordsApi
from asposewordscloud.WordsApi import ApiException
from asposewordscloud.models import DrawingObjectsResponse
import asposestoragecloud
from asposestoragecloud.StorageApi import StorageApi
from asposestoragecloud.StorageApi import ResponseMessage
apiKey = "XXXXX" #sepcify App Key
appSid = "XXXXX" #sepcify App SID
apiServer = "http://api.aspose.com/v1.1"
data_folder = "../../data/"
#Instantiate Aspose Storage API SDK
storage_apiClient = asposestoragecloud.ApiClient.ApiClient(apiKey, appSid, True)
storageApi = StorageApi(storage_apiClient)
#Instantiate Aspose Words API SDK
api_client = asposewordscloud.ApiClient.ApiClient(apiKey, appSid, True)
wordsApi = WordsApi(api_client)
#set input file name
filename = "SampleOlePdfData.docx"
objectIndex = 0
#upload file to aspose cloud storage
storageApi.PutCreate(Path=filename, file=data_folder + filename)
try:
#invoke Aspose.Words Cloud SDK API to get ole drawing object by index in a word document
response = wordsApi.GetDocumentDrawingObjectOleData(name=filename, objectIndex=objectIndex)
if response.Status == "OK":
destfilename = "OLEDrawingObject_"+ str(objectIndex) + ".pdf"
with open("c:/temp/" +destfilename, 'wb') as f:
for chunk in response.InputStream:
f.write(chunk)
except ApiException as ex:
print "ApiException:"
print "Code:" + str(ex.code)
print "Message:" + ex.message
import asposewordscloud
from asposewordscloud.WordsApi import WordsApi
from asposewordscloud.WordsApi import ApiException
from asposewordscloud.models import ParagraphLinkCollectionResponse
import asposestoragecloud
from asposestoragecloud.StorageApi import StorageApi
from asposestoragecloud.StorageApi import ResponseMessage
apiKey = "XXXXX" #sepcify App Key
appSid = "XXXXX" #sepcify App SID
apiServer = "http://api.aspose.com/v1.1"
data_folder = "../../data/"
#Instantiate Aspose Storage API SDK
storage_apiClient = asposestoragecloud.ApiClient.ApiClient(apiKey, appSid, True)
storageApi = StorageApi(storage_apiClient)
#Instantiate Aspose Words API SDK
api_client = asposewordscloud.ApiClient.ApiClient(apiKey, appSid, True)
wordsApi = WordsApi(api_client)
#set input file name
filename = "SampleWordDocument.docx"
index = 1
#upload file to aspose cloud storage
storageApi.PutCreate(Path=filename, file=data_folder + filename)
try:
#invoke Aspose.Words Cloud SDK API to get a specific paragraph from a word document
response = wordsApi.GetDocumentParagraph(name=filename, index=index)
if response.Status == "OK":
docParagraph = response.Paragraph
#display document paragraph info
if docParagraph is not None:
print "NoteId : " + docParagraph.NodeId
print "Link : " + docParagraph.link.Href
except ApiException as ex:
print "ApiException:"
print "Code:" + str(ex.code)
print "Message:" + ex.message
import asposewordscloud
from asposewordscloud.WordsApi import WordsApi
from asposewordscloud.WordsApi import ApiException
from asposewordscloud.models import ProtectionRequest
import asposestoragecloud
from asposestoragecloud.StorageApi import StorageApi
from asposestoragecloud.StorageApi import ResponseMessage
apiKey = "XXXXX" #sepcify App Key
appSid = "XXXXX" #sepcify App SID
apiServer = "http://api.aspose.com/v1.1"
data_folder = "../../data/"
\#Instantiate Aspose Storage API SDK
storage_apiClient = asposestoragecloud.ApiClient.ApiClient(apiKey, appSid, True)
storageApi = StorageApi(storage_apiClient)
\#Instantiate Aspose Words API SDK
api_client = asposewordscloud.ApiClient.ApiClient(apiKey, appSid, True)
wordsApi = WordsApi(api_client)
\#set input file name
filename = "SampleWordDocument.docx"
propertyName = "AsposeAuthor"
\#upload file to aspose cloud storage
storageApi.PutCreate(Path=filename, file=data_folder + filename)
try:
\#invoke Aspose.Words Cloud SDK API to get document property by given name from a word document
response = wordsApi.GetDocumentProperty(name=filename, propertyName=propertyName)
if response.Status == "OK":
\#display document property info
print response.DocumentProperty.Name + " : " + response.DocumentProperty.Value
except ApiException as ex:
print "ApiException:"
print "Code:" + str(ex.code)
print "Message:" + ex.message
import asposewordscloud
from asposewordscloud.WordsApi import WordsApi
from asposewordscloud.WordsApi import ApiException
from asposewordscloud.models import RunResponse
import asposestoragecloud
from asposestoragecloud.StorageApi import StorageApi
from asposestoragecloud.StorageApi import ResponseMessage
apiKey = "XXXXX" #sepcify App Key
appSid = "XXXXX" #sepcify App SID
apiServer = "http://api.aspose.com/v1.1"
data_folder = "../../data/"
#Instantiate Aspose Storage API SDK
storage_apiClient = asposestoragecloud.ApiClient.ApiClient(apiKey, appSid, True)
storageApi = StorageApi(storage_apiClient)
#Instantiate Aspose Words API SDK
api_client = asposewordscloud.ApiClient.ApiClient(apiKey, appSid, True)
wordsApi = WordsApi(api_client)
#set input file name
filename = "SampleWordDocument.docx"
index = 1
runIndex = 0
#upload file to aspose cloud storage
storageApi.PutCreate(Path=filename, file=data_folder + filename)
try:
#invoke Aspose.Words Cloud SDK API to get a specific run of a paragraph from a word document
response = wordsApi.GetDocumentParagraphRun(name=filename, index=index, runIndex=runIndex)
if response.Status == "OK":
docParagraphRun = response.Run
#display document paragraph run info
if docParagraphRun is not None:
print "NoteId : " + docParagraphRun.NodeId
print "Text : " + docParagraphRun.Text
except ApiException as ex:
print "ApiException:"
print "Code:" + str(ex.code)
print "Message:" + ex.message
import asposewordscloud
from asposewordscloud.WordsApi import WordsApi
from asposewordscloud.WordsApi import ApiException
from asposewordscloud.models import ProtectionRequest
import asposestoragecloud
from asposestoragecloud.StorageApi import StorageApi
from asposestoragecloud.StorageApi import ResponseMessage
apiKey = "XXXXX" #sepcify App Key
appSid = "XXXXX" #sepcify App SID
apiServer = "http://api.aspose.com/v1.1"
data_folder = "../../data/"
#Instantiate Aspose Storage API SDK
storage_apiClient = asposestoragecloud.ApiClient.ApiClient(apiKey, appSid, True)
storageApi = StorageApi(storage_apiClient)
#Instantiate Aspose Words API SDK
api_client = asposewordscloud.ApiClient.ApiClient(apiKey, appSid, True)
wordsApi = WordsApi(api_client)
#set input file name
filename = "SampleWordDocument.docx"
#upload file to aspose cloud storage
storageApi.PutCreate(Path=filename, file=data_folder + filename)
try:
#invoke Aspose.Words Cloud SDK API to get text items from a word document
response = wordsApi.GetDocumentTextItems(name=filename)
if response.Status == "OK":
#get all the TextItem's text
for textItem in response.TextItems.List:
print textItem.Text
except ApiException as ex:
print "ApiException:"
print "Code:" + str(ex.code)
print "Message:" + ex.message
import asposewordscloud
from asposewordscloud.WordsApi import WordsApi
from asposewordscloud.WordsApi import ApiException
from asposewordscloud.models import DrawingObjectsResponse
import asposestoragecloud
from asposestoragecloud.StorageApi import StorageApi
from asposestoragecloud.StorageApi import ResponseMessage
apiKey = "XXXXX" #sepcify App Key
appSid = "XXXXX" #sepcify App SID
apiServer = "http://api.aspose.com/v1.1"
data_folder = "../../data/"
#Instantiate Aspose Storage API SDK
storage_apiClient = asposestoragecloud.ApiClient.ApiClient(apiKey, appSid, True)
storageApi = StorageApi(storage_apiClient)
#Instantiate Aspose Words API SDK
api_client = asposewordscloud.ApiClient.ApiClient(apiKey, appSid, True)
wordsApi = WordsApi(api_client)
#set input file name
filename = "SampleWordDocument.docx"
#upload file to aspose cloud storage
storageApi.PutCreate(Path=filename, file=data_folder + filename)
try:
#invoke Aspose.Words Cloud SDK API to get list of all drawing objects present in a word document
response = wordsApi.GetDocumentDrawingObjects(name=filename)
if response.Status == "OK":
#export all drawing objects to PNG
objectIndex = 0
for item in response.DrawingObjects.List:
pngImageDataRes = wordsApi.GetDocumentDrawingObjectByIndexWithFormat(name=filename, objectIndex=objectIndex, format="png");
destfilename = "DrawingObject_" + str(objectIndex) + ".png";
outfilename = "c:/temp/" + destfilename
with open(outfilename, 'wb') as f:
for chunk in pngImageDataRes.InputStream:
f.write(chunk)
objectIndex = objectIndex + 1
except ApiException as ex:
print "ApiException:"
print "Code:" + str(ex.code)
print "Message:" + ex.message
import asposewordscloud
from asposewordscloud.WordsApi import WordsApi
from asposewordscloud.WordsApi import ApiException
from asposewordscloud.models import FormField
from asposewordscloud.models import FormFieldResponse
import asposestoragecloud
from asposestoragecloud.StorageApi import StorageApi
from asposestoragecloud.StorageApi import ResponseMessage
apiKey = "XXXXX" #sepcify App Key
appSid = "XXXXX" #sepcify App SID
apiServer = "http://api.aspose.com/v1.1"
data_folder = "../../data/"
#Instantiate Aspose Storage API SDK
storage_apiClient = asposestoragecloud.ApiClient.ApiClient(apiKey, appSid, True)
storageApi = StorageApi(storage_apiClient)
#Instantiate Aspose Words API SDK
api_client = asposewordscloud.ApiClient.ApiClient(apiKey, appSid, True)
wordsApi = WordsApi(api_client)
#set input file name
filename = "SampleMailMergeTemplate.docx"
#upload file to aspose cloud storage
storageApi.PutCreate(Path=filename, file=data_folder + filename)
try:
#invoke Aspose.Words Cloud SDK API to get merge field names from a word document
response = wordsApi.GetDocumentFieldNames(name=filename)
if response.Status == "OK":
#Get all merge field names from document
for fieldName in response.FieldNames.Names:
print fieldName
except ApiException as ex:
print "ApiException:"
print "Code:" + str(ex.code)
print "Message:" + ex.message
import asposewordscloud
from asposewordscloud.WordsApi import WordsApi
from asposewordscloud.WordsApi import ApiException
from asposewordscloud.models import ProtectionRequest
import asposestoragecloud
from asposestoragecloud.StorageApi import StorageApi
from asposestoragecloud.StorageApi import ResponseMessage
apiKey = "XXXXX" #sepcify App Key
appSid = "XXXXX" #sepcify App SID
apiServer = "http://api.aspose.com/v1.1"
data_folder = "../../data/"
#Instantiate Aspose Storage API SDK
storage_apiClient = asposestoragecloud.ApiClient.ApiClient(apiKey, appSid, True)
storageApi = StorageApi(storage_apiClient)
#Instantiate Aspose Words API SDK
api_client = asposewordscloud.ApiClient.ApiClient(apiKey, appSid, True)
wordsApi = WordsApi(api_client)
#set input file name
filename = "SampleWordDocument.docx"
#upload file to aspose cloud storage
storageApi.PutCreate(Path=filename, file=data_folder + filename)
try:
#invoke Aspose.Words Cloud SDK API to get all the bookmarks from a word document
response = wordsApi.GetDocumentBookmarks(name=filename)
if response.Status == "OK":
#display the bookmarks info
for bookmark in response.Bookmarks.BookmarkList:
print "Name: " + bookmark.Name + " Text: " + bookmark.Text + " link: " + bookmark.link.Href
except ApiException as ex:
print "ApiException:"
print "Code:" + str(ex.code)
print "Message:" + ex.message
import asposewordscloud
from asposewordscloud.WordsApi import WordsApi
from asposewordscloud.models import StatDataResponse
import asposestoragecloud
from asposestoragecloud.StorageApi import StorageApi
from asposestoragecloud.StorageApi import ResponseMessage
apiKey = "XXXXX" #sepcify App Key
appSid = "XXXXX" #sepcify App SID
apiServer = "http://api.aspose.com/v1.1"
data_folder = "../../data/"
#Instantiate Aspose Storage API SDK
storage_apiClient = asposestoragecloud.ApiClient.ApiClient(apiKey, appSid, True)
storageApi = StorageApi(storage_apiClient)
#Instantiate Aspose Words API SDK
api_client = asposewordscloud.ApiClient.ApiClient(apiKey, appSid, True)
wordsApi = WordsApi(api_client)
#set input file name
filename = "SampleWordDocument.docx"
#upload file to aspose cloud storage
storageApi.PutCreate(Path=filename, file=data_folder + filename)
#invoke Aspose.Words Cloud SDK API to get document statistics
response = wordsApi.GetDocumentStatistics(filename)
if(response.Status == "OK"):
print "Total Words: " + str(response.StatData.WordCount);
print "Total Paragraphs: " + str(response.StatData.ParagraphCount);
print "Total Page Count: " + str(response.StatData.PageCount);
for pageStat in response.StatData.PageStatData:
print "Page# " + str(pageStat.PageNumber)
print "Page Word Count: " + str(pageStat.WordCount)
print "Page Paragraph Count: " + str(pageStat.ParagraphCount)
import asposewordscloud
from asposewordscloud.WordsApi import WordsApi
from asposewordscloud.WordsApi import ApiException
from asposewordscloud.models import ProtectionRequest
import asposestoragecloud
from asposestoragecloud.StorageApi import StorageApi
from asposestoragecloud.StorageApi import ResponseMessage
apiKey = "XXXXX" #sepcify App Key
appSid = "XXXXX" #sepcify App SID
apiServer = "http://api.aspose.com/v1.1"
data_folder = "../../data/"
#Instantiate Aspose Storage API SDK
storage_apiClient = asposestoragecloud.ApiClient.ApiClient(apiKey, appSid, True)
storageApi = StorageApi(storage_apiClient)
#Instantiate Aspose Words API SDK
api_client = asposewordscloud.ApiClient.ApiClient(apiKey, appSid, True)
wordsApi = WordsApi(api_client)
#set input file name
filename = "SampleMailMergeTemplateImage.doc"
destfilename = "updated-" + filename
#set input file data name
filedataname = "SampleMailMergeTemplateImageData.txt"
logofile = "header-logo.png"
#upload file to aspose cloud storage
storageApi.PutCreate(Path=filename, file=data_folder + filename)
storageApi.PutCreate(Path=logofile, file=data_folder + logofile)
try:
#invoke Aspose.Words Cloud SDK API to execute mail merge and populate a word document from XML data
response = wordsApi.PostDocumentExecuteMailMerge(name=filename, withRegions=False, file=data_folder + filedataname, filename=destfilename, useWholeParagraphAsRegion=False)
if response.Status == "OK":
print "mail merge template has been executed successfully"
#download updated document from storage server
response = storageApi.GetDownload(Path=destfilename)
outfilename = "c:/temp/" + destfilename
with open(outfilename, 'wb') as f:
for chunk in response.InputStream:
f.write(chunk)
except ApiException as ex:
print "ApiException:"
print "Code:" + str(ex.code)
print "Message:" + ex.message
import asposewordscloud
from asposewordscloud.WordsApi import WordsApi
from asposewordscloud.WordsApi import ApiException
from asposewordscloud.models import PageNumber
from asposewordscloud.models import DocumentResponse
import asposestoragecloud
from asposestoragecloud.StorageApi import StorageApi
from asposestoragecloud.StorageApi import ResponseMessage
apiKey = "XXXXX" #sepcify App Key
appSid = "XXXXX" #sepcify App SID
apiServer = "http://api.aspose.com/v1.1"
data_folder = "../../data/"
#Instantiate Aspose Storage API SDK
storage_apiClient = asposestoragecloud.ApiClient.ApiClient(apiKey, appSid, True)
storageApi = StorageApi(storage_apiClient)
#Instantiate Aspose Words API SDK
api_client = asposewordscloud.ApiClient.ApiClient(apiKey, appSid, True)
wordsApi = WordsApi(api_client)
#set input file name
filename = "SampleWordDocument.docx"
#configure third party storage name
storage = "AsposeDropboxStorage"
body = PageNumber.PageNumber()
body.Format = "{PAGE} of {NUMPAGES}"
body.Alignment = "center"
#upload file to aspose cloud storage
storageApi.PutCreate(Path=filename, file=data_folder + filename, storage=storage)
try:
#invoke Aspose.Words Cloud SDK API to insert page number field into a word document
response = wordsApi.PostInsertPageNumbers(name=filename, body=body, storage=storage)
if response.Status == "OK":
print "Page Number Field has been inserted successfully"
#download updated document from storage server
response = storageApi.GetDownload(Path=filename, storage=storage)
outfilename = "c:/temp/" + filename
with open(outfilename, 'wb') as f:
for chunk in response.InputStream:
f.write(chunk)
except ApiException as ex:
print "ApiException:"
print "Code:" + str(ex.code)
print "Message:" + ex.message
import asposewordscloud
from asposewordscloud.WordsApi import WordsApi
from asposewordscloud.WordsApi import ApiException
from asposewordscloud.models import PageNumber
from asposewordscloud.models import DocumentResponse
import asposestoragecloud
from asposestoragecloud.StorageApi import StorageApi
from asposestoragecloud.StorageApi import ResponseMessage
apiKey = "XXXXX" #sepcify App Key
appSid = "XXXXX" #sepcify App SID
apiServer = "http://api.aspose.com/v1.1"
data_folder = "../../data/"
#Instantiate Aspose Storage API SDK
storage_apiClient = asposestoragecloud.ApiClient.ApiClient(apiKey, appSid, True)
storageApi = StorageApi(storage_apiClient)
#Instantiate Aspose Words API SDK
api_client = asposewordscloud.ApiClient.ApiClient(apiKey, appSid, True)
wordsApi = WordsApi(api_client)
#set input file name
filename = "SampleWordDocument.docx"
body = PageNumber.PageNumber()
body.Format = "{PAGE} of {NUMPAGES}"
body.Alignment = "center"
#upload file to aspose cloud storage
storageApi.PutCreate(Path=filename, file=data_folder + filename)
try:
#invoke Aspose.Words Cloud SDK API to insert page number field into a word document
response = wordsApi.PostInsertPageNumbers(name=filename, body=body)
if response.Status == "OK":
print "Page Number Field has been inserted successfully"
#download updated document from storage server
response = storageApi.GetDownload(Path=filename)
outfilename = "c:/temp/" + filename
with open(outfilename, 'wb') as f:
for chunk in response.InputStream:
f.write(chunk)
except ApiException as ex:
print "ApiException:"
print "Code:" + str(ex.code)
print "Message:" + ex.message
import asposewordscloud
from asposewordscloud.WordsApi import WordsApi
from asposewordscloud.WordsApi import ApiException
from asposewordscloud.models import ProtectionRequest
import asposestoragecloud
from asposestoragecloud.StorageApi import StorageApi
from asposestoragecloud.StorageApi import ResponseMessage
apiKey = "XXXXX" #sepcify App Key
appSid = "XXXXX" #sepcify App SID
apiServer = "http://api.aspose.com/v1.1"
data_folder = "../../data/"
#Instantiate Aspose Storage API SDK
storage_apiClient = asposestoragecloud.ApiClient.ApiClient(apiKey, appSid, True)
storageApi = StorageApi(storage_apiClient)
#Instantiate Aspose Words API SDK
api_client = asposewordscloud.ApiClient.ApiClient(apiKey, appSid, True)
wordsApi = WordsApi(api_client)
#set input file name
filename = "SampleProtectedBlankWordDocument.docx"
destfilename = filename
body = ProtectionRequest.ProtectionRequest()
body.Password = "aspose"
body.NewPassword = ""
body.ProtectionType = "NoProtection"
#upload file to aspose cloud storage
storageApi.PutCreate(Path=filename, file=data_folder + filename)
try:
#invoke Aspose.Words Cloud SDK API to unprotect a word document
response = wordsApi.PostChangeDocumentProtection(name=filename, body=body)
if response.Status == "OK":
print "Document protection property has been changed from protected to unprotected successfully"
#download updated document from storage server
response = storageApi.GetDownload(Path=destfilename)
outfilename = "c:/temp/" + destfilename
with open(outfilename, 'wb') as f:
for chunk in response.InputStream:
f.write(chunk)
except ApiException as ex:
print "ApiException:"
print "Code:" + str(ex.code)
print "Message:" + ex.message
import asposewordscloud
from asposewordscloud.WordsApi import WordsApi
from asposewordscloud.WordsApi import ApiException
from asposewordscloud.models import LoadWebDocumentData
from asposewordscloud.models import SaveOptionsData
import asposestoragecloud
from asposestoragecloud.StorageApi import StorageApi
from asposestoragecloud.StorageApi import ResponseMessage
apiKey = "XXXXX" #sepcify App Key
appSid = "XXXXX" #sepcify App SID
apiServer = "http://api.aspose.com/v1.1"
data_folder = "../../data/"
try:
#Instantiate Aspose Storage API SDK
storage_apiClient = asposestoragecloud.ApiClient.ApiClient(apiKey, appSid, True)
storageApi = StorageApi(storage_apiClient)
#Instantiate Aspose Words API SDK
api_client = asposewordscloud.ApiClient.ApiClient(apiKey, appSid, True)
wordsApi = WordsApi(api_client);
#set output file name
filename ="WebPageConverterExample.doc"
loadWebDocumentData = LoadWebDocumentData.LoadWebDocumentData()
loadWebDocumentData.LoadingDocumentUrl = "http://www.aspose.com/corporate/default.aspx"
saveOptionsData = SaveOptionsData.SaveOptionsData()
saveOptionsData.FileName = filename
saveOptionsData.SaveFormat = "doc"
loadWebDocumentData.SaveOptions=saveOptionsData
#invoke Aspose.Words Cloud SDK API to convert live web page into words document
response = wordsApi.PostLoadWebDocument(body=loadWebDocumentData)
if(response.Status == 'OK'):
print "Document has been generated successfully"
#download output document from storage server
response = storageApi.GetDownload(Path=filename)
outfilename = "c:/temp/" + filename
with open(outfilename, 'wb') as f:
for chunk in response.InputStream:
f.write(chunk)
except ApiException as ex:
print "ApiException:"
print "Code:" + str(ex.code)
print "Message:" + ex.message
import asposewordscloud
from asposewordscloud.WordsApi import WordsApi
from asposewordscloud.WordsApi import ApiException
from asposewordscloud.models import ProtectionRequest
import asposestoragecloud
from asposestoragecloud.StorageApi import StorageApi
from asposestoragecloud.StorageApi import ResponseMessage
apiKey = "XXXXX" #sepcify App Key
appSid = "XXXXX" #sepcify App SID
apiServer = "http://api.aspose.com/v1.1"
data_folder = "../../data/"
#Instantiate Aspose Storage API SDK
storage_apiClient = asposestoragecloud.ApiClient.ApiClient(apiKey, appSid, True)
storageApi = StorageApi(storage_apiClient)
#Instantiate Aspose Words API SDK
api_client = asposewordscloud.ApiClient.ApiClient(apiKey, appSid, True)
wordsApi = WordsApi(api_client)
#set input file name
filename = "SampleBlankWordDocument.docx"
destfilename = "updated-" + filename
body = ProtectionRequest.ProtectionRequest()
body.Password = "aspose"
body.ProtectionType = "ReadOnly"
#upload file to aspose cloud storage
storageApi.PutCreate(Path=filename, file=data_folder + filename)
try:
#invoke Aspose.Words Cloud SDK API to protect a word document
response = wordsApi.PutProtectDocument(name=filename, body=body, filename=destfilename)
if response.Status == "OK":
print "Document has been protected successfully"
#download updated document from storage server
response = storageApi.GetDownload(Path=destfilename)
outfilename = "c:/temp/" + destfilename
with open(outfilename, 'wb') as f:
for chunk in response.InputStream:
f.write(chunk)
except ApiException as ex:
print "ApiException:"
print "Code:" + str(ex.code)
print "Message:" + ex.message
import asposewordscloud
from asposewordscloud.WordsApi import WordsApi
from asposewordscloud.WordsApi import ApiException
from asposewordscloud.models import ResponseMessage
apiKey = "XXXXX" #sepcify App Key
appSid = "XXXXX" #sepcify App SID
apiServer = "http://api.aspose.com/v1.1"
data_folder = "../../data/"
try:
#Instantiate Aspose Words API SDK
apiClient = asposewordscloud.ApiClient.ApiClient(apiKey, appSid, debug=True)
wordsApi = WordsApi(apiClient);
#set input file name
name = "SampleWordDocument"
filename = name + ".docx"
format = "pdf"
#invoke Aspose.Words Cloud SDK API to convert words document to required format using file
response = wordsApi.PutConvertDocument(file=data_folder + filename, format="pdf")
if(response.Status == "OK"):
outfilename = "c:/temp/" + name + "." + format
with open(outfilename, 'wb') as f:
for chunk in response.InputStream:
f.write(chunk)
except ApiException as ex:
print "ApiException:"
print "Code:" + str(ex.code)
print "Message:" + ex.message
import asposewordscloud
from asposewordscloud.WordsApi import WordsApi
from asposewordscloud.models import SaveOptionsData
from asposewordscloud.models import SaveResult
import asposestoragecloud
from asposestoragecloud.StorageApi import StorageApi
from asposestoragecloud.StorageApi import ResponseMessage
apiKey = "XXXXX" #sepcify App Key
appSid = "XXXXX" #sepcify App SID
apiServer = "http://api.aspose.com/v1.1"
data_folder = "../../data/"
try:
#Instantiate Aspose Storage API SDK
storageapiClient = asposestoragecloud.ApiClient.ApiClient(apiKey, appSid, debug = True)
storageApi = StorageApi(storageapiClient)
#Instantiate Aspose Words API SDK
apiClient = asposewordscloud.ApiClient.ApiClient(apiKey, appSid, debug = True)
wordsApi = WordsApi(apiClient);
#set input file name
filename = "SampleWordDocument.docx"
format = "pdf"
outfilename = "SampleWordDocumentOutput.pdf"
body = SaveOptionsData.SaveOptionsData()
body.FileName = outfilename
body.SaveFormat = "pdf"
# invoke Aspose.Words Cloud SDK API to save document to required format
response = wordsApi.PostDocumentSaveAs(filename, body)
if(response.Status == 'OK'):
outputfilename = response.SaveResult.DestDocument.Href;
response = storageApi.GetDownload(Path= outputfilename)
outfilename = "c:/temp/" + outputfilename
with open(outfilename, 'wb') as f:
for chunk in response.InputStream:
f.write(chunk)
except ApiException as ex:
print "ApiException:"
print "Code:" + str(ex.code)
print "Message:" + ex.message
import asposewordscloud
from asposewordscloud.WordsApi import WordsApi
from asposewordscloud.WordsApi import ApiException
from asposewordscloud.models import ProtectionRequest
import asposestoragecloud
from asposestoragecloud.StorageApi import StorageApi
from asposestoragecloud.StorageApi import ResponseMessage
apiKey = "XXXXX" #sepcify App Key
appSid = "XXXXX" #sepcify App SID
apiServer = "http://api.aspose.com/v1.1"
data_folder = "../../data/"
#Instantiate Aspose Storage API SDK
storage_apiClient = asposestoragecloud.ApiClient.ApiClient(apiKey, appSid, True)
storageApi = StorageApi(storage_apiClient)
#Instantiate Aspose Words API SDK
api_client = asposewordscloud.ApiClient.ApiClient(apiKey, appSid, True)
wordsApi = WordsApi(api_client)
#set input file name
filename = "SampleWordDocument.docx"
#upload file to aspose cloud storage
storageApi.PutCreate(Path=filename, file=data_folder + filename)
try:
#invoke Aspose.Words Cloud SDK API to get all the hyperlinks in a word document
response = wordsApi.GetDocumentHyperlinks(name=filename)
if response.Status == "OK":
#display the hyperlinks info
for hyperlink in response.Hyperlinks.HyperlinkList:
print "Display Text: " + hyperlink.DisplayText + " Value: " + hyperlink.Value + " link: " + hyperlink.link.Href
except ApiException as ex:
print "ApiException:"
print "Code:" + str(ex.code)
print "Message:" + ex.message
import asposewordscloud
from asposewordscloud.WordsApi import WordsApi
from asposewordscloud.WordsApi import ApiException
from asposewordscloud.models import ProtectionRequest
import asposestoragecloud
from asposestoragecloud.StorageApi import StorageApi
from asposestoragecloud.StorageApi import ResponseMessage
apiKey = "XXXXX" #sepcify App Key
appSid = "XXXXX" #sepcify App SID
apiServer = "http://api.aspose.com/v1.1"
data_folder = "../../data/"
#Instantiate Aspose Storage API SDK
storage_apiClient = asposestoragecloud.ApiClient.ApiClient(apiKey, appSid, True)
storageApi = StorageApi(storage_apiClient)
#Instantiate Aspose Words API SDK
api_client = asposewordscloud.ApiClient.ApiClient(apiKey, appSid, True)
wordsApi = WordsApi(api_client)
#set input file name
filename = "SampleWordDocument.docx"
#upload file to aspose cloud storage
storageApi.PutCreate(Path=filename, file=data_folder + filename)
try:
#invoke Aspose.Words Cloud SDK API to get all document properties from a word document
response = wordsApi.GetDocumentProperties(name=filename)
if response.Status == "OK":
#display document property info
for docProperty in response.DocumentProperties.List:
print docProperty.Name + " : " + docProperty.Value
except ApiException as ex:
print "ApiException:"
print "Code:" + str(ex.code)
print "Message:" + ex.message
import asposewordscloud
from asposewordscloud.WordsApi import WordsApi
from asposewordscloud.WordsApi import ApiException
from asposewordscloud.models import DrawingObjectsResponse
import asposestoragecloud
from asposestoragecloud.StorageApi import StorageApi
from asposestoragecloud.StorageApi import ResponseMessage
apiKey = "XXXXX" #sepcify App Key
appSid = "XXXXX" #sepcify App SID
apiServer = "http://api.aspose.com/v1.1"
data_folder = "../../data/"
#Instantiate Aspose Storage API SDK
storage_apiClient = asposestoragecloud.ApiClient.ApiClient(apiKey, appSid, True)
storageApi = StorageApi(storage_apiClient)
#Instantiate Aspose Words API SDK
api_client = asposewordscloud.ApiClient.ApiClient(apiKey, appSid, True)
wordsApi = WordsApi(api_client)
#set input file name
filename = "SampleWordDocument.docx"
objectIndex = 1
#upload file to aspose cloud storage
storageApi.PutCreate(Path=filename, file=data_folder + filename)
try:
#invoke Aspose.Words Cloud SDK API to get drawing object by index present in a word document
response = wordsApi.GetDocumentDrawingObjectImageData(name=filename, objectIndex=objectIndex)
if response.Status == "OK":
destfilename = "DrawingObject_" + str(objectIndex) + ".png"
with open("c:/temp/" +destfilename, 'wb') as f:
for chunk in response.InputStream:
f.write(chunk)
except ApiException as ex:
print "ApiException:"
print "Code:" + str(ex.code)
print "Message:" + ex.message
import asposewordscloud
from asposewordscloud.WordsApi import WordsApi
from asposewordscloud.WordsApi import RevisionsModificationResponse
import asposestoragecloud
from asposestoragecloud.StorageApi import StorageApi
from asposestoragecloud.StorageApi import ResponseMessage
apiKey = "XXXXX" #sepcify App Key
appSid = "XXXXX" #sepcify App SID
apiServer = "http://api.aspose.com/v1.1"
data_folder = "../../data/"
#Instantiate Aspose Storage API SDK
storage_apiClient = asposestoragecloud.ApiClient.ApiClient(apiKey, appSid, True)
storageApi = StorageApi(storage_apiClient)
#Instantiate Aspose Words API SDK
api_client = asposewordscloud.ApiClient.ApiClient(apiKey, appSid, True)
wordsApi = WordsApi(api_client)
#set input file name
filename = "SampleWordDocument.docx"
#upload file to aspose cloud storage
storageApi.PutCreate(filename, data_folder + filename)
#invoke Aspose.Words Cloud SDK API to reject all revisions
response = wordsApi.RejectAllRevisions(filename)
if response.Status == "OK":
print "Document track changes have been rejected successfully"
import asposewordscloud
from asposewordscloud.WordsApi import WordsApi
from asposewordscloud.WordsApi import ApiException
from asposewordscloud.models import SectionLinkCollectionResponse
import asposestoragecloud
from asposestoragecloud.StorageApi import StorageApi
from asposestoragecloud.StorageApi import ResponseMessage
apiKey = "XXXXX" #sepcify App Key
appSid = "XXXXX" #sepcify App SID
apiServer = "http://api.aspose.com/v1.1"
data_folder = "../../data/"
#Instantiate Aspose Storage API SDK
storage_apiClient = asposestoragecloud.ApiClient.ApiClient(apiKey, appSid, True)
storageApi = StorageApi(storage_apiClient)
#Instantiate Aspose Words API SDK
api_client = asposewordscloud.ApiClient.ApiClient(apiKey, appSid, True)
wordsApi = WordsApi(api_client)
#set input file name
filename = "SampleHeaderFooterWordDocument.docx"
destfilename = "updated-" + filename
#upload file to aspose cloud storage
storageApi.PutCreate(Path=filename, file=data_folder + filename)
try:
#invoke Aspose.Words Cloud SDK API to remove all headers and footers from a word document
response = wordsApi.DeleteHeadersFooters(name=filename, filename=destfilename)
if response.Status == "OK":
print "All headers and footers have been deleted successfully"
#download updated file from cloud storage
response = storageApi.GetDownload(Path=destfilename)
outfilename = "c:/temp/" + destfilename
with open(outfilename, 'wb') as f:
for chunk in response.InputStream:
f.write(chunk)
except ApiException as ex:
print "ApiException:"
print "Code:" + str(ex.code)
print "Message:" + ex.message
import asposewordscloud
from asposewordscloud.WordsApi import WordsApi
from asposewordscloud.WordsApi import ApiException
from asposewordscloud.models import ProtectionRequest
import asposestoragecloud
from asposestoragecloud.StorageApi import StorageApi
from asposestoragecloud.StorageApi import ResponseMessage
apiKey = "XXXXX" #sepcify App Key
appSid = "XXXXX" #sepcify App SID
apiServer = "http://api.aspose.com/v1.1"
data_folder = "../../data/"
#Instantiate Aspose Storage API SDK
storage_apiClient = asposestoragecloud.ApiClient.ApiClient(apiKey, appSid, True)
storageApi = StorageApi(storage_apiClient)
#Instantiate Aspose Words API SDK
api_client = asposewordscloud.ApiClient.ApiClient(apiKey, appSid, True)
wordsApi = WordsApi(api_client)
#set input file name
filename = "SampleWordDocument.docx"
propertyName = "AsposeAuthor"
#upload file to aspose cloud storage
storageApi.PutCreate(Path=filename, file=data_folder + filename)
try:
#invoke Aspose.Words Cloud SDK API to delete document property by given name from a word document
response = wordsApi.DeleteDocumentProperty(name=filename, propertyName=propertyName)
if response.Status == "OK":
print "The document property has been removed successfully"
except ApiException as ex:
print "ApiException:"
print "Code:" + str(ex.code)
print "Message:" + ex.message
import asposewordscloud
from asposewordscloud.WordsApi import WordsApi
from asposewordscloud.WordsApi import ApiException
from asposewordscloud.models import ProtectionRequest
import asposestoragecloud
from asposestoragecloud.StorageApi import StorageApi
from asposestoragecloud.StorageApi import ResponseMessage
apiKey = "XXXXX" #sepcify App Key
appSid = "XXXXX" #sepcify App SID
apiServer = "http://api.aspose.com/v1.1"
data_folder = "../../data/"
#Instantiate Aspose Storage API SDK
storage_apiClient = asposestoragecloud.ApiClient.ApiClient(apiKey, appSid, True)
storageApi = StorageApi(storage_apiClient)
#Instantiate Aspose Words API SDK
api_client = asposewordscloud.ApiClient.ApiClient(apiKey, appSid, True)
wordsApi = WordsApi(api_client)
#set input file name
filename = "SampleProtectedBlankWordDocument.docx"
destfilename = "updated-" + filename
body = ProtectionRequest.ProtectionRequest()
body.Password = "aspose"
#upload file to aspose cloud storage
storageApi.PutCreate(Path=filename, file=data_folder + filename)
try:
#invoke Aspose.Words Cloud SDK API to unprotect a word document
response = wordsApi.DeleteUnprotectDocument(name=filename, body=body, filename=destfilename)
if response.Status == "OK":
print "Document has been unprotected successfully"
#download updated document from storage server
response = storageApi.GetDownload(Path=destfilename)
outfilename = "c:/temp/" + destfilename
with open(outfilename, 'wb') as f:
for chunk in response.InputStream:
f.write(chunk)
except ApiException as ex:
print "ApiException:"
print "Code:" + str(ex.code)
print "Message:" + ex.message
import asposewordscloud
from asposewordscloud.WordsApi import WordsApi
from asposewordscloud.WordsApi import ApiException
from asposewordscloud.models import WatermarkText
import asposestoragecloud
from asposestoragecloud.StorageApi import StorageApi
from asposestoragecloud.StorageApi import ResponseMessage
apiKey = "XXXXX" #sepcify App Key
appSid = "XXXXX" #sepcify App SID
apiServer = "http://api.aspose.com/v1.1"
data_folder = "../../data/"
#Instantiate Aspose Storage API SDK
storage_apiClient = asposestoragecloud.ApiClient.ApiClient(apiKey, appSid, True)
storageApi = StorageApi(storage_apiClient)
#Instantiate Aspose Words API SDK
api_client = asposewordscloud.ApiClient.ApiClient(apiKey, appSid, True)
wordsApi = WordsApi(api_client)
#set input file name
filename = "SampleBlankWatermarkDocument.docx"
destfilename = "updated-" + filename
#upload file to aspose cloud storage
storageApi.PutCreate(Path=filename, file=data_folder + filename)
try:
#invoke Aspose.Words Cloud SDK API to remove watermark image from a word document
response = wordsApi.DeleteDocumentWatermark(name=filename, filename=destfilename)
if response.Status == "OK":
print "Watermark image has been removed successfully"
#download updated document from storage server
response = storageApi.GetDownload(Path=destfilename)
outfilename = "c:/temp/" + destfilename
with open(outfilename, 'wb') as f:
for chunk in response.InputStream:
f.write(chunk)
except ApiException as ex:
print "ApiException:"
print "Code:" + str(ex.code)
print "Message:" + ex.message
import asposewordscloud
from asposewordscloud.WordsApi import WordsApi
from asposewordscloud.WordsApi import ApiException
from asposewordscloud.models import ReplaceTextRequest
import asposestoragecloud
from asposestoragecloud.StorageApi import StorageApi
from asposestoragecloud.StorageApi import ResponseMessage
apiKey = "XXXXX" #sepcify App Key
appSid = "XXXXX" #sepcify App SID
apiServer = "http://api.aspose.com/v1.1"
data_folder = "../../data/"
#Instantiate Aspose Storage API SDK
storage_apiClient = asposestoragecloud.ApiClient.ApiClient(apiKey, appSid, True)
storageApi = StorageApi(storage_apiClient)
#Instantiate Aspose Words API SDK
api_client = asposewordscloud.ApiClient.ApiClient(apiKey, appSid, True)
wordsApi = WordsApi(api_client)
#set input file name
filename = "SampleWordDocument.docx"
body = ReplaceTextRequest.ReplaceTextRequest()
body.OldValue = "aspose"
body.NewValue = "aspose.com"
#upload file to aspose cloud storage
storageApi.PutCreate(Path=filename, file=data_folder + filename)
try:
#invoke Aspose.Words Cloud SDK API to replace text from a given a Word document
response = wordsApi.PostReplaceText(name=filename, body=body)
if response.Status == "OK":
print "Document has been updated successfully"
#download updated document from storage server
response = storageApi.GetDownload(Path=filename)
outfilename = "c:/temp/" + filename
with open(outfilename, 'wb') as f:
for chunk in response.InputStream:
f.write(chunk)
except ApiException as ex:
print "ApiException:"
print "Code:" + str(ex.code)
print "Message:" + ex.message
import asposewordscloud
from asposewordscloud.WordsApi import WordsApi
from asposewordscloud.WordsApi import ApiException
from asposewordscloud.models import ReplaceTextRequest
import asposestoragecloud
from asposestoragecloud.StorageApi import StorageApi
from asposestoragecloud.StorageApi import ResponseMessage
apiKey = "XXXXX" #sepcify App Key
appSid = "XXXXX" #sepcify App SID
apiServer = "http://api.aspose.com/v1.1"
data_folder = "../../data/"
#Instantiate Aspose Storage API SDK
storage_apiClient = asposestoragecloud.ApiClient.ApiClient(apiKey, appSid, True)
storageApi = StorageApi(storage_apiClient)
#Instantiate Aspose Words API SDK
api_client = asposewordscloud.ApiClient.ApiClient(apiKey, appSid, True)
wordsApi = WordsApi(api_client)
#set input file name
filename = "SampleWordDocument.docx"
storage = "AsposeDropboxStorage"
body = ReplaceTextRequest.ReplaceTextRequest()
body.OldValue = "aspose"
body.NewValue = "aspose.com"
#upload file to aspose cloud storage
storageApi.PutCreate(Path=filename, file=data_folder + filename, storage=storage)
try:
#invoke Aspose.Words Cloud SDK API to replace text from a given a Word document
response = wordsApi.PostReplaceText(name=filename, body=body, storage=storage)
if response.Status == "OK":
print "Document has been updated successfully"
#download updated document from storage server
response = storageApi.GetDownload(Path=filename)
outfilename = "c:/temp/" + filename
with open(outfilename, 'wb') as f:
for chunk in response.InputStream:
f.write(chunk)
except ApiException as ex:
print "ApiException:"
print "Code:" + str(ex.code)
print "Message:" + ex.message
import asposewordscloud
from asposewordscloud.WordsApi import WordsApi
from asposewordscloud.WordsApi import ApiException
from asposewordscloud.models import DocumentProperty
import asposestoragecloud
from asposestoragecloud.StorageApi import StorageApi
from asposestoragecloud.StorageApi import ResponseMessage
apiKey = "XXXXX" #sepcify App Key
appSid = "XXXXX" #sepcify App SID
apiServer = "http://api.aspose.com/v1.1"
data_folder = "../../data/"
#Instantiate Aspose Storage API SDK
storage_apiClient = asposestoragecloud.ApiClient.ApiClient(apiKey, appSid, True)
storageApi = StorageApi(storage_apiClient)
#Instantiate Aspose Words API SDK
api_client = asposewordscloud.ApiClient.ApiClient(apiKey, appSid, True)
wordsApi = WordsApi(api_client)
#set input file name
filename = "SampleWordDocument.docx"
propertyName = "Author"
body = DocumentProperty.DocumentProperty()
body.Name = "Author"
body.Value = "Farooq Sheikh"
#upload file to aspose cloud storage
storageApi.PutCreate(Path=filename, file=data_folder + filename)
try:
#invoke Aspose.Words Cloud SDK API to update document property by given name from a word document
response = wordsApi.PutUpdateDocumentProperty(name=filename, propertyName=propertyName, body=body)
if response.Status == "OK":
#display document property info
print response.DocumentProperty.Name + " : " + response.DocumentProperty.Value
except ApiException as ex:
print "ApiException:"
print "Code:" + str(ex.code)
print "Message:" + ex.message
import asposewordscloud
from asposewordscloud.WordsApi import WordsApi
from asposewordscloud.WordsApi import ApiException
from asposewordscloud.models import ProtectionRequest
import asposestoragecloud
from asposestoragecloud.StorageApi import StorageApi
from asposestoragecloud.StorageApi import ResponseMessage
apiKey = "XXXXX" #sepcify App Key
appSid = "XXXXX" #sepcify App SID
apiServer = "http://api.aspose.com/v1.1"
data_folder = "../../data/"
#Instantiate Aspose Storage API SDK
storage_apiClient = asposestoragecloud.ApiClient.ApiClient(apiKey, appSid, True)
storageApi = StorageApi(storage_apiClient)
#Instantiate Aspose Words API SDK
api_client = asposewordscloud.ApiClient.ApiClient(apiKey, appSid, True)
wordsApi = WordsApi(api_client)
#set input file name
filename = "SampleWordDocument.docx"
bookmarkName = "aspose"
#upload file to aspose cloud storage
storageApi.PutCreate(Path=filename, file=data_folder + filename)
try:
#invoke Aspose.Words Cloud SDK API to get the bookmark by given name from a word document
response = wordsApi.GetDocumentBookmarkByName(name=filename, bookmarkName=bookmarkName)
if response.Status == "OK":
#display the bookmarks info
print "Name: " + response.Bookmark.Name + " Text: " + response.Bookmark.Text + " link: " + response.Bookmark.link.Href
except ApiException as ex:
print "ApiException:"
print "Code:" + str(ex.code)
print "Message:" + ex.message
import asposewordscloud
from asposewordscloud.WordsApi import WordsApi
from asposewordscloud.models import SplitDocumentResponse
import asposestoragecloud
from asposestoragecloud.StorageApi import StorageApi
from asposestoragecloud.StorageApi import ResponseMessage
apiKey = "XXXXX" #sepcify App Key
appSid = "XXXXX" #sepcify App SID
apiServer = "http://api.aspose.com/v1.1"
data_folder = "../../data/"
#Instantiate Aspose Storage API SDK
storageapiClient = asposestoragecloud.ApiClient.ApiClient(apiKey, appSid, debug = True)
storageApi = StorageApi(storageapiClient)
#Instantiate Aspose Words API SDK
apiClient = asposewordscloud.ApiClient.ApiClient(apiKey, appSid, debug = True)
wordsApi = WordsApi(apiClient)
#set input file name
filename = "SampleWordDocument.docx"
format = "pdf"
#upload input file to aspose cloud storage
storageApi.PutCreate(Path = filename, file = data_folder + filename)
#invoke Aspose.Words Cloud SDK API to split word document
response = wordsApi.PostSplitDocument(name=filename, format=format, zipOutput='true')
if response.Status == 'OK':
print "Document has been splitted to pfds successfully"
#download splitted pdfs from storage server as zipOutput
outfilename = response.SplitResult.ZippedPages.Href
response = storageApi.GetDownload(Path=outfilename)
with open("c:/temp/" + outfilename, 'wb') as f:
for chunk in response.InputStream:
f.write(chunk)
import asposewordscloud
from asposewordscloud.WordsApi import WordsApi
from asposewordscloud.models import SplitDocumentResponse
import asposestoragecloud
from asposestoragecloud.StorageApi import StorageApi
from asposestoragecloud.StorageApi import ResponseMessage
apiKey = "XXXXX" #sepcify App Key
appSid = "XXXXX" #sepcify App SID
apiServer = "http://api.aspose.com/v1.1"
data_folder = "../../data/"
#Instantiate Aspose Storage API SDK
storageapiClient = asposestoragecloud.ApiClient.ApiClient(apiKey, appSid, debug = True)
storageApi = StorageApi(storageapiClient)
#Instantiate Aspose Words API SDK
apiClient = asposewordscloud.ApiClient.ApiClient(apiKey, appSid, debug = True)
wordsApi = WordsApi(apiClient)
#set input file name
filename = "SampleWordDocument.docx"
format = "png"
#upload input file to aspose cloud storage
storageApi.PutCreate(Path = filename, file = data_folder + filename)
#invoke Aspose.Words Cloud SDK API to split word document
response = wordsApi.PostSplitDocument(name=filename, format=format,ffrom=2, to=2, zipOutput='false')
if response.Status == 'OK':
print "Document has been splitted to png successfully"
#download splitted png from storage server
outfilename = response.SplitResult.Pages[0].Href
response = storageApi.GetDownload(Path=outfilename)
with open("c:/temp/" + outfilename, 'wb') as f:
for chunk in response.InputStream:
f.write(chunk)
import asposewordscloud
from asposewordscloud.WordsApi import WordsApi
from asposewordscloud.models import SplitDocumentResponse
import asposestoragecloud
from asposestoragecloud.StorageApi import StorageApi
from asposestoragecloud.StorageApi import ResponseMessage
apiKey = "XXXXX" #sepcify App Key
appSid = "XXXXX" #sepcify App SID
apiServer = "http://api.aspose.com/v1.1"
data_folder = "../../data/"
#Instantiate Aspose Storage API SDK
storageapiClient = asposestoragecloud.ApiClient.ApiClient(apiKey, appSid, debug = True)
storageApi = StorageApi(storageapiClient)
#Instantiate Aspose Words API SDK
apiClient = asposewordscloud.ApiClient.ApiClient(apiKey, appSid, debug = True)
wordsApi = WordsApi(apiClient)
#set input file name
filename = "SampleWordDocument.docx"
format = "pdf"
#upload input file to aspose cloud storage
storageApi.PutCreate(Path = filename, file = data_folder + filename)
#invoke Aspose.Words Cloud SDK API to split word document
response = wordsApi.PostSplitDocument(name=filename, format=format,ffrom=2, to=2, zipOutput='false')
if response.Status == 'OK':
print "Document has been splitted to png successfully"
#download splitted png from storage server
outfilename = response.SplitResult.Pages[0].Href
response = storageApi.GetDownload(Path=outfilename)
with open("c:/temp/" + outfilename, 'wb') as f:
for chunk in response.InputStream:
f.write(chunk)
import asposewordscloud
from asposewordscloud.WordsApi import WordsApi
from asposewordscloud.WordsApi import ApiException
from asposewordscloud.models import FormField
from asposewordscloud.models import FormFieldResponse
import asposestoragecloud
from asposestoragecloud.StorageApi import StorageApi
from asposestoragecloud.StorageApi import ResponseMessage
apiKey = "XXXXX" #sepcify App Key
appSid = "XXXXX" #sepcify App SID
apiServer = "http://api.aspose.com/v1.1"
data_folder = "../../data/"
#Instantiate Aspose Storage API SDK
storage_apiClient = asposestoragecloud.ApiClient.ApiClient(apiKey, appSid, True)
storageApi = StorageApi(storage_apiClient)
#Instantiate Aspose Words API SDK
api_client = asposewordscloud.ApiClient.ApiClient(apiKey, appSid, True)
wordsApi = WordsApi(api_client)
#set input file name
filename = "SampleBlankWordDocument.docx"
#upload file to aspose cloud storage
storageApi.PutCreate(Path=filename, file=data_folder + filename)
try:
#invoke Aspose.Words Cloud SDK API to update fields in the whole document
response = wordsApi.PostUpdateDocumentFields(name=filename)
if response.Status == "OK":
print "Document fields have been updated successfully"
except ApiException as ex:
print "ApiException:"
print "Code:" + str(ex.code)
print "Message:" + ex.message
import asposewordscloud
from asposewordscloud.WordsApi import WordsApi
from asposewordscloud.WordsApi import ApiException
from asposewordscloud.models import BookmarkData
import asposestoragecloud
from asposestoragecloud.StorageApi import StorageApi
from asposestoragecloud.StorageApi import ResponseMessage
apiKey = "XXXXX" #sepcify App Key
appSid = "XXXXX" #sepcify App SID
apiServer = "http://api.aspose.com/v1.1"
data_folder = "../../data/"
#Instantiate Aspose Storage API SDK
storage_apiClient = asposestoragecloud.ApiClient.ApiClient(apiKey, appSid, True)
storageApi = StorageApi(storage_apiClient)
#Instantiate Aspose Words API SDK
api_client = asposewordscloud.ApiClient.ApiClient(apiKey, appSid, True)
wordsApi = WordsApi(api_client)
#set input file name
filename = "SampleWordDocument.docx"
bookmarkName = "aspose"
body = BookmarkData.BookmarkData()
body.Name = "aspose"
body.Text = "This is updated Bookmark"
#upload file to aspose cloud storage
storageApi.PutCreate(Path=filename, file=data_folder + filename)
try:
#invoke Aspose.Words Cloud SDK API to update the bookmark from a word document
response = wordsApi.PostUpdateDocumentBookmark(name=filename, bookmarkName=bookmarkName, body=body)
if response.Status == "OK":
#display the bookmarks info
print "Name: " + response.Bookmark.Name + " Text: " + response.Bookmark.Text + " link: " + response.Bookmark.link.Href
except ApiException as ex:
print "ApiException:"
print "Code:" + str(ex.code)
print "Message:" + ex.message
# sepcify App SID
AsposeApp.app_sid = "******************"
# sepcify App Key
AsposeApp.app_key = "******************"
# specify product URI
Product.base_product_uri = 'http://api.aspose.com/v1.1'
# set parameters
file_name = "Bookmarks.docx"
bookmark_name = "first_bookmark"
#build URI to update bookmark text
str_uri_request = Product.base_product_uri + "/words/" + file_name + "/bookmarks/" + bookmark_name
signed_uri = Utils.sign(Utils(),str_uri_request)
post_data = {"Text" : "This is updated text two"}
json_arr = json.dumps(post_data)
response_stream = Utils.process_command(Utils(),signed_uri, "POST", "JSON", json_arr)
json_data = json.loads(response_stream)
if (json_data['Code'] == 200):
print 'The bookmark text has been updated successfully'
else:
print 'Error'
import asposewordscloud
from asposewordscloud.WordsApi import WordsApi
from asposewordscloud.WordsApi import ApiException
from asposewordscloud.models import Font
import asposestoragecloud
from asposestoragecloud.StorageApi import StorageApi
from asposestoragecloud.StorageApi import ResponseMessage
apiKey = "XXXXX" #sepcify App Key
appSid = "XXXXX" #sepcify App SID
apiServer = "http://api.aspose.com/v1.1"
data_folder = "../../data/"
#Instantiate Aspose Storage API SDK
storage_apiClient = asposestoragecloud.ApiClient.ApiClient(apiKey, appSid, True)
storageApi = StorageApi(storage_apiClient)
#Instantiate Aspose Words API SDK
api_client = asposewordscloud.ApiClient.ApiClient(apiKey, appSid, True)
wordsApi = WordsApi(api_client)
#set input file name
filename = "SampleWordDocument.docx"
destfilename = "updated-" + filename
index = 1
runIndex = 0
body = Font.Font()
body.Bold = True
body.Size = 31.0
body.Name = "Calibri"
#upload file to aspose cloud storage
storageApi.PutCreate(Path=filename, file=data_folder + filename)
try:
#invoke Aspose.Words Cloud SDK API to update font of a specific run of a paragraph present in a word document
response = wordsApi.PostDocumentParagraphRunFont(name=filename, index=index, runIndex=runIndex, body=body, filename=destfilename)
if response.Status == "OK":
print "paragraph run font has been updated successfully"
#download updated file from cloud storage
response = storageApi.GetDownload(Path=destfilename)
outfilename = "c:/temp/" + destfilename
with open(outfilename, 'wb') as f:
for chunk in response.InputStream:
f.write(chunk)
except ApiException as ex:
print "ApiException:"
print "Code:" + str(ex.code)
print "Message:" + ex.message
import asposewordscloud
from asposewordscloud.WordsApi import WordsApi
from asposewordscloud.WordsApi import ApiException
from asposewordscloud.models import PageSetup
import asposestoragecloud
from asposestoragecloud.StorageApi import StorageApi
from asposestoragecloud.StorageApi import ResponseMessage
apiKey = "XXXXX" #sepcify App Key
appSid = "XXXXX" #sepcify App SID
apiServer = "http://api.aspose.com/v1.1"
data_folder = "../../data/"
#Instantiate Aspose Storage API SDK
storage_apiClient = asposestoragecloud.ApiClient.ApiClient(apiKey, appSid, True)
storageApi = StorageApi(storage_apiClient)
#Instantiate Aspose Words API SDK
api_client = asposewordscloud.ApiClient.ApiClient(apiKey, appSid, True)
wordsApi = WordsApi(api_client)
#set input file name
filename = "SampleBlankWordDocument.docx"
destfilename = "updated-" + filename
sectionIndex = 0
body = PageSetup.PageSetup()
body.RtlGutter = True
body.Orientation = "Portrait"
body.PaperSize = "A5"
#upload file to aspose cloud storage
storageApi.PutCreate(Path=filename, file=data_folder + filename)
try:
#invoke Aspose.Words Cloud SDK API to update page setup properties by given section index from a word document
response = wordsApi.UpdateSectionPageSetup(name=filename, sectionIndex=sectionIndex, body=body, filename=destfilename)
if response.Status == "OK":
secPageSetup = response.PageSetup
if(secPageSetup is not None):
#display section page setup info
print "PaperSize :" + response.PageSetup.PaperSize + " Orientation: " + response.PageSetup.Orientation
#download updated document from storage server
response = storageApi.GetDownload(Path=destfilename)
outfilename = "c:/temp/" + destfilename
with open(outfilename, 'wb') as f:
for chunk in response.InputStream:
f.write(chunk)
except ApiException as ex:
print "ApiException:"
print "Code:" + str(ex.code)
print "Message:" + ex.message
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment