Skip to content

Instantly share code, notes, and snippets.

@groupdocscloud
Last active September 27, 2018 13:51
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save groupdocscloud/91cf9bb641d8b967c65ee1f2eb626f2e to your computer and use it in GitHub Desktop.
Save groupdocscloud/91cf9bb641d8b967c65ee1f2eb626f2e to your computer and use it in GitHub Desktop.
This Gist contains PHP examples of GroupDocs.Annotation Cloud
Annotation-PHP
//TODO: Get your AppSID and AppKey at https://dashboard.groupdocs.cloud (free registration is required).
$configuration = new Configuration();
$configuration->setAppSid($sid);
$configuration->setAppKey($key);
$imagePagesApi= new ImagePagesApi($configuration);
try {
$request = new Requests\DeletePagesRequest("Annotated.pdf","SourceFiles");
$response = $imagePagesApi->deletePages($request);
echo "Process Completed";
} catch (Exception $e) {
echo "Something went wrong: ", $e->getMessage(), "\n";
PHP_EOL;
}
//TODO: Get your AppSID and AppKey at https://dashboard.groupdocs.cloud (free registration is required).
$configuration = new Configuration();
$configuration->setAppSid($sid);
$configuration->setAppKey($key);
$annotationApi = new AnnotationApi($configuration);
//ini_set('MAX_EXECUTION_TIME', 3600);
try {
$request = new Requests\DeleteCleanDocumentRequest("one-page-annotated.pdf","SourceFiles");
$response = $annotationApi->deleteCleanDocument($request);
echo $response;
} catch (Exception $e) {
echo "Something went wrong: ", $e->getMessage(), "\n";
PHP_EOL;
}
//TODO: Get your AppSID and AppKey at https://dashboard.groupdocs.cloud (free registration is required).
$configuration = new Configuration();
$configuration->setAppSid($sid);
$configuration->setAppKey($key);
$imageInfoApi= new ImageInfoApi($configuration);
try {
$request = new Requests\GetInfoRequest("one-page-annotated.pdf","SourceFiles");
$response = $imageInfoApi->getInfo($request);
echo $response;
} catch (Exception $e) {
echo "Something went wrong: ", $e->getMessage(), "\n";
PHP_EOL;
}
//TODO: Get your AppSID and AppKey at https://dashboard.groupdocs.cloud (free registration is required).
$configuration = new Configuration();
$configuration->setAppSid($sid);
$configuration->setAppKey($key);
$annotationApi = new AnnotationApi($configuration);
$annotationPosition = new Model\Point(["x" => 852, "y" => 154.31]);
$reply1 = new Model\AnnotationReplyInfo(["message" => "reply text", "repliedOn" => time(), "userName" => "Admin"]);
$reply2 = new Model\AnnotationReplyInfo(["message" => "reply2 text", "repliedOn" => time(), "userName" => "Commentator"]);
$box = new Model\Rectangle(["x" => 173.29, "y" => 154.31, "width" => 142.5, "height" => 9]);
$annotation = new Model\AnnotationInfo(["annotationPosition" => $annotationPosition,
"replies" => [$reply1, $reply2],
"box" => $box,
"pageNumber" => 0,
"svgPath" => "[{\"x\":173.2986,\"y\":687.5769},{\"x\":315.7985,\"y\":687.5769},{\"x\":173.2986,\"y\":678.5769},{\"x\":315.7985,\"y\":678.5769}]",
"type" => 'Text',
"creatorName" => "Anonym A."]);
try {
$request = new Requests\PutExportRequest("Annotated.pdf", json_encode([$annotation]),"SourceFiles");
$response = $annotationApi->putExport($request);
echo $response->getFileInfo();
} catch (Exception $e) {
echo "Something went wrong: ", $e->getMessage(), "\n";
PHP_EOL;
}
//TODO: Get your AppSID and AppKey at https://dashboard.groupdocs.cloud (free registration is required).
$configuration = new Configuration();
$configuration->setAppSid($sid);
$configuration->setAppKey($key);
$imagePagesApi= new ImagePagesApi($configuration);
try {
$request = new Requests\GetPageRequest("Annotated.pdf","0","SourceFiles");
$response = $imagePagesApi->getPage($request);
echo $response;
} catch (Exception $e) {
echo "Something went wrong: ", $e->getMessage(), "\n";
PHP_EOL;
}
$configuration = new Configuration();
$configuration->setAppSid($sid);
$configuration->setAppKey($key);
$imagePagesApi= new ImagePagesApi($configuration);
try {
$request = new Requests\GetPagesRequest("Annotated.pdf","SourceFiles");
$response = $imagePagesApi->getPages($request);
echo $response;
} catch (Exception $e) {
echo "Something went wrong: ", $e->getMessage(), "\n";
PHP_EOL;
}
//TODO: Get your AppSID and AppKey at https://dashboard.groupdocs.cloud (free registration is required).
$configuration = new Configuration();
$configuration->setAppSid($sid);
$configuration->setAppKey($key);
$annotationApi = new AnnotationApi($configuration);
try {
$request = new Requests\GetImportRequest("one-page-annotated.pdf","SourceFiles");
$response = $annotationApi->getImport($request);
echo $response;
//echo json_encode($response);
//$string=implode('|',$response);
//echo $string;
//foreach($response as $x => $value) {
// echo $value;}
echo '<pre>';
print_r($response);
echo '</pre>';
} catch (Exception $e) {
echo "Something went wrong: ", $e->getMessage(), "\n";
PHP_EOL;
}
//TODO: Get your AppSID and AppKey at https://dashboard.groupdocs.cloud (free registration is required).
$configuration = new Configuration();
$configuration->setAppSid($sid);
$configuration->setAppKey($key);
$pdfFileApi= new PdfFileApi($configuration);
try {
$request = new Requests\GetPdfRequest("one-page-annotated.docx","SourceFiles");
$response = $pdfFileApi->getPdf($request);
echo "Process Completed";
} catch (Exception $e) {
echo "Something went wrong: ", $e->getMessage(), "\n";
PHP_EOL;
}
//TODO: Get your AppSID and AppKey at https://dashboard.groupdocs.cloud (free registration is required).
$configuration = new Configuration();
$configuration->setAppSid($sid);
$configuration->setAppKey($key);
$pdfFileApi= new PdfFileApi($configuration);
try {
$request = new Requests\GetPdfStreamRequest("one-page-annotated.docx","SourceFiles");
$response = $pdfFileApi->getPdfStream($request);
echo $response;
} catch (Exception $e) {
echo "Something went wrong: ", $e->getMessage(), "\n";
PHP_EOL;
}
//TODO: Get your AppSID and AppKey at https://dashboard.groupdocs.cloud (free registration is required).
$configuration = new Configuration();
$configuration->setAppSid($sid);
$configuration->setAppKey($key);
$imagePagesApi= new ImagePagesApi($configuration);
try {
$request = new Requests\PostPagesRequest("Annotated.pdf","SourceFiles");
$response = $imagePagesApi->postPages($request);
echo $response;
} catch (Exception $e) {
echo "Something went wrong: ", $e->getMessage(), "\n";
PHP_EOL;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment