GroupDocs.Editor 雲產品系列

對於雲開發者來說又一個好消息! GroupDocs 推出了文檔編輯雲 API。這改進了 GroupDocs 的文檔編輯解決方案。該解決方案已經作為本地 API 供 .NET 和 Java 開發人員使用,並作為跨平台在線應用程序 供任何類型的用戶免費在線編輯文檔。 GroupDocs.Editor Cloud API 和 SDK 允許開發人員使用前端所見即所得編輯器來編輯大多數流行的文檔格式,而無需任何其他應用程序。

GroupDocs.Editor Cloud 是 REST API,提供許多編輯選項和輸出自定義,以自定義各種文檔類型的編輯過程。一些主要功能包括:

  • 在流程或分頁模式下編輯文字處理文檔。
  • 管理字體提取以提供相同的用戶體驗。
  • 大文件的內存使用優化。
  • 支持多選項卡電子表格。
  • 靈活的數字和日期轉換。
  • URI 和電子郵件地址識別。

要更好地了解功能和產品,您可以隨時訪問 文檔 部分中的開發人員指南。

支持的文檔類型

以下是當前支持的文檔格式。您可以隨時訪問 GroupDocs.Editor Cloud 的文檔,了解所有支持的文檔格式

SDK 和示例

除了Cloud文檔編輯REST API之外,GroupDocs還提供開源SDK,因此可以根據需求進行自定義。開發者可以使用cURL與GroupDocs.Editor Cloud API進行交互,也可以使用相關的SDK來加快開發速度。這有助於開發人員不再擔心發出請求和處理響應的低級細節。下面提到的 SDK 以及代碼示例可在 GitHub 上獲取

在 C# 中編輯 Word 文檔

您可以在此處查看使用 GroupDocs.Editor Cloud SDK for .NET 編輯 Word 文檔的 C# 代碼示例。使用相關的可用 SDK,可以在 Java、PHP、Python、Ruby 和 Node.js 中輕鬆實現同樣的效果。這只是將源文檔轉換為 HTML 格式並允許編輯,稍後將更新的文檔轉換回原始格式。

// 如需完整示例和數據文件,請訪問 https://github.com/groupdocs-editor-cloud/groupdocs-editor-cloud-dotnet-samples
string MyAppKey = ""; // Get AppKey and AppSID from https://dashboard.groupdocs.cloud
string MyAppSid = ""; // Get AppKey and AppSID from https://dashboard.groupdocs.cloud
  
var configuration = new Configuration(MyAppSid, MyAppKey);
 
// 創建必要的API實例
var editApi = new EditApi(configuration );
var fileApi = new FileApi(configuration );
 
// 該文檔已上傳到存儲中。
// 將其加載為可編輯狀態
var loadOptions = new WordProcessingLoadOptions
{
    FileInfo = new FileInfo
    {
        FilePath = "WordProcessing/password-protected.docx",
        Password = "password"
    },
    OutputPath = "output"
};
var loadResult = editApi.Load(new LoadRequest(loadOptions));
 
// 下載html文檔
var stream = fileApi.DownloadFile(new DownloadFileRequest(loadResult.HtmlPath));
var htmlString = new StreamReader(stream, Encoding.UTF8).ReadToEnd();
 
// 編輯一些東西...
htmlString = htmlString.Replace("Sample test text", "Hello world");
 
// 將 html 上傳回存儲
fileApi.UploadFile(new UploadFileRequest(loadResult.HtmlPath,
    new MemoryStream(Encoding.UTF8.GetBytes(htmlString))));
 
// 將 html 保存回 docx
var saveOptions = new WordProcessingSaveOptions
{
    FileInfo = loadOptions.FileInfo,
    OutputPath = "output/edited.docx",
    HtmlPath = loadResult.HtmlPath,
    ResourcesPath = loadResult.ResourcesPath
};
var saveResult = editApi.Save(new SaveRequest(saveOptions));

用 Java 更新 Excel 電子表格文檔

下面的代碼片段展示瞭如何使用 GroupDocs.Editor Cloud SDK for Java 在 Java 應用程序中快速編輯電子表格文檔。

// 如需完整示例和數據文件,請訪問 https://github.com/groupdocs-editor-cloud/groupdocs-editor-cloud-java-samples
String MyAppKey = ""; // Get AppKey and AppSID from https://dashboard.groupdocs.cloud
String MyAppSid = ""; // Get AppKey and AppSID from https://dashboard.groupdocs.cloud
  
Configuration configuration = new Configuration(MyAppSid, MyAppKey);
 
 
// 創建必要的API實例
EditApi editApi = new EditApi(configuration);
FileApi fileApi = new FileApi(configuration);
 
// 該文檔已上傳到存儲中。
// 將其加載為可編輯狀態
FileInfo fileInfo = new FileInfo();
fileInfo.setFilePath("Spreadsheet/four-sheets.xlsx");           
SpreadsheetLoadOptions loadOptions = new SpreadsheetLoadOptions();
loadOptions.setFileInfo(fileInfo);
loadOptions.setOutputPath("output");
LoadResult loadResult = editApi.load(new LoadRequest(loadOptions));
 
// 下載html文檔
File file = fileApi.downloadFile(new DownloadFileRequest(loadResult.getHtmlPath(), null, null));
             
// 編輯一些東西...
List<String> lines = Files.readAllLines(file.toPath());
List<String> newLines = new ArrayList<String>();
for (String line : lines) {
    newLines.add(line.replaceAll("This is sample sheet", "This is sample sheep"));
}
Files.write(file.toPath(), newLines);
 
// 將 html 上傳回存儲
fileApi.uploadFile(new UploadFileRequest(loadResult.getHtmlPath(), file, Common.MYStorage));
 
// 將 html 保存回 xlsx
SpreadsheetSaveOptions saveOptions = new SpreadsheetSaveOptions();
saveOptions.setFileInfo(fileInfo);
saveOptions.setOutputPath("output/edited.xlsx");    
saveOptions.setHtmlPath(loadResult.getHtmlPath());      
saveOptions.setResourcesPath(loadResult.getResourcesPath());
DocumentResult saveResult = editApi.save(new SaveRequest(saveOptions));
 
System.out.println("Document edited: " + saveResult.getPath());

用 Python 編輯演示文稿

以下代碼示例展示瞭如何在 Python 中編輯 PowerPoint 或 OpenDocument 演示文稿。

# 如需完整示例和數據文件,請訪問 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)
 
# 該文檔已上傳到存儲中。
# 將其加載為可編輯狀態
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))        
 
# 下載html文檔
htmlFile = fileApi.download_file(groupdocs_editor_cloud.DownloadFileRequest(loadResult.html_path))
html = ""       
with open(htmlFile, 'r') as file:
    html = file.read()
 
# 編輯一些東西...    
html = html.replace("Slide sub-heading", "Hello world!")
 
# 將 html 上傳回存儲
with open(htmlFile, 'w') as file:
    file.write(html)
 
fileApi.upload_file(groupdocs_editor_cloud.UploadFileRequest(loadResult.html_path, htmlFile))
 
# 將 html 保存回 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))
 
# 完畢
print("Document edited: " + saveResult.path)

資源

以下是相關資源的一些重要鏈接:

很高興在這裡見到您有關文檔編輯雲 API 的信息。如果您感到任何困難或有任何困惑或提出一些好的建議,您可以在論壇上自由聯繫我們。謝謝。