GroupDocs.Editor Cloud SDK for Python 使开发者能够更轻松地在基于 Python 的应用中通过与 GroupDocs.Editor Cloud REST API 集成来加入文档编辑功能。只需在任意前端 HTML 编辑器中使用 GroupDocs.Editor Cloud API 获取受支持的文档类型(Microsoft Word、Excel 电子表格、PowerPoint、TXT、HTML、XML),即可执行高级文档编辑操作,并在编辑后将文档保存回原始格式。
GroupDocs.Editor Cloud SDK for Python 构建在 GroupDocs.Editor Cloud REST API 之上,作为一层抽象,能够通过管理底层请求和处理响应,为您节省宝贵的开发时间。开发者只需在项目中根据需要编写特定代码即可。
如果您正在寻找用于在云端标注文件的源代码,请查看GroupDocs.Editor Cloud SDK 用于 Python 在 GitHub。
您可以尝试 GroupDocs.Editor低代码 Python APIs,且没有任何限制。
GroupDocs.Editor Cloud 也提供 Docker 镜像,可用于自托管该服务。或者,您可以使用GroupDocs.Editor 高代码 APIs(https://products.groupdocs.com/editor/)来构建自己的服务,该服务目前驱动我们的 REST APIs。
//Get your App SID, App Key and Storage Name at https://dashboard.groupdocs.cloud (free registration is required).
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)