文档编辑器 REST API 和 PHP Cloud SDK

Cloud REST API 可快速编辑所有流行文档格式,适用于任何类型的 PHP 应用,无需安装任何外部软件。

  • GroupDocs.Editor 用于 cURL
  • GroupDocs.Editor 用于 .NET
  • GroupDocs.Editor 用于 Java
  • GroupDocs.Editor 用于 Python
  • GroupDocs.Editor 用于 Ruby
  • GroupDocs.Editor 用于 Node.js
  • GroupDocs.Editor 用于 Android
开始免费试用

GroupDocs.Editor Cloud SDK for PHP 支持在 PHP 应用中编辑和操作多种流行文档文件格式。只需将 GroupDocs.Editor Cloud SDK for PHP 与 GroupDocs.Editor Cloud REST API 集成,便可在任意第三方所见即所得 HTML 编辑器中上传受支持的文档,操作文档后将其保存回原始文档格式,且编辑后外观不受影响。PHP 编辑器库支持多种文档格式,包括 Microsoft Word(DOC、DOCX、WordML)、Excel(XLS、XLSX、SpreadsheetML)、演示文稿(PPT、PPTX)、HTML、XML、TXT 和 OpenDocument。

GroupDocs.Editor Cloud SDK for PHP 构建在 GroupDocs.Editor Cloud REST API 之上,作为一层封装,通过管理底层请求和处理响应,为您节省宝贵的开发时间。开发者可以专注于在项目中仅编写所需的特定代码。

常见问题

我想创建自己的 PHP 应用程序来编辑文档吗?

如果您正在寻找用于在云端标注文件的源代码,请查看 GroupDocs.Editor Cloud SDK for PHP at GitHub

我可以在 PHP 上免费试用 GroupDocs.Editor REST APIs 吗?

您可以尝试 GroupDocs.Editor Low-Code PHP APIs,且没有任何限制。

您不想将机密文件上传到任何地方进行编辑吗?您有哪些选项?

GroupDocs.Editor Cloud 也提供 Docker 镜像,可用于 self-host 服务。或者,您可以使用 GroupDocs.Editor High-code APIs(https://products.groupdocs.com/editor/)自行构建服务,该技术目前驱动我们的 REST APIs。

高级文档编辑器 REST API 功能

可轻松集成到任何所见即所得编辑器中

您可以整体编辑 Word 文档,或定义页面范围

支持多标签页的电子表格编辑

针对大型 CSV 或 TSV 文件优化了内存使用

提取文档信息(类型、大小、页数等)

Cloud REST API 可用于任何语言或平台

处理文字处理文档 - PHP

//Get your App SID, App Key and Storage Name at https://dashboard.groupdocs.cloud (free registration is required).
$AppSid = ""; // Get AppKey and AppSID from https://dashboard.groupdocs.cloud
$AppKey = ""; // Get AppKey and AppSID from https://dashboard.groupdocs.cloud
  
$configuration = new GroupDocs\Editor\Configuration();
$configuration->setAppSid($AppSid);
$configuration->setAppKey($AppKey);

$editApi = new GroupDocs\Editor\EditApi($configuration);
$fileApi = new GroupDocs\Editor\FileApi($configuration);

// The document already uploaded into the storage
// Load it into editable state
$fileInfo = new Model\FileInfo();
$fileInfo->setFilePath("Spreadsheet/four-sheets.xlsx");        
$loadOptions = new Model\SpreadsheetLoadOptions();
$loadOptions->setFileInfo($fileInfo);
$loadOptions->setOutputPath("output");
$loadOptions->setWorksheetIndex(0);
$loadResult = $editApi->load(new Requests\loadRequest($loadOptions));

// Download html document
$htmlFile = $fileApi->downloadFile(new Requests\downloadFileRequest($loadResult->getHtmlPath()));
$html = file_get_contents($htmlFile->getRealPath());

// Edit something...
$html = str_replace("This is sample sheet", "This is sample sheep", $html);

// Upload html back to storage
file_put_contents($htmlFile->getRealPath(), $html);
$uploadRequest = new Requests\uploadFileRequest($loadResult->getHtmlPath(), $htmlFile->getRealPath());
$fileApi->uploadFile($uploadRequest);

// Save html back to xlsx
$saveOptions = new Model\SpreadsheetSaveOptions();
$saveOptions->setFileInfo($fileInfo);
$saveOptions->setOutputPath("output/edited.xlsx");
$saveOptions->setHtmlPath($loadResult->getHtmlPath());
$saveOptions->setResourcesPath($loadResult->getResourcesPath());
$saveResult = $editApi->save(new Requests\saveRequest($saveOptions));

// Done.
echo "Document edited: " . $saveResult->getPath();

支持和学习资源

GroupDocs.Editor 为其他流行的开发环境提供文档查看 APIs

  中文
8db490fe0