Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Editor-Python
# Import modules
import groupdocs_Editor_cloud
from Common_Utilities.Utils import Common_Utilities
class Editor_Python_Copy_File:
@classmethod
def Run(self):
# Create instance of the API
api = Common_Utilities.Get_FileApi_Instance()
try:
request = groupdocs_Editor_cloud.CopyFileRequest("Editordocs\\one-page.docx", "Editordocs\\one-page-copied.docx", Common_Utilities.myStorage, Common_Utilities.myStorage)
api.copy_file(request)
print("Expected response type is Void: 'Editordocs/one-page.docx' file copied as 'Editordocs/one-page-copied.docx'.")
except groupdocs_Editor_cloud.ApiException as e:
print("Exception while calling API: {0}".format(e.message))
# Import modules
import groupdocs_Editor_cloud
from Common_Utilities.Utils import Common_Utilities
class Editor_Python_Copy_Folder:
@classmethod
def Run(self):
# Create instance of the API
api = Common_Utilities.Get_FolderApi_Instance()
try:
request = groupdocs_Editor_cloud.CopyFolderRequest("Editordocs", "Editordocs1", Common_Utilities.myStorage, Common_Utilities.myStorage)
api.copy_folder(request)
print("Expected response type is Void: 'Editordocs' folder copied as 'Editordocs1'.")
except groupdocs_Editor_cloud.ApiException as e:
print("Exception while calling API: {0}".format(e.message))
# Import modules
import groupdocs_Editor_cloud
from Common_Utilities.Utils import Common_Utilities
class Editor_Python_Create_Folder:
@classmethod
def Run(self):
# Create instance of the API
api = Common_Utilities.Get_FolderApi_Instance()
try:
request = groupdocs_Editor_cloud.CreateFolderRequest("Assembler", Common_Utilities.myStorage)
api.create_folder(request)
print("Expected response type is Void: 'Assembler' folder created.")
except groupdocs_Editor_cloud.ApiException as e:
print("Exception while calling API: {0}".format(e.message))
# Import modules
import groupdocs_Editor_cloud
from Common_Utilities.Utils import Common_Utilities
class Editor_Python_Delete_File:
@classmethod
def Run(self):
# Create instance of the API
api = Common_Utilities.Get_FileApi_Instance()
try:
request = groupdocs_Editor_cloud.DeleteFileRequest("Editordocs1\\one-page.docx", Common_Utilities.myStorage)
api.delete_file(request)
print("Expected response type is Void: 'Editordocs1/one-page.docx' deleted.")
except groupdocs_Editor_cloud.ApiException as e:
print("Exception while calling API: {0}".format(e.message))
# Import modules
import groupdocs_Editor_cloud
from Common_Utilities.Utils import Common_Utilities
class Editor_Python_Delete_Folder:
@classmethod
def Run(self):
# Create instance of the API
api = Common_Utilities.Get_FolderApi_Instance()
try:
request = groupdocs_Editor_cloud.DeleteFolderRequest("Editordocs\\Editordocs1", Common_Utilities.myStorage, True)
api.delete_folder(request)
print("Expected response type is Void: 'Editordocs/Editordocs1' folder deleted recursively.")
except groupdocs_Editor_cloud.ApiException as e:
print("Exception while calling API: {0}".format(e.message))
# Import modules
import groupdocs_Editor_cloud
from Common_Utilities.Utils import Common_Utilities
class Editor_Python_Download_File:
@classmethod
def Run(self):
# Create instance of the API
api = Common_Utilities.Get_FileApi_Instance()
try:
request = groupdocs_Editor_cloud.DownloadFileRequest("Editordocs\\one-page.docx", Common_Utilities.myStorage)
response = api.download_file(request)
print("Expected response type is Stream: " + str(len(response)))
except groupdocs_Editor_cloud.ApiException as e:
print("Exception while calling API: {0}".format(e.message))
# Import modules
import groupdocs_Editor_cloud
from Common_Utilities.Utils import Common_Utilities
class Editor_Python_Get_Disc_Usage:
@classmethod
def Run(self):
# Create instance of the API
api = Common_Utilities.Get_StorageApi_Instance()
try:
request = groupdocs_Editor_cloud.GetDiscUsageRequest(Common_Utilities.myStorage)
response = api.get_disc_usage(request)
print("Expected response type is DiscUsage: " + str(response))
except groupdocs_Editor_cloud.ApiException as e:
print("Exception while calling API: {0}".format(e.message))
# For complete examples and data files, please go to https://github.com/groupdocs-editor-cloud/groupdocs-editor-cloud-python-samples
import groupdocs_editor_cloud
app_sid = "XXXX-XXXX-XXXX-XXXX" # Get AppKey and AppSID from https://dashboard.groupdocs.cloud
app_key = "XXXXXXXXXXXXXXXX" # Get AppKey and AppSID from https://dashboard.groupdocs.cloud
infoApi = groupdocs_editor_cloud.InfoApi.from_keys(app_sid, app_key)
result = infoApi.get_supported_file_formats()
# For complete examples and data files, please go to https://github.com/groupdocs-editor-cloud/groupdocs-editor-cloud-python-samples
import groupdocs_editor_cloud
app_sid = "XXXX-XXXX-XXXX-XXXX" # Get AppKey and AppSID from https://dashboard.groupdocs.cloud
app_key = "XXXXXXXXXXXXXXXX" # Get AppKey and AppSID from https://dashboard.groupdocs.cloud
infoApi = groupdocs_editor_cloud.InfoApi.from_keys(app_sid, app_key)
fileInfo = groupdocs_editor_cloud.FileInfo("WordProcessing/password-protected.docx", None, None, "password")
result = infoApi.get_info(groupdocs_editor_cloud.GetInfoRequest(fileInfo))
print("Page count = " + str(result.page_count))
# Import modules
import groupdocs_Editor_cloud
from Common_Utilities.Utils import Common_Utilities
class Editor_Python_Get_File_Versions:
@classmethod
def Run(self):
# Create instance of the API
api = Common_Utilities.Get_StorageApi_Instance()
try:
request = groupdocs_Editor_cloud.GetFileVersionsRequest("Editordocs\\one-page.docx", Common_Utilities.myStorage)
response = api.get_file_versions(request)
print("Expected response type is FileVersions: " + str(response))
except groupdocs_Editor_cloud.ApiException as e:
print("Exception while calling API: {0}".format(e.message))
# Import modules
import groupdocs_Editor_cloud
from Common_Utilities.Utils import Common_Utilities
class Editor_Python_Get_Files_List:
@classmethod
def Run(self):
# Create instance of the API
api = Common_Utilities.Get_FolderApi_Instance()
try:
request = groupdocs_Editor_cloud.GetFilesListRequest("Editordocs\\sample.docx", Common_Utilities.myStorage)
response = api.get_files_list(request)
print("Expected response type is FilesList: " + str(response))
except groupdocs_Editor_cloud.ApiException as e:
print("Exception while calling API: {0}".format(e.message))
# Import modules
import groupdocs_Editor_cloud
from Common_Utilities.Utils import Common_Utilities
class Editor_Python_Move_File:
@classmethod
def Run(self):
# Create instance of the API
api = Common_Utilities.Get_FileApi_Instance()
try:
request = groupdocs_Editor_cloud.MoveFileRequest("Editordocs\\one-page.docx", "Editordocs1\\one-page.docx", Common_Utilities.myStorage, Common_Utilities.myStorage)
api.move_file(request)
print("Expected response type is Void: 'Editordocs/one-page.docx' file moved to 'Editordocs1/one-page.docx'.")
except groupdocs_Editor_cloud.ApiException as e:
print("Exception while calling API: {0}".format(e.message))
# Import modules
import groupdocs_Editor_cloud
from Common_Utilities.Utils import Common_Utilities
class Editor_Python_Move_Folder:
@classmethod
def Run(self):
# Create instance of the API
api = Common_Utilities.Get_FolderApi_Instance()
try:
request = groupdocs_Editor_cloud.MoveFolderRequest("Editordocs1", "Editordocs1\\Editordocs", Common_Utilities.myStorage, Common_Utilities.myStorage)
api.move_folder(request)
print("Expected response type is Void: 'Editordocs1' folder moved to 'Editordocs/Editordocs1'.")
except groupdocs_Editor_cloud.ApiException as e:
print("Exception while calling API: {0}".format(e.message))
# Import modules
import groupdocs_Editor_cloud
from Common_Utilities.Utils import Common_Utilities
class Editor_Python_Object_Exists:
@classmethod
def Run(self):
# Create instance of the API
api = Common_Utilities.Get_StorageApi_Instance()
try:
request = groupdocs_Editor_cloud.ObjectExistsRequest("Editordocs\\one-page.docx", Common_Utilities.myStorage)
response = api.object_exists(request)
print("Expected response type is ObjectExist: " + str(response))
except groupdocs_Editor_cloud.ApiException as e:
print("Exception while calling API: {0}".format(e.message))
# Import modules
import groupdocs_Editor_cloud
from Common_Utilities.Utils import Common_Utilities
class Editor_Python_Storage_Exist:
@classmethod
def Run(self):
# Create instance of the API
api = Common_Utilities.Get_StorageApi_Instance()
try:
request = groupdocs_Editor_cloud.StorageExistsRequest(Common_Utilities.myStorage)
response = api.storage_exists(request)
print("Expected response type is StorageExist: " + str(response))
except groupdocs_Editor_cloud.ApiException as e:
print("Exception while calling API: {0}".format(e.message))
# Import modules
import groupdocs_Editor_cloud
from Common_Utilities.Utils import Common_Utilities
class Editor_Python_Upload_File:
@classmethod
def Run(self):
# Create instance of the API
api = Common_Utilities.Get_FileApi_Instance()
try:
request = groupdocs_Editor_cloud.UploadFileRequest("Editordocs\\one-page.docx", "D:\\ewspace\\GroupDocs.Editor.Cloud.Python.Examples\\src\\Resources\\Editordocs\\one-page.docx", Common_Utilities.myStorage)
response = api.upload_file(request)
print("Expected response type is FilesUploadResult: " + str(response))
except groupdocs_Editor_cloud.ApiException as e:
print("Exception while calling API: {0}".format(e.message))
# For complete examples and data files, please go to https://github.com/groupdocs-editor-cloud/groupdocs-editor-cloud-python-samples
import groupdocs_editor_cloud
app_sid = "XXXX-XXXX-XXXX-XXXX" # Get AppKey and AppSID from https://dashboard.groupdocs.cloud
app_key = "XXXXXXXXXXXXXXXX" # Get AppKey and AppSID from https://dashboard.groupdocs.cloud
editApi = groupdocs_editor_cloud.EditApi.from_keys(app_sid, app_key)
fileApi = groupdocs_editor_cloud.FileApi.from_keys(app_sid, app_key)
# The document already uploaded into the storage.
# Load it into editable state
fileInfo = groupdocs_editor_cloud.FileInfo("Spreadsheet/sample.tsv")
loadOptions = groupdocs_editor_cloud.DelimitedTextLoadOptions()
loadOptions.file_info = fileInfo
loadOptions.output_path = "output"
loadResult = editApi.load(groupdocs_editor_cloud.LoadRequest(loadOptions))
# Download html document
htmlFile = fileApi.download_file(groupdocs_editor_cloud.DownloadFileRequest(loadResult.html_path))
html = ""
with open(htmlFile, 'r') as file:
html = file.read()
# Edit something...
html = html.replace("32", "66")
# Upload html back to storage
with open(htmlFile, 'w') as file:
file.write(html)
fileApi.upload_file(groupdocs_editor_cloud.UploadFileRequest(loadResult.html_path, htmlFile))
# Save html back to tsv
saveOptions = groupdocs_editor_cloud.DelimitedTextSaveOptions()
saveOptions.file_info = fileInfo
saveOptions.output_path = "output/edited.tsv"
saveOptions.html_path = loadResult.html_path
saveOptions.resources_path = loadResult.resources_path
saveResult = editApi.save(groupdocs_editor_cloud.SaveRequest(saveOptions))
# Done
print("Document edited: " + saveResult.path)
# For complete examples and data files, please go to https://github.com/groupdocs-editor-cloud/groupdocs-editor-cloud-python-samples
import groupdocs_editor_cloud
app_sid = "XXXX-XXXX-XXXX-XXXX" # Get AppKey and AppSID from https://dashboard.groupdocs.cloud
app_key = "XXXXXXXXXXXXXXXX" # Get AppKey and AppSID from https://dashboard.groupdocs.cloud
editApi = groupdocs_editor_cloud.EditApi.from_keys(app_sid, app_key)
fileApi = groupdocs_editor_cloud.FileApi.from_keys(app_sid, app_key)
# The document already uploaded into the storage.
# Load it into editable state
fileInfo = groupdocs_editor_cloud.FileInfo("Presentation/with-notes.pptx")
loadOptions = groupdocs_editor_cloud.PresentationLoadOptions()
loadOptions.file_info = fileInfo
loadOptions.output_path = "output"
loadOptions.slide_number = 0
loadResult = editApi.load(groupdocs_editor_cloud.LoadRequest(loadOptions))
# Download html document
htmlFile = fileApi.download_file(groupdocs_editor_cloud.DownloadFileRequest(loadResult.html_path))
html = ""
with open(htmlFile, 'r') as file:
html = file.read()
# Edit something...
html = html.replace("Slide sub-heading", "Hello world!")
# Upload html back to storage
with open(htmlFile, 'w') as file:
file.write(html)
fileApi.upload_file(groupdocs_editor_cloud.UploadFileRequest(loadResult.html_path, htmlFile))
# Save html back to pptx
saveOptions = groupdocs_editor_cloud.PresentationSaveOptions()
saveOptions.file_info = fileInfo
saveOptions.output_path = "output/edited.pptx"
saveOptions.html_path = loadResult.html_path
saveOptions.resources_path = loadResult.resources_path
saveResult = editApi.save(groupdocs_editor_cloud.SaveRequest(saveOptions))
# Done
print("Document edited: " + saveResult.path)
# For complete examples and data files, please go to https://github.com/groupdocs-editor-cloud/groupdocs-editor-cloud-python-samples
import groupdocs_editor_cloud
app_sid = "XXXX-XXXX-XXXX-XXXX" # Get AppKey and AppSID from https://dashboard.groupdocs.cloud
app_key = "XXXXXXXXXXXXXXXX" # Get AppKey and AppSID from https://dashboard.groupdocs.cloud
editApi = groupdocs_editor_cloud.EditApi.from_keys(app_sid, app_key)
fileApi = groupdocs_editor_cloud.FileApi.from_keys(app_sid, app_key)
# The document already uploaded into the storage.
# Load it into editable state
fileInfo = groupdocs_editor_cloud.FileInfo("Spreadsheet/four-sheets.xlsx")
loadOptions = groupdocs_editor_cloud.SpreadsheetLoadOptions()
loadOptions.file_info = fileInfo
loadOptions.output_path = "output"
loadOptions.worksheet_index = 0
loadResult = editApi.load(groupdocs_editor_cloud.LoadRequest(loadOptions))
# Download html document
htmlFile = fileApi.download_file(groupdocs_editor_cloud.DownloadFileRequest(loadResult.html_path))
html = ""
with open(htmlFile, 'r') as file:
html = file.read()
# Edit something...
html = html.replace("This is sample sheet", "This is sample sheep")
# Upload html back to storage
with open(htmlFile, 'w') as file:
file.write(html)
fileApi.upload_file(groupdocs_editor_cloud.UploadFileRequest(loadResult.html_path, htmlFile))
# Save html back to xlsx
saveOptions = groupdocs_editor_cloud.SpreadsheetSaveOptions()
saveOptions.file_info = fileInfo
saveOptions.output_path = "output/edited.xlsx"
saveOptions.html_path = loadResult.html_path
saveOptions.resources_path = loadResult.resources_path
saveResult = editApi.save(groupdocs_editor_cloud.SaveRequest(saveOptions))
# Done
print("Document edited: " + saveResult.path)
# For complete examples and data files, please go to https://github.com/groupdocs-editor-cloud/groupdocs-editor-cloud-python-samples
import groupdocs_editor_cloud
app_sid = "XXXX-XXXX-XXXX-XXXX" # Get AppKey and AppSID from https://dashboard.groupdocs.cloud
app_key = "XXXXXXXXXXXXXXXX" # Get AppKey and AppSID from https://dashboard.groupdocs.cloud
editApi = groupdocs_editor_cloud.EditApi.from_keys(app_sid, app_key)
fileApi = groupdocs_editor_cloud.FileApi.from_keys(app_sid, app_key)
# The document already uploaded into the storage.
# Load it into editable state
fileInfo = groupdocs_editor_cloud.FileInfo("Text/document.txt")
loadOptions = groupdocs_editor_cloud.TextLoadOptions()
loadOptions.file_info = fileInfo
loadOptions.output_path = "output"
loadResult = editApi.load(groupdocs_editor_cloud.LoadRequest(loadOptions))
# Download html document
htmlFile = fileApi.download_file(groupdocs_editor_cloud.DownloadFileRequest(loadResult.html_path))
html = ""
with open(htmlFile, 'r') as file:
html = file.read()
# Edit something...
html = html.replace("Page Text", "New Text")
# Upload html back to storage
with open(htmlFile, 'w') as file:
file.write(html)
fileApi.upload_file(groupdocs_editor_cloud.UploadFileRequest(loadResult.html_path, htmlFile))
# Save html back to txt
saveOptions = groupdocs_editor_cloud.TextSaveOptions()
saveOptions.file_info = fileInfo
saveOptions.output_path = "output/edited.txt"
saveOptions.html_path = loadResult.html_path
saveOptions.resources_path = loadResult.resources_path
saveResult = editApi.save(groupdocs_editor_cloud.SaveRequest(saveOptions))
# Done
print("Document edited: " + saveResult.path)
# For complete examples and data files, please go to https://github.com/groupdocs-editor-cloud/groupdocs-editor-cloud-python-samples
import groupdocs_editor_cloud
app_sid = "XXXX-XXXX-XXXX-XXXX" # Get AppKey and AppSID from https://dashboard.groupdocs.cloud
app_key = "XXXXXXXXXXXXXXXX" # Get AppKey and AppSID from https://dashboard.groupdocs.cloud
editApi = groupdocs_editor_cloud.EditApi.from_keys(app_sid, app_key)
fileApi = groupdocs_editor_cloud.FileApi.from_keys(app_sid, app_key)
# The document already uploaded into the storage.
# Load it into editable state
fileInfo = groupdocs_editor_cloud.FileInfo("WordProcessing/password-protected.docx", None, None, "password")
loadOptions = groupdocs_editor_cloud.WordProcessingLoadOptions()
loadOptions.file_info = fileInfo
loadOptions.output_path = "output"
loadResult = editApi.load(groupdocs_editor_cloud.LoadRequest(loadOptions))
# Download html document
htmlFile = fileApi.download_file(groupdocs_editor_cloud.DownloadFileRequest(loadResult.html_path))
html = ""
with open(htmlFile, 'r') as file:
html = file.read()
# Edit something...
html = html.replace("Sample test text", "Hello world")
# Upload html back to storage
with open(htmlFile, 'w') as file:
file.write(html)
fileApi.upload_file(groupdocs_editor_cloud.UploadFileRequest(loadResult.html_path, htmlFile))
# Save html back to docx
saveOptions = groupdocs_editor_cloud.WordProcessingSaveOptions()
saveOptions.file_info = fileInfo
saveOptions.output_path = "output/edited.docx"
saveOptions.html_path = loadResult.html_path
saveOptions.resources_path = loadResult.resources_path
saveResult = editApi.save(groupdocs_editor_cloud.SaveRequest(saveOptions))
# Done
print("Document edited: " + saveResult.path)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.