浏览我们的产品

If so you can download any of the below versions for testing. The product will function as normal except for an evaluation limitation. At the time of purchase we provide a license file via email that will allow the product to work in its full capacity. If you would also like an evaluation license to test without any restrictions for 30 days, please follow the directions provided here.


Product Docs Swagger Examples Blog Support Dashboard

安装

该软件包在Packagist可用,可以通过执行以下命令通过 Composer 安装:

composer require groupdocscloud/groupdocs-merger-cloud

Packagist Version Packagist Downloads PHP-GroupDocsCloud


要求

  • PHP 8.1 或更高版本
  • Composer
  • PHP 扩展 — curl, json, mbstring
  • GroupDocs Cloud 凭证 — Client ID and Client Secret 来自仪表板

依赖关系

SDK需要以下软件包:

PackageConstraint
guzzlehttp/guzzle^6.5.8 or ^7.4.5
ext-curl*
ext-json*
ext-mbstring*

快速入门

获取您的 API 凭证

要使用GroupDocs.Merger Cloud,请在GroupDocs.Cloud Dashboard注册并获取您的Client ID和Client Secret。

初始化API

使用以下代码开始使用GroupDocs.Merger Cloud SDK for PHP:

<?php

require_once(__DIR__ . '/vendor/autoload.php');

// Get your ClientId and ClientSecret at https://dashboard.groupdocs.cloud
$configuration = new GroupDocs\Merger\Configuration();
$configuration->setAppSid("YourClientId");
$configuration->setAppKey("YourClientSecret");
$configuration->setApiBaseUrl("https://api.groupdocs.cloud");

$documentApi = new GroupDocs\Merger\DocumentApi($configuration);

请参阅 CommonUtils.php 中的完整示例。

合并多个文档

初始化后,使用此基本示例将来自云存储的 Word 文档合并为一个文件。

<?php

require_once(__DIR__ . '/vendor/autoload.php');

use GroupDocs\Merger\Model;
use GroupDocs\Merger\Model\Requests;

$configuration = new GroupDocs\Merger\Configuration();
$configuration->setAppSid("YourClientId");
$configuration->setAppKey("YourClientSecret");
$configuration->setApiBaseUrl("https://api.groupdocs.cloud");

$documentApi = new GroupDocs\Merger\DocumentApi($configuration);

$fileInfo1 = new Model\FileInfo();
$fileInfo1->setFilePath("WordProcessing/four-pages.docx");
$item1 = new Model\JoinItem();
$item1->setFileInfo($fileInfo1);

$fileInfo2 = new Model\FileInfo();
$fileInfo2->setFilePath("WordProcessing/one-page.docx");
$item2 = new Model\JoinItem();
$item2->setFileInfo($fileInfo2);

$options = new Model\JoinOptions();
$options->setJoinItems([$item1, $item2]);
$options->setOutputPath("Output/joined.docx");

$request = new Requests\joinRequest($options);
$response = $documentApi->join($request);

echo "Output file path: " . $response->getPath() . "\n";

请参阅 JoinMultipleDocuments.php 中的完整示例。

将文档拆分为单页

此示例将 Word 文档的第 1 页和第 3 页拆分为单独的文件。

<?php

require_once(__DIR__ . '/vendor/autoload.php');

use GroupDocs\Merger\Model;
use GroupDocs\Merger\Model\Requests;

$configuration = new GroupDocs\Merger\Configuration();
$configuration->setAppSid("YourClientId");
$configuration->setAppKey("YourClientSecret");
$configuration->setApiBaseUrl("https://api.groupdocs.cloud");

$documentApi = new GroupDocs\Merger\DocumentApi($configuration);

$fileInfo = new Model\FileInfo();
$fileInfo->setFilePath("WordProcessing/sample-10-pages.docx");

$options = new Model\SplitOptions();
$options->setFileInfo($fileInfo);
$options->setOutputPath("Output/split-document");
$options->setPages([1, 3]);
$options->setMode(Model\SplitOptions::MODE_PAGES);

$request = new Requests\splitRequest($options);
$response = $documentApi->split($request);

echo "Documents count: " . count($response->getDocuments()) . "\n";

请参阅 SplitToSinglePages.php 中的完整示例。

旋转文档页面

此示例旋转 PDF 文档中的选定页面。

<?php

require_once(__DIR__ . '/vendor/autoload.php');

use GroupDocs\Merger\Model;
use GroupDocs\Merger\Model\Requests;

$configuration = new GroupDocs\Merger\Configuration();
$configuration->setAppSid("YourClientId");
$configuration->setAppKey("YourClientSecret");
$configuration->setApiBaseUrl("https://api.groupdocs.cloud");

$pagesApi = new GroupDocs\Merger\PagesApi($configuration);

$fileInfo = new Model\FileInfo();
$fileInfo->setFilePath("Pdf/ten-pages.pdf");

$options = new Model\RotateOptions();
$options->setFileInfo($fileInfo);
$options->setOutputPath("Output/rotate-pages.pdf");
$options->setPages([2, 4]);
$options->setMode(Model\RotateOptions::MODE_ROTATE90);

$request = new Requests\rotateRequest($options);
$response = $pagesApi->rotate($request);

echo "Output file path: " . $response->getPath() . "\n";

请参阅 RotatePages.php 中的完整示例。

获取支持的文件类型

检索支持的文件类型。

<?php

require_once(__DIR__ . '/vendor/autoload.php');

$configuration = new GroupDocs\Merger\Configuration();
$configuration->setAppSid("YourClientId");
$configuration->setAppKey("YourClientSecret");
$configuration->setApiBaseUrl("https://api.groupdocs.cloud");

$infoApi = new GroupDocs\Merger\InfoApi($configuration);

$response = $infoApi->getSupportedFileFormats();

foreach ($response->getFormats() as $format) {
    echo $format->getFileFormat() . " - " . $format->getExtension() . "\n";
}

请参阅 GetSupportedFileTypes.php 中的完整示例。

GitHub 上的示例

GroupDocs.Merger Cloud PHP 示例 存储库包含可立即运行的示例,涵盖:

CategoryExamples
信息支持的文件类型、文档信息、许可证用量
文档操作合并多个文档、跨格式合并、合并页面、合并图像、连续 Word 合并、混合页面、拆分文档、预览、导入附件
页面操作提取页面、移动页面、删除页面、旋转页面、交换页面、更改方向
安全操作添加、删除和更新密码;检查密码保护

如何运行示例

  1. 克隆或下载示例存储库
  2. 编辑Examples/CommonUtils.php并设置您的ClientId和ClientSecret
  3. 进入Examples目录
  4. 运行composer update
  5. 执行php RunExamples.php

欲了解更多详情,请访问Getting Started。


Product Docs Swagger Examples Blog Support Dashboard


标签

Document Merging API | PHP Cloud API | GroupDocs.Merger Cloud | REST API | Page Manipulation | Document Security | Password Protection | Cloud Storage Integration | File Operations | Folder Operations | Document Splitting | PDF Merging | Cross-format Merging | Word Document Merging | Excel File Merging | Presentation Merging | Document Reorganization | Secure API Access | Document Joining | Document Manipulation API | Merge Multiple Formats | Cross-platform API



 简体中文