Browse our Products

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

Installation

Le package est disponible sur Packagist et peut être installé via Composer en exécutant la commande suivante :

composer require groupdocscloud/groupdocs-annotation-cloud

Packagist Version Packagist Downloads PHP-GroupDocsCloud


Exigences

  • PHP 8.2 ou version ultérieure
  • Composer
  • Extensions PHP — curl, json, mbstring
  • Identifiants GroupDocs Cloud — Client ID et Client Secret depuis le Dashboard

Dépendances

Le SDK requiert les packages suivants :

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

Démarrage rapide

Obtenez vos identifiants API

Pour utiliser GroupDocs.Annotation Cloud, inscrivez-vous sur le GroupDocs.Cloud Dashboard et obtenez votre Client ID et Client Secret.

Initialiser l’API

Utilisez le code suivant pour commencer à utiliser GroupDocs.Annotation Cloud SDK pour 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);

Consultez l’exemple complet dans Utils.php.

Ajouter une annotation de champ de texte

Une fois initialisé, utilisez cet exemple de base pour ajouter une annotation de champ de texte à un document Word stocké dans GroupDocs Cloud.

<?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";

Consultez l’exemple complet dans AddTextFieldAnnotation.php.

Ajouter une annotation de zone

Cet exemple ajoute une annotation de zone à un document 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";

Consultez l’exemple complet dans AddAreaAnnotation.php.

Supprimer des annotations

Cet exemple supprime les annotations 1, 2 et 3 d’un document.

<?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";

Consultez l’exemple complet dans DeleteAnnotations.php.

Obtenir les formats de fichiers pris en charge

Récupérez les formats d’annotation pris en charge.

<?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";
}

Consultez l’exemple complet dans GetSupportedFormats.php.

Exemples sur GitHub

Le dépôt GroupDocs.Annotation Cloud PHP Examples inclut des exemples prêts à l’emploi couvrant :

CatégorieExemples
Ajouter des annotationsChamp de texte, zone, flèche, distance, ellipse, image, lien, point, polyligne, caviardage de ressources, soulignement ondulé, surlignage, remplacement, barré, soulignement, filigrane ; annotations multiples ; annotation directe
Gérer les annotationsExtraire les annotations, supprimer les annotations
Aperçu du documentObtenir les pages, supprimer les pages
Utilisation de baseFormats pris en charge, informations sur le document
Fichiers, dossiers et stockageTéléverser, télécharger, copier, déplacer, supprimer ; opérations sur les dossiers et le stockage

Comment exécuter les exemples

  1. Clonez ou téléchargez le dépôt d’exemples
  2. Modifiez Examples/Utils.php et définissez votre ClientId et ClientSecret
  3. Accédez au répertoire Examples
  4. Exécutez composer update
  5. Exécutez php RunExamples.php

Pour plus de détails, consultez 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



 Français