浏览我们的产品

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-annotation-cloud

Packagist Version Packagist Downloads PHP-GroupDocsCloud


要求

  • PHP 8.2 或更高版本
  • 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.Annotation Cloud,请在GroupDocs.Cloud Dashboard注册并获取您的Client ID和Client Secret。

初始化API

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

<?php

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

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

$annotateApi = new GroupDocs\Annotation\AnnotateApi($configuration);

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

添加文本字段注释

初始化后,使用此基本示例向存储在 GroupDocs Cloud 中的 Word 文档添加文本字段注释。

<?php

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

use GroupDocs\Annotation\Model;
use GroupDocs\Annotation\Model\Requests;

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

$annotateApi = new GroupDocs\Annotation\AnnotateApi($configuration);

$a = new Model\AnnotationInfo();
$pt = new Model\Point();
$pt->setX(1);
$pt->setY(1);
$a->setAnnotationPosition($pt);
$box = new Model\Rectangle();
$box->setX(100);
$box->setY(100);
$box->setWidth(200);
$box->setHeight(100);
$a->setBox($box);
$a->setPageNumber(0);
$a->setFontColor(1201033);
$a->setFontSize(12);
$a->setOpacity(0.7);
$a->setType(Model\AnnotationInfo::TYPE_TEXT_FIELD);
$a->setText("Text field text");
$a->setCreatorName("Anonym A.");

$fileInfo = new Model\FileInfo();
$fileInfo->setFilePath("annotationdocs\\one-page.docx");

$options = new Model\AnnotateOptions();
$options->setFileInfo($fileInfo);
$options->setAnnotations([$a]);
$options->setOutputPath("Output\\output.docx");

$request = new Requests\annotateRequest($options);
$result = $annotateApi->annotate($request);

echo "Text field annotation added: " . $result->getHref() . "\n";

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

添加区域注释

此示例向 Word 文档添加区域注释。

<?php

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

use GroupDocs\Annotation\Model;
use GroupDocs\Annotation\Model\Requests;

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

$annotateApi = new GroupDocs\Annotation\AnnotateApi($configuration);

$a = new Model\AnnotationInfo();
$pt = new Model\Point();
$pt->setX(1);
$pt->setY(1);
$a->setAnnotationPosition($pt);
$box = new Model\Rectangle();
$box->setX(100);
$box->setY(100);
$box->setWidth(200);
$box->setHeight(100);
$a->setBox($box);
$a->setPageNumber(0);
$a->setPenColor(1201033);
$a->setPenStyle(Model\AnnotationInfo::PEN_STYLE_SOLID);
$a->setPenWidth(1);
$a->setOpacity(0.7);
$a->setType(Model\AnnotationInfo::TYPE_AREA);
$a->setText("This is area annotation");
$a->setCreatorName("Anonym A.");

$fileInfo = new Model\FileInfo();
$fileInfo->setFilePath("annotationdocs\\one-page.docx");

$options = new Model\AnnotateOptions();
$options->setFileInfo($fileInfo);
$options->setAnnotations([$a]);
$options->setOutputPath("Output\\output.docx");

$request = new Requests\annotateRequest($options);
$result = $annotateApi->annotate($request);

echo "Area annotation added: " . $result->getHref() . "\n";

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

移除注释

此示例从文档中移除注释 1、2 和 3。

<?php

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

use GroupDocs\Annotation\Model;
use GroupDocs\Annotation\Model\Requests;

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

$annotateApi = new GroupDocs\Annotation\AnnotateApi($configuration);

$fileInfo = new Model\FileInfo();
$fileInfo->setFilePath("input\\input.docx");

$options = new Model\RemoveOptions();
$options->setFileInfo($fileInfo);
$options->setAnnotationIds([1, 2, 3]);
$options->setOutputPath("Output\\output.docx");

$request = new Requests\removeAnnotationsRequest($options);
$result = $annotateApi->removeAnnotations($request);

echo "Annotations deleted: " . $result->getHref() . "\n";

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

获取支持的文件格式

检索支持的注释格式。

<?php

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

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

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

$response = $infoApi->getSupportedFileFormats();

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

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

GitHub 上的示例

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

CategoryExamples
添加注释文本字段、区域、箭头、距离、椭圆、图像、链接、点、折线、资源编辑、波浪线、高亮、替换、删除线、下划线、水印;多个注释;直接注释
管理注释提取注释、删除注释
文档预览获取页面、删除页面
基本用法支持的格式、文档信息
文件、文件夹和存储上传、下载、复制、移动、删除;文件夹和存储操作

如何运行示例

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

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


Product Docs Swagger Examples Blog Support Dashboard


Tags

Document Annotation API | PHP Cloud API | GroupDocs.Annotation Cloud | REST API | Text Field Annotation | Area Annotation | Remove Annotations | Highlight Annotation | Redaction | PDF Annotation | Word Annotation | Supported File Formats | Document Information | Cloud Storage | Secure API Access



 简体中文