@fdgfdgdfg
Please note that you need to pass the cloud storage file path to fileinfo
parameter instead of your local(project) file path. Please check the following sample code to upload a local file to the cloud storage and get the page count of a document; you can amend it as per your requirements. Hopefully, it will help you accomplish the task.
<?php
require_once('D:\xampp\htdocs\groupdocs-viewer-cloud-php-master\vendor\autoload.php');
//require_once(__DIR__ . '/vendor/autoload.php');
//Get Client Id and Client Secret from https://dashboard.groupdocs.cloud
$myClientId = "xxxxx-xxxx-xxxx-xxxx-xxxxxxxx";
$myClientSecret = "xxxxxxxxxxxxxxxxxxxxxxxxx";
// Create instance of the API
$configuration = new GroupDocs\Viewer\Configuration();
$configuration->setAppSid($myClientId);
$configuration->setAppKey($myClientSecret);
$infoApi = new GroupDocs\Viewer\InfoApi($configuration);
$fileApi = new GroupDocs\Viewer\FileApi($configuration);
try {
//Upload local file to cloud storage
$localfile = 'data/4pages.pdf';
$remotefile = 'Temp/4pages.pdf';
$uploadrequest = new GroupDocs\Viewer\Model\Requests\UploadFileRequest($remotefile,$localfile);
$uploadresponse = $fileApi->uploadFile($uploadrequest);
// Get Document Info
$viewOptions = new GroupDocs\Viewer\Model\ViewOptions();
$fileInfo = new GroupDocs\Viewer\Model\FileInfo();
$fileInfo->setFilePath($remotefile);
$viewOptions->setFileInfo($fileInfo);
$request = new GroupDocs\Viewer\Model\Requests\GetInfoRequest($viewOptions);
$response = $infoApi->getInfo($request);
echo 'page count of the document - ' . count($response->getpages());
} catch (Exception $e) {
echo "Something went wrong: ", $e->getMessage(), "\n";
PHP_EOL;
}
?>