Skip to content

Instantly share code, notes, and snippets.

@groupdocscloud
Last active October 23, 2019 11:35
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save groupdocscloud/9d23670221e0b7b3882f3f3bab9baf9e to your computer and use it in GitHub Desktop.
Save groupdocscloud/9d23670221e0b7b3882f3f3bab9baf9e to your computer and use it in GitHub Desktop.
Annotation-PHP-v2
<?php
include(dirname(__DIR__) . '\CommonUtils.php');
try {
$apiInstance = CommonUtils::GetAnnotateApiInstance();
$a = new GroupDocs\Annotation\Model\AnnotationInfo();
$pt = new GroupDocs\Annotation\Model\Point();
$pt->setX(852);
$pt->setY(59.388262910798119);
$a->setAnnotationPosition($pt);
$box = new GroupDocs\Annotation\Model\Rectangle();
$box->setX(375.89276123046875);
$box->setY(59.388263702392578);
$box->setWidth(88.7330551147461);
$box->setHeight(37.7290153503418);
$a->setBox($box);
$a->setPageNumber(0);
$a->setPenColor(1201033);
$a->setPenStyle(0);
$a->setPenWidth(1);
$a->setType(GroupDocs\Annotation\Model\AnnotationInfo::TYPE_AREA);
$a->setCreatorName("Anonym A.");
$request = new GroupDocs\Annotation\Model\Requests\postAnnotationsRequest("annotationdocs\\ten-pages.docx", [$a]);
$apiInstance->postAnnotations($request);
echo "Expected response type is void: Annotation added.";
} catch (Exception $e) {
echo "Something went wrong: ", $e->getMessage(), "\n";
}
<?php
include(dirname(__DIR__) . '\CommonUtils.php');
try {
$apiInstance = CommonUtils::GetAnnotateApiInstance();
$a = new GroupDocs\Annotation\Model\AnnotationInfo();
$pt = new GroupDocs\Annotation\Model\Point();
$pt->setX(852);
$pt->setY(59.388262910798119);
$a->setAnnotationPosition($pt);
$box = new GroupDocs\Annotation\Model\Rectangle();
$box->setX(375.89276123046875);
$box->setY(59.388263702392578);
$box->setWidth(88.7330551147461);
$box->setHeight(37.7290153503418);
$a->setBox($box);
$a->setPageNumber(2);
$a->setPenColor(1201033);
$a->setPenStyle(0);
$a->setPenWidth(1);
$a->setOpacity(0.7);
$a->setType(GroupDocs\Annotation\Model\AnnotationInfo::TYPE_AREA);
$a->setText("This is area annotation");
$a->setCreatorName("Anonym A.");
$request = new GroupDocs\Annotation\Model\Requests\postAnnotationsRequest("annotationdocs\\ten-pages.docx", [$a]);
$apiInstance->postAnnotations($request);
echo "Expected response type is void: Area Annotation added.";
} catch (Exception $e) {
echo "Something went wrong: ", $e->getMessage(), "\n";
}
<?php
include(dirname(__DIR__) . '\CommonUtils.php');
try {
$apiInstance = CommonUtils::GetAnnotateApiInstance();
$a = new GroupDocs\Annotation\Model\AnnotationInfo();
$pt = new GroupDocs\Annotation\Model\Point();
$pt->setX(852);
$pt->setY(59.388262910798119);
$a->setAnnotationPosition($pt);
$box = new GroupDocs\Annotation\Model\Rectangle();
$box->setX(375.89276123046875);
$box->setY(59.388263702392578);
$box->setWidth(88.7330551147461);
$box->setHeight(37.7290153503418);
$a->setBox($box);
$a->setPageNumber(2);
$a->setPenColor(1201033);
$a->setPenStyle(0);
$a->setPenWidth(1);
$a->setOpacity(0.7);
$a->setType(GroupDocs\Annotation\Model\AnnotationInfo::TYPE_ARROW);
$a->setText("This is arrow annotation");
$a->setCreatorName("Anonym A.");
$request = new GroupDocs\Annotation\Model\Requests\postAnnotationsRequest("annotationdocs\\ten-pages.docx", [$a]);
$apiInstance->postAnnotations($request);
echo "Expected response type is void: Arrow Annotation added.";
} catch (Exception $e) {
echo "Something went wrong: ", $e->getMessage(), "\n";
}
<?php
include(dirname(__DIR__) . '\CommonUtils.php');
try {
$apiInstance = CommonUtils::GetAnnotateApiInstance();
$a = new GroupDocs\Annotation\Model\AnnotationInfo();
$pt = new GroupDocs\Annotation\Model\Point();
$pt->setX(852);
$pt->setY(59.388262910798119);
$a->setAnnotationPosition($pt);
$box = new GroupDocs\Annotation\Model\Rectangle();
$box->setX(375.89276123046875);
$box->setY(59.388263702392578);
$box->setWidth(88.7330551147461);
$box->setHeight(37.7290153503418);
$a->setBox($box);
$a->setPageNumber(2);
$a->setPenColor(1201033);
$a->setPenStyle(0);
$a->setPenWidth(1);
$a->setOpacity(0.7);
$a->setType(GroupDocs\Annotation\Model\AnnotationInfo::TYPE_DISTANCE);
$a->setText("This is distance annotation");
$a->setCreatorName("Anonym A.");
$request = new GroupDocs\Annotation\Model\Requests\postAnnotationsRequest("annotationdocs\\ten-pages.docx", [$a]);
$apiInstance->postAnnotations($request);
echo "Expected response type is void: Distance Annotation added.";
} catch (Exception $e) {
echo "Something went wrong: ", $e->getMessage(), "\n";
}
<?php
include(dirname(__DIR__) . '\CommonUtils.php');
try {
$apiInstance = CommonUtils::GetAnnotateApiInstance();
$a = new GroupDocs\Annotation\Model\AnnotationInfo();
$pt = new GroupDocs\Annotation\Model\Point();
$pt->setX(852);
$pt->setY(59.388262910798119);
$a->setAnnotationPosition($pt);
$box = new GroupDocs\Annotation\Model\Rectangle();
$box->setX(375.89276123046875);
$box->setY(59.388263702392578);
$box->setWidth(88.7330551147461);
$box->setHeight(37.7290153503418);
$a->setBox($box);
$a->setPageNumber(0);
$a->setPenColor(1201033);
$a->setPenStyle(0);
$a->setPenWidth(1);
$a->setOpacity(0.7);
$a->setType(GroupDocs\Annotation\Model\AnnotationInfo::TYPE_DISTANCE);
$a->setText("This is distance annotation");
$a->setCreatorName("Anonym A.");
$a1 = new GroupDocs\Annotation\Model\AnnotationInfo();
$pt = new GroupDocs\Annotation\Model\Point();
$pt->setX(852);
$pt->setY(59.388262910798119);
$a1->setAnnotationPosition($pt);
$box = new GroupDocs\Annotation\Model\Rectangle();
$box->setX(375.89276123046875);
$box->setY(59.388263702392578);
$box->setWidth(88.7330551147461);
$box->setHeight(37.7290153503418);
$a1->setBox($box);
$a1->setPageNumber(2);
$a1->setPenColor(1201033);
$a1->setPenStyle(0);
$a1->setPenWidth(1);
$a1->setOpacity(0.7);
$a1->setType(GroupDocs\Annotation\Model\AnnotationInfo::TYPE_AREA);
$a1->setText("This is area annotation");
$a1->setCreatorName("Anonym A.");
$a2 = new GroupDocs\Annotation\Model\AnnotationInfo();
$pt = new GroupDocs\Annotation\Model\Point();
$pt->setX(852);
$pt->setY(59.388262910798119);
$a2->setAnnotationPosition($pt);
$box = new GroupDocs\Annotation\Model\Rectangle();
$box->setX(375.89276123046875);
$box->setY(59.388263702392578);
$box->setWidth(88.7330551147461);
$box->setHeight(37.7290153503418);
$a2->setBox($box);
$a2->setPageNumber(4);
$a2->setOpacity(0.7);
$a2->setType(GroupDocs\Annotation\Model\AnnotationInfo::TYPE_POINT);
$a2->setText("This is point annotation");
$a2->setCreatorName("Anonym A.");
$a3 = new GroupDocs\Annotation\Model\AnnotationInfo();
$pt = new GroupDocs\Annotation\Model\Point();
$pt->setX(852);
$pt->setY(59.388262910798119);
$a3->setAnnotationPosition($pt);
$box = new GroupDocs\Annotation\Model\Rectangle();
$box->setX(375.89276123046875);
$box->setY(59.388263702392578);
$box->setWidth(88.7330551147461);
$box->setHeight(37.7290153503418);
$a3->setBox($box);
$a1->setPageNumber(5);
$a1->setPenColor(1201033);
$a1->setPenStyle(0);
$a1->setPenWidth(1);
$a3->setOpacity(0.7);
$a3->setType(GroupDocs\Annotation\Model\AnnotationInfo::TYPE_ARROW);
$a3->setText("This is arrow annotation");
$a3->setCreatorName("Anonym A.");
$request = new GroupDocs\Annotation\Model\Requests\postAnnotationsRequest("annotationdocs\\ten-pages.docx", [$a, $a1, $a2, $a3]);
$apiInstance->postAnnotations($request);
echo "Expected response type is void: Multiple Annotations added.";
} catch (Exception $e) {
echo "Something went wrong: ", $e->getMessage(), "\n";
}
<?php
include(dirname(__DIR__) . '\CommonUtils.php');
try {
$apiInstance = CommonUtils::GetAnnotateApiInstance();
$a = new GroupDocs\Annotation\Model\AnnotationInfo();
$pt = new GroupDocs\Annotation\Model\Point();
$pt->setX(852);
$pt->setY(59.388262910798119);
$a->setAnnotationPosition($pt);
$box = new GroupDocs\Annotation\Model\Rectangle();
$box->setX(375.89276123046875);
$box->setY(59.388263702392578);
$box->setWidth(88.7330551147461);
$box->setHeight(37.7290153503418);
$a->setBox($box);
$a->setPageNumber(2);
$a->setOpacity(0.7);
$a->setType(GroupDocs\Annotation\Model\AnnotationInfo::TYPE_POINT);
$a->setText("This is point annotation");
$a->setCreatorName("Anonym A.");
$request = new GroupDocs\Annotation\Model\Requests\postAnnotationsRequest("annotationdocs\\ten-pages.docx", [$a]);
$apiInstance->postAnnotations($request);
echo "Expected response type is void: Point Annotation added.";
} catch (Exception $e) {
echo "Something went wrong: ", $e->getMessage(), "\n";
}
<?php
include(dirname(__DIR__) . '\CommonUtils.php');
try {
$apiInstance = CommonUtils::GetAnnotateApiInstance();
$a = new GroupDocs\Annotation\Model\AnnotationInfo();
$pt = new GroupDocs\Annotation\Model\Point();
$pt->setX(852);
$pt->setY(59.388262910798119);
$a->setAnnotationPosition($pt);
$box = new GroupDocs\Annotation\Model\Rectangle();
$box->setX(375.89276123046875);
$box->setY(59.388263702392578);
$box->setWidth(88.7330551147461);
$box->setHeight(37.7290153503418);
$a->setBox($box);
$a->setPageNumber(2);
$a->setPenColor(1201033);
$a->setPenStyle(0);
$a->setPenWidth(1);
$a->setOpacity(0.7);
$a->setType(GroupDocs\Annotation\Model\AnnotationInfo::TYPE_POLYLINE);
$a->setText("This is polyline annotation");
$a->setCreatorName("Anonym A.");
$request = new GroupDocs\Annotation\Model\Requests\postAnnotationsRequest("annotationdocs\\ten-pages.docx", [$a]);
$apiInstance->postAnnotations($request);
echo "Expected response type is void: Polyline Annotation added.";
} catch (Exception $e) {
echo "Something went wrong: ", $e->getMessage(), "\n";
}
<?php
include(dirname(__DIR__) . '\CommonUtils.php');
try {
$apiInstance = CommonUtils::GetAnnotateApiInstance();
$a = new GroupDocs\Annotation\Model\AnnotationInfo();
$pt = new GroupDocs\Annotation\Model\Point();
$pt->setX(852);
$pt->setY(59.388262910798119);
$a->setAnnotationPosition($pt);
$box = new GroupDocs\Annotation\Model\Rectangle();
$box->setX(375.89276123046875);
$box->setY(59.388263702392578);
$box->setWidth(88.7330551147461);
$box->setHeight(37.7290153503418);
$a->setBox($box);
$a->setPageNumber(2);
$a->setFontColor(1201033);
$a->setFontSize(12);
$a->setOpacity(0.7);
$a->setType(GroupDocs\Annotation\Model\AnnotationInfo::TYPE_TEXT);
$a->setText("This is text annotation");
$a->setCreatorName("Anonym A.");
$request = new GroupDocs\Annotation\Model\Requests\postAnnotationsRequest("annotationdocs\\ten-pages.docx", [$a]);
$apiInstance->postAnnotations($request);
echo "Expected response type is void: Text Annotation added.";
} catch (Exception $e) {
echo "Something went wrong: ", $e->getMessage(), "\n";
}
<?php
include(dirname(__DIR__) . '\CommonUtils.php');
try {
$apiInstance = CommonUtils::GetAnnotateApiInstance();
$a = new GroupDocs\Annotation\Model\AnnotationInfo();
$pt = new GroupDocs\Annotation\Model\Point();
$pt->setX(852);
$pt->setY(59.388262910798119);
$a->setAnnotationPosition($pt);
$box = new GroupDocs\Annotation\Model\Rectangle();
$box->setX(375.89276123046875);
$box->setY(59.388263702392578);
$box->setWidth(88.7330551147461);
$box->setHeight(37.7290153503418);
$a->setBox($box);
$a->setPageNumber(2);
$a->setFontColor(1201033);
$a->setFontSize(12);
$a->setOpacity(0.7);
$a->setType(GroupDocs\Annotation\Model\AnnotationInfo::TYPE_TEXT_FIELD);
$a->setText("This is text field annotation");
$a->setFieldText("Text field text");
$a->setCreatorName("Anonym A.");
$request = new GroupDocs\Annotation\Model\Requests\postAnnotationsRequest("annotationdocs\\ten-pages.docx", [$a]);
$apiInstance->postAnnotations($request);
echo "Expected response type is void: Text Field Annotation added.";
} catch (Exception $e) {
echo "Something went wrong: ", $e->getMessage(), "\n";
}
<?php
include(dirname(__DIR__) . '\CommonUtils.php');
try {
$apiInstance = CommonUtils::GetAnnotateApiInstance();
$a = new GroupDocs\Annotation\Model\AnnotationInfo();
$pt = new GroupDocs\Annotation\Model\Point();
$pt->setX(852);
$pt->setY(59.388262910798119);
$a->setAnnotationPosition($pt);
$box = new GroupDocs\Annotation\Model\Rectangle();
$box->setX(375.89276123046875);
$box->setY(59.388263702392578);
$box->setWidth(88.7330551147461);
$box->setHeight(37.7290153503418);
$a->setBox($box);
$a->setPageNumber(2);
$a->setFontColor(1201033);
$a->setFontSize(12);
$a->setOpacity(0.7);
$a->setType(GroupDocs\Annotation\Model\AnnotationInfo::TYPE_TEXT_REDACTION);
$a->setText("This is text redaction annotation");
$a->setCreatorName("Anonym A.");
$request = new GroupDocs\Annotation\Model\Requests\postAnnotationsRequest("annotationdocs\\ten-pages.docx", [$a]);
$apiInstance->postAnnotations($request);
echo "Expected response type is void: Text Redaction Annotation added.";
} catch (Exception $e) {
echo "Something went wrong: ", $e->getMessage(), "\n";
}
<?php
include(dirname(__DIR__) . '\CommonUtils.php');
try {
$apiInstance = CommonUtils::GetAnnotateApiInstance();
$a = new GroupDocs\Annotation\Model\AnnotationInfo();
$pt = new GroupDocs\Annotation\Model\Point();
$pt->setX(852);
$pt->setY(59.388262910798119);
$a->setAnnotationPosition($pt);
$box = new GroupDocs\Annotation\Model\Rectangle();
$box->setX(375.89276123046875);
$box->setY(59.388263702392578);
$box->setWidth(88.7330551147461);
$box->setHeight(37.7290153503418);
$a->setBox($box);
$a->setPageNumber(2);
$a->setFontColor(1201033);
$a->setFontSize(12);
$a->setOpacity(0.7);
$a->setType(GroupDocs\Annotation\Model\AnnotationInfo::TYPE_TEXT_REPLACEMENT);
$a->setText("This is text replacement annotation");
$a->setFieldText("Text to replacement");
$a->setCreatorName("Anonym A.");
$request = new GroupDocs\Annotation\Model\Requests\postAnnotationsRequest("annotationdocs\\ten-pages.docx", [$a]);
$apiInstance->postAnnotations($request);
echo "Expected response type is void: Text Replacement Annotation added.";
} catch (Exception $e) {
echo "Something went wrong: ", $e->getMessage(), "\n";
}
<?php
include(dirname(__DIR__) . '\CommonUtils.php');
try {
$apiInstance = CommonUtils::GetAnnotateApiInstance();
$a = new GroupDocs\Annotation\Model\AnnotationInfo();
$pt = new GroupDocs\Annotation\Model\Point();
$pt->setX(852);
$pt->setY(59.388262910798119);
$a->setAnnotationPosition($pt);
$a->setPageNumber(2);
$a->setFontColor(1201033);
$a->setFontSize(12);
$a->setOpacity(0.7);
$a->setType(GroupDocs\Annotation\Model\AnnotationInfo::TYPE_TEXT_STRIKEOUT);
$a->setText("This is text strikeout annotation");
$a->setCreatorName("Anonym A.");
$request = new GroupDocs\Annotation\Model\Requests\postAnnotationsRequest("annotationdocs\\ten-pages.docx", [$a]);
$apiInstance->postAnnotations($request);
echo "Expected response type is void: Text Strikeout Annotation added.";
} catch (Exception $e) {
echo "Something went wrong: ", $e->getMessage(), "\n";
}
<?php
include(dirname(__DIR__) . '\CommonUtils.php');
try {
$apiInstance = CommonUtils::GetAnnotateApiInstance();
$a = new GroupDocs\Annotation\Model\AnnotationInfo();
$pt = new GroupDocs\Annotation\Model\Point();
$pt->setX(852);
$pt->setY(59.388262910798119);
$a->setAnnotationPosition($pt);
$a->setPageNumber(2);
$a->setFontColor(1201033);
$a->setFontSize(12);
$a->setOpacity(0.7);
$a->setType(GroupDocs\Annotation\Model\AnnotationInfo::TYPE_TEXT_UNDERLINE);
$a->setText("This is text underline annotation");
$a->setCreatorName("Anonym A.");
$request = new GroupDocs\Annotation\Model\Requests\postAnnotationsRequest("annotationdocs\\ten-pages.docx", [$a]);
$apiInstance->postAnnotations($request);
echo "Expected response type is void: Text Underline Annotation added.";
} catch (Exception $e) {
echo "Something went wrong: ", $e->getMessage(), "\n";
}
<?php
include(dirname(__DIR__) . '\CommonUtils.php');
try {
$apiInstance = CommonUtils::GetAnnotateApiInstance();
$a = new GroupDocs\Annotation\Model\AnnotationInfo();
$pt = new GroupDocs\Annotation\Model\Point();
$pt->setX(852);
$pt->setY(59.388262910798119);
$a->setAnnotationPosition($pt);
$box = new GroupDocs\Annotation\Model\Rectangle();
$box->setX(375.89276123046875);
$box->setY(59.388263702392578);
$box->setWidth(88.7330551147461);
$box->setHeight(37.7290153503418);
$a->setBox($box);
$a->setPageNumber(2);
$a->setFontColor(1201033);
$a->setFontSize(12);
$a->setOpacity(0.7);
$a->setAngle(75);
$a->setType(GroupDocs\Annotation\Model\AnnotationInfo::TYPE_WATERMARK);
$a->setText("This is text watermark annotation");
$a->setCreatorName("Anonym A.");
$request = new GroupDocs\Annotation\Model\Requests\postAnnotationsRequest("annotationdocs\\ten-pages.docx", [$a]);
$apiInstance->postAnnotations($request);
echo "Expected response type is void: Text Watermark Annotation added.";
} catch (Exception $e) {
echo "Something went wrong: ", $e->getMessage(), "\n";
}
<?php
// Required dependencies and include autoload.php
require_once(__DIR__ . '\vendor\autoload.php');
// Common class to hold the constants and static functions
class CommonUtils {
// TODO: Get your AppSID and AppKey at https://dashboard.groupdocs.cloud (free registration is required)
static $AppSid = 'XXXXX-XXXXX-XXXXX-XXXXX-XXXXX';
static $AppKey = 'XXXXXXXXXXXXXXXXXXXX';
static $ApiBaseUrl = 'https://api.groupdocs.cloud';
static $MyStorage = 'XXXXX';
// Getting the Annotate API Instance
public static function GetAnnotateApiInstance() {
// intializing the configuration
$configuration = new GroupDocs\Annotation\Configuration();
// Seting the configurations
$configuration->setAppSid(CommonUtils::$AppSid);
$configuration->setAppKey(CommonUtils::$AppKey);
$configuration->setApiBaseUrl(CommonUtils::$ApiBaseUrl);
// Retrun the new AnnotateApi instance
return new GroupDocs\Annotation\AnnotateApi($configuration);
}
// Getting the Preview API Instance
public static function GetPreviewApiInstance() {
// intializing the configuration
$configuration = new GroupDocs\Annotation\Configuration();
// Seting the configurations
$configuration->setAppSid(CommonUtils::$AppSid);
$configuration->setAppKey(CommonUtils::$AppKey);
$configuration->setApiBaseUrl(CommonUtils::$ApiBaseUrl);
// Retrun the new AnnotateApi instance
return new GroupDocs\Annotation\PreviewApi($configuration);
}
// Getting the Info API Instance
public static function GetInfoApiInstance() {
// intializing the configuration
$configuration = new GroupDocs\Annotation\Configuration();
// Seting the configurations
$configuration->setAppSid(CommonUtils::$AppSid);
$configuration->setAppKey(CommonUtils::$AppKey);
$configuration->setApiBaseUrl(CommonUtils::$ApiBaseUrl);
// Retrun the new InfoApi instance
return new GroupDocs\Annotation\InfoApi($configuration);
}
// Getting the Annotation StorageAPI API Instance
public static function GetStorageApiInstance() {
// intializing the configuration
$configuration = new GroupDocs\Annotation\Configuration();
// Seting the configurations
$configuration->setAppSid(CommonUtils::$AppSid);
$configuration->setAppKey(CommonUtils::$AppKey);
// Retrun the new StorageApi instance
return new GroupDocs\Annotation\StorageApi($configuration);
}
// Getting the Annotation FolderAPI API Instance
public static function GetFolderApiInstance() {
// intializing the configuration
$configuration = new GroupDocs\Annotation\Configuration();
// Seting the configurations
$configuration->setAppSid(CommonUtils::$AppSid);
$configuration->setAppKey(CommonUtils::$AppKey);
// Retrun the new FolderApi instance
return new GroupDocs\Annotation\FolderApi($configuration);
}
// Getting the Annotation FileAPI API Instance
public static function GetFileApiInstance() {
// intializing the configuration
$configuration = new GroupDocs\Annotation\Configuration();
// Seting the configurations
$configuration->setAppSid(CommonUtils::$AppSid);
$configuration->setAppKey(CommonUtils::$AppKey);
// Retrun the new FileApi instance
return new GroupDocs\Annotation\FileApi($configuration);
}
}
<?php
include(dirname(__DIR__) . '\CommonUtils.php');
try {
$apiInstance = CommonUtils::GetFileApiInstance();
$request = new GroupDocs\Annotation\Model\Requests\CopyFileRequest("annotationdocs\one-page.docx", "annotationdocs\one-page-copied.docx", CommonUtils::$MyStorage, CommonUtils::$MyStorage);
$apiInstance->copyFile($request);
echo "Expected response type is Void: 'annotationdocs/one-page.docx' file copied as 'annotationdocs/one-page-copied.docx'.";
} catch (Exception $e) {
echo "Something went wrong: ", $e->getMessage(), "\n";
}
?>
<?php
include(dirname(__DIR__) . '\CommonUtils.php');
try {
$apiInstance = CommonUtils::GetFolderApiInstance();
$request = new GroupDocs\Annotation\Model\Requests\CopyFolderRequest("annotationdocs", "annotationdocs1", CommonUtils::$MyStorage, CommonUtils::$MyStorage);
$apiInstance->copyFolder($request);
echo "Expected response type is Void: 'annotationdocs' folder copied as 'annotationdocs1'.", "<br />";
} catch (Exception $e) {
echo "Something went wrong: ", $e->getMessage(), "\n";
}
?>
<?php
include(dirname(__DIR__) . '\CommonUtils.php');
try {
$apiInstance = CommonUtils::GetFolderApiInstance();
$request = new GroupDocs\Annotation\Model\Requests\CreateFolderRequest("annotationdocs", CommonUtils::$MyStorage);
$apiInstance->createFolder($request);
echo "Expected response type is Void: 'annotationdocs' folder created.", "<br />";
} catch (Exception $e) {
echo "Something went wrong: ", $e->getMessage(), "\n";
}
?>
<?php
include(dirname(__DIR__) . '\CommonUtils.php');
try {
$apiInstance = CommonUtils::GetAnnotateApiInstance();
$request = new GroupDocs\Annotation\Model\Requests\DeleteAnnotationsRequest("annotationdocs\\ten-pages.docx");
$apiInstance->deleteAnnotations($request);
echo "Expected response type is Void: Annotation deleted from document.";
} catch (Exception $e) {
echo "Something went wrong: ", $e->getMessage(), "\n";
}
<?php
include(dirname(__DIR__) . '\CommonUtils.php');
try {
$apiInstance = CommonUtils::GetFileApiInstance();
$request = new GroupDocs\Annotation\Model\Requests\DeleteFileRequest("annotationdocs\one-page-copied.docx", CommonUtils::$MyStorage);
$apiInstance->deleteFile($request);
echo "Expected response type is Void: 'annotationdocs1/one-page-copied.docx' file deleted.";
} catch (Exception $e) {
echo "Something went wrong: ", $e->getMessage(), "\n";
}
?>
<?php
include(dirname(__DIR__) . '\CommonUtils.php');
try {
$apiInstance = CommonUtils::GetFolderApiInstance();
$request = new GroupDocs\Annotation\Model\Requests\DeleteFolderRequest("annotationdocs1\\annotationdocs1", CommonUtils::$MyStorage, true);
$apiInstance->deleteFolder($request);
echo "Expected response type is Void: 'annotationdocs1/annotationdocs1' folder deleted recursively.", "<br />";
} catch (Exception $e) {
echo "Something went wrong: ", $e->getMessage(), "\n";
}
?>
<?php
include(dirname(__DIR__) . '\CommonUtils.php');
try {
$apiInstance = CommonUtils::GetPreviewApiInstance();
$request = new GroupDocs\Annotation\Model\Requests\DeletePagesRequest("annotationdocs\\ten-pages.docx");
$response = $apiInstance->deletePages($request);
echo "Expected response type is Void: pages deleted.";
} catch (Exception $e) {
echo "Something went wrong: ", $e->getMessage(), "\n";
}
<?php
include(dirname(__DIR__) . '\CommonUtils.php');
try {
$apiInstance = CommonUtils::GetFileApiInstance();
$request = new GroupDocs\Annotation\Model\Requests\DownloadFileRequest("annotationdocs\one-page.docx", CommonUtils::$MyStorage, null);
$response = $apiInstance->downloadFile($request);
echo "Expected response type is File: ", strlen($response);
} catch (Exception $e) {
echo "Something went wrong: ", $e->getMessage(), "\n";
}
?>
<?php
include(dirname(__DIR__) . '\CommonUtils.php');
try {
$apiInstance = CommonUtils::GetAnnotateApiInstance();
$request = new GroupDocs\Annotation\Model\Requests\GetExportRequest("annotationdocs\\ten-pages.docx", null, null, null, null, "");
$response = $apiInstance->getExport($request);
echo "Expected response type is File: ", $response->getSize();
} catch (Exception $e) {
echo "Something went wrong: ", $e->getMessage(), "\n";
}
<?php
include(dirname(__DIR__) . '\CommonUtils.php');
try {
$apiInstance = CommonUtils::GetStorageApiInstance();
$request = new GroupDocs\Annotation\Model\Requests\GetDiscUsageRequest(CommonUtils::$MyStorage);
$response = $apiInstance->getDiscUsage($request);
echo "Expected response type is DiscUsage: ", $response;
} catch (Exception $e) {
echo "Something went wrong: ", $e->getMessage(), "\n";
}
?>
<?php
include(dirname(__DIR__) . '\CommonUtils.php');
try {
$apiInstance = CommonUtils::GetInfoApiInstance();
$request = new GroupDocs\Annotation\Model\Requests\getInfoRequest("annotationdocs\\ten-pages.docx", "");
$response = $apiInstance->getInfo($request);
echo "Path: ", $response->getPath();
} catch (Exception $e) {
echo "Something went wrong: ", $e->getMessage(), "\n";
}
<?php
include(dirname(__DIR__) . '\CommonUtils.php');
try {
$apiInstance = CommonUtils::GetAnnotateApiInstance();
$request = new GroupDocs\Annotation\Model\Requests\GetExportRequest("annotationdocs\\ten-pages.docx", null, true, 1, 2, "");
$response = $apiInstance->getExport($request);
echo "Expected response type is File: ", $response->getSize();
} catch (Exception $e) {
echo "Something went wrong: ", $e->getMessage(), "\n";
}
<?php
include(dirname(__DIR__) . '\CommonUtils.php');
try {
$apiInstance = CommonUtils::GetStorageApiInstance();
$request = new GroupDocs\Annotation\Model\Requests\GetFileVersionsRequest("annotationdocs\one-page.docx", CommonUtils::$MyStorage);
$response = $apiInstance->getFileVersions($request);
echo "Expected response type is FileVersions: ", $response;
} catch (Exception $e) {
echo "Something went wrong: ", $e->getMessage(), "\n";
}
?>
<?php
include(dirname(__DIR__) . '\CommonUtils.php');
try {
$apiInstance = CommonUtils::GetFolderApiInstance();
$request = new GroupDocs\Annotation\Model\Requests\GetFilesListRequest("annotationdocs", CommonUtils::$MyStorage);
$response = $apiInstance->getFilesList($request);
echo "Expected response type is FilesList.", "<br />";
foreach($response->getValue() as $storageFile) {
echo "Files: ", $storageFile->getPath(), "<br />";
}
} catch (Exception $e) {
echo "Something went wrong: ", $e->getMessage(), "\n";
}
?>
<?php
include(dirname(__DIR__) . '\CommonUtils.php');
try {
$apiInstance = CommonUtils::GetPreviewApiInstance();
$request = new GroupDocs\Annotation\Model\Requests\GetPagesRequest("annotationdocs\\ten-pages.docx", null, null, null, null, null, null, "");
$response = $apiInstance->getPages($request);
echo "Expected response type is PageImages Count: ", $response->getTotalCount();
} catch (Exception $e) {
echo "Something went wrong: ", $e->getMessage(), "\n";
}
<?php
include(dirname(__DIR__) . '\CommonUtils.php');
try {
$apiInstance = CommonUtils::GetAnnotateApiInstance();
$request = new GroupDocs\Annotation\Model\Requests\GetPdfRequest("annotationdocs\\ten-pages.docx");
$response = $apiInstance->getPdf($request);
echo "Expected response type is File: ", $response->getSize();
} catch (Exception $e) {
echo "Something went wrong: ", $e->getMessage(), "\n";
}
<?php
include(dirname(__DIR__) . '\CommonUtils.php');
try {
$apiInstance = CommonUtils::GetInfoApiInstance();
$response = $apiInstance->getSupportedFileFormats();
echo '<b>Supported file formats<br /></b>';
foreach($response->getFormats() as $key => $format) {
echo $format->getFileFormat(), "(", $format->getExtension(), ")<br />";
}
} catch (Exception $e) {
echo "Something went wrong: ", $e->getMessage(), "\n";
}
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>GroupDocs.Annotation Cloud SDK - Php Examples</title>
</head>
<body>
<h1>
GroupDocs.Annotation Cloud SDK - Php Examples</h1>
<p>
Please first provide the <b>AppSid</b> & <b>AppKey</b> in <b>'CommonUtils.php'</b> and then <a href="Annotation_Php_Upload_Resoruces.php" target="_blank">click here</a> to upload the test files to your default storage<br/>Click on the link to execute the examples for respective outputs.</p>
<ul>
<li>
<h3>
Supported File Formats</h3>
<ol>
<li><a href="Supported_File_Formats/Annotation_Php_Get_Supported_Formats.php" target="_blank">Get_All_Supported_Formats</a></li>
</ol>
</li>
<li>
<h3>
Document Information</h3>
<ol>
<li><a href="Document_Information/Annotation_Php_Get_Document_Information.php" target="_blank">Get_Document_Information</a></li>
</ol>
</li>
<li>
<h3>
Working with Storage</h3>
<ol>
<li><a href="Working_With_Storage/Annotation_Php_Storage_Exist.php" target="_blank">Storage_Exist</a></li>
<li><a href="Working_With_Storage/Annotation_Php_Object_Exists.php" target="_blank">Object_Exists</a></li>
<li><a href="Working_With_Storage/Annotation_Php_Get_File_Versions.php" target="_blank">Get_File_Versions</a></li>
<li><a href="Working_With_Storage/Annotation_Php_Get_Disc_Usage.php" target="_blank">Get_Disc_Usage</a></li>
</ol>
</li>
<li>
<h3>
Working with Folder</h3>
<ol>
<li><a href="Working_With_Folder/Annotation_Php_Create_Folder.php" target="_blank">Create_Folder</a></li>
<li><a href="Working_With_Folder/Annotation_Php_Copy_Folder.php" target="_blank">Copy_Folder</a></li>
<li><a href="Working_With_Folder/Annotation_Php_Get_Files_List.php" target="_blank">Get_Files_List</a></li>
<li><a href="Working_With_Folder/Annotation_Php_Move_Folder.php" target="_blank">Move_Folder</a></li>
<li><a href="Working_With_Folder/Annotation_Php_Delete_Folder.php" target="_blank">Delete_Folder</a></li>
</ol>
</li>
<li>
<h3>
Working with Files</h3>
<ol>
<li><a href="Working_With_Files/Annotation_Php_Upload_File.php" target="_blank">Upload_File</a></li>
<li><a href="Working_With_Files/Annotation_Php_Copy_File.php" target="_blank">Copy_File</a></li>
<li><a href="Working_With_Files/Annotation_Php_Download_File.php" target="_blank">Download_File</a></li>
<li><a href="Working_With_Files/Annotation_Php_Move_File.php" target="_blank">Move_File</a></li>
<li><a href="Working_With_Files/Annotation_Php_Delete_File.php" target="_blank">Delete_File</a></li>
</ol>
</li>
<li>
<h3>
Working with Annotations</h3>
<ol>
<li><a href="Working_With_Annotations/Annotation_Php_Add_Multiple_Annotations.php" target="_blank">Add_Multiple_Annotations</a></li>
<li><a href="Working_With_Annotations/Annotation_Php_Add_Area_Annotation.php" target="_blank">Add_Area_Annotation</a></li>
<li><a href="Working_With_Annotations/Annotation_Php_Add_Arrow_Annotation.php" target="_blank">Add_Arrow_Annotation</a></li>
<li><a href="Working_With_Annotations/Annotation_Php_Add_Distance_Annotation.php" target="_blank">Add_Distance_Annotation</a></li>
<li><a href="Working_With_Annotations/Annotation_Php_Add_Point_Annotation.php" target="_blank">Add_Point_Annotation</a></li>
<li><a href="Working_With_Annotations/Annotation_Php_Add_Polyline_Annotation.php" target="_blank">Add_Polyline_Annotation</a></li>
<li><a href="Working_With_Annotations/Annotation_Php_Add_Text_Annotation.php" target="_blank">Add_Text_Annotation</a></li>
<li><a href="Working_With_Annotations/Annotation_Php_Add_TextField_Annotation.php" target="_blank">Add_Text_Field_Annotation</a></li>
<li><a href="Working_With_Annotations/Annotation_Php_Add_TextReplacement_Annotation.php" target="_blank">Add_Text_Replacement_Annotation</a></li>
<li><a href="Working_With_Annotations/Annotation_Php_Add_TextRedaction_Annotation.php" target="_blank">Add_Text_Redaction_Annotation</a></li>
<li><a href="Working_With_Annotations/Annotation_Php_Add_TextStrikeout_Annotation.php" target="_blank">Add_Text_Strikeout_Annotation</a></li>
<li><a href="Working_With_Annotations/Annotation_Php_Add_TextUnderline_Annotation.php" target="_blank">Add_Text_Underline_Annotation</a></li>
<li><a href="Working_With_Annotations/Annotation_Php_Add_Watermark_Annotation.php" target="_blank">Add_Watermark_Annotation</a></li>
<li><a href="Working_With_Annotations/Annotation_Php_Get_Annotation.php" target="_blank">Get_Annotation</a></li>
<li><a href="Working_With_Annotations/Annotation_Php_Get_Export_Document.php" target="_blank">Get_Export_Document</a></li>
<li><a href="Working_With_Annotations/Annotation_Php_Get_PDF.php" target="_blank">Get_PDF</a></li>
<li><a href="Working_With_Annotations/Annotation_Php_Delete_Annotation.php" target="_blank">Delete_Annotation</a></li>
</ol>
</li>
<li>
<h3>
Working with Pages</h3>
<ol>
<li><a href="Working_With_Pages/Annotation_Php_Get_Pages.php" target="_blank">Get_Pages</a></li>
<li><a href="Working_With_Pages/Annotation_Php_Delete_Pages.php" target="_blank">Delete_Pages</a></li>
</ol>
</li>
</ul>
</body>
</html>
<?php
include(dirname(__DIR__) . '\CommonUtils.php');
try {
$apiInstance = CommonUtils::GetFileApiInstance();
$request = new GroupDocs\Annotation\Model\Requests\MoveFileRequest("annotationdocs\one-page.docx", "annotationdocs1\one-page-copied.docx", CommonUtils::$MyStorage, CommonUtils::$MyStorage);
$apiInstance->moveFile($request);
echo "Expected response type is Void: 'annotationdocs/one-page.docx' file moved as 'annotationdocs1/one-page-copied.docx'.";
} catch (Exception $e) {
echo "Something went wrong: ", $e->getMessage(), "\n";
}
?>
<?php
include(dirname(__DIR__) . '\CommonUtils.php');
try {
$apiInstance = CommonUtils::GetFolderApiInstance();
$request = new GroupDocs\Annotation\Model\Requests\MoveFolderRequest("annotationdocs1", "annotationdocs1\\annotationdocs1", CommonUtils::$MyStorage, CommonUtils::$MyStorage, true);
$apiInstance->moveFolder($request);
echo "Expected response type is Void: 'annotationdocs1' folder moved to 'annotationdocs1/annotationdocs1'.", "<br />";
} catch (Exception $e) {
echo "Something went wrong: ", $e->getMessage(), "\n";
}
?>
<?php
include(dirname(__DIR__) . '\CommonUtils.php');
try {
$apiInstance = CommonUtils::GetStorageApiInstance();
$request = new GroupDocs\Annotation\Model\Requests\ObjectExistsRequest("annotationdocs\one-page.docx", CommonUtils::$MyStorage);
$response = $apiInstance->objectExists($request);
echo "Expected response type is ObjectExist: ", $response;
} catch (Exception $e) {
echo "Something went wrong: ", $e->getMessage(), "\n";
}
?>
<?php
include(dirname(__DIR__) . '\CommonUtils.php');
try {
$apiInstance = CommonUtils::GetStorageApiInstance();
$request = new GroupDocs\Annotation\Model\Requests\StorageExistsRequest(CommonUtils::$MyStorage);
$response = $apiInstance->storageExists($request);
echo "Expected response type is StorageExist: ", $response;
} catch (Exception $e) {
echo "Something went wrong: ", $e->getMessage(), "\n";
}
?>
<?php
include(dirname(__DIR__) . '\CommonUtils.php');
try {
$apiInstance = CommonUtils::GetFileApiInstance();
$filePath = realpath(dirname(__DIR__). '\Resources\annotationdocs\one-page.docx');
echo "filePath: ". $filePath;
$fileStream = readfile($filePath);
$request = new GroupDocs\Annotation\Model\Requests\UploadFileRequest("annotationdocs\one-page1.docx", $fileStream);
$response = $apiInstance->uploadFile($request);
echo "Expected response type is FilesUploadResult: ", $response;
} catch (Exception $e) {
echo "Something went wrong: ", $e->getMessage(), "\n";
}
?>
<?php
include(__DIR__ . '\CommonUtils.php');
try {
$storageApi = CommonUtils::GetStorageApiInstance();
$fileApi = CommonUtils::GetFileApiInstance();
$folder = realpath(__DIR__ . '\Resources');
$filePathInStorage = "";
$dir_iterator = new \RecursiveDirectoryIterator($folder);
$iterator = new \RecursiveIteratorIterator($dir_iterator, \RecursiveIteratorIterator::SELF_FIRST);
echo 'Uploading file process executing....<br />';
foreach ($iterator as $file) {
if (!$file->isDir()) {
$filePath = $file->getPathName();
$filePathInStorage = str_replace($folder . '\\', "", $filePath);
echo $filePathInStorage;
echo "<br>";
$isExistRequest = new \GroupDocs\Annotation\Model\Requests\objectExistsRequest($filePathInStorage);
$isExistResponse = $storageApi->objectExists($isExistRequest);
if (!$isExistResponse->getExists()) {
$putCreateRequest = new \GroupDocs\Annotation\Model\Requests\uploadFileRequest($filePathInStorage, $filePath);
$putCreateResponse = $fileApi->uploadFile($putCreateRequest);
}
}
}
} catch (Exception $e) {
echo "Something went wrong: ", $e->getMessage(), "\n";
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment