GroupDocs.Comparison Cloud allows to create document preview images, one per page. Image size and format can be set as options.
API Usage
There are steps that usage of GroupDocs.Comparison Cloud consists of:
Upload input document into cloud storage
Create preview images
Download images
For storage operations, like uploading or downloading documents, please refer to the corresponding articles of this manual.
Swagger UI lets you call this REST API directly from the browser.
cURL REST Example
// First get JSON Web Token
// Please get your Client Id and Client Secret from https://dashboard.groupdocs.cloud/applications. Kindly place Client Id in "client_id" and Client Secret in "client_secret" argument.
curl-v"https://api.groupdocs.cloud/connect/token"\-XPOST\-d"grant_type#client_credentials&client_id#xxxx&client_secret#xxxx"\-H"Content-Type: application/x-www-form-urlencoded"\-H"Accept: application/json"// cURL example to get document information
curl-v"https://api.groupdocs.cloud/v2.0/comparison/preview"\-XPOST\-H"Content-Type: application/json"\-H"Accept: application/json"\-H"Authorization: Bearer <jwt token>"-d"{
'FileInfo': {
'FilePath': 'sample2.pdf'
},
'Format': 'jpeg'
}"
The API is completely independent of your operating system, database system or development language. We provide and support API SDKs in many development languages in order to make it even easier to integrate. You can see our available SDKs list here.
SDK Examples
// For complete examples and data files, please go to https://github.com/groupdocs-comparison-cloud/groupdocs-comparison-cloud-dotnet-samplesstringMyClientSecret="";// Get ClientId and ClientSecret from https://dashboard.groupdocs.cloudstringMyClientId="";// Get ClientId and ClientSecret from https://dashboard.groupdocs.cloudvarconfiguration=newConfiguration(MyClientId,MyClientSecret);varapiInstance=newPreviewApi(configuration);try{varoptions=newPreviewOptions{FileInfo=newFileInfo{FilePath="source_files/word/source.docx"},Format=PreviewOptions.FormatEnum.Png,OutputFolder="output"};varrequest=newPreviewRequest(options);varresponse=apiInstance.Preview(request);Console.WriteLine("Output pages num: "+response.Count);}catch(Exceptione){Console.WriteLine("Exception while calling api: "+e.Message);}
// For complete examples and data files, please go to https://github.com/groupdocs-comparison-cloud/groupdocs-comparison-cloud-java-samples
StringMyClientSecret="";// Get ClientId and ClientSecret from https://dashboard.groupdocs.cloud
StringMyClientId="";// Get ClientId and ClientSecret from https://dashboard.groupdocs.cloud
Configurationconfiguration=newConfiguration(MyClientId,MyClientSecret);PreviewApiapiInstance=newPreviewApi(configuration);try{FileInfofileInfo=newFileInfo();fileInfo.setFilePath("source_files/word/source.docx");PreviewOptionsoptions=newPreviewOptions();options.setFileInfo(fileInfo);options.setFormat(FormatEnum.JPEG);options.setOutputFolder("output");PreviewRequestrequest=newPreviewRequest(options);List<Link>response=apiInstance.preview(request);System.out.println("Output pages count: "+response.size());}catch(ApiExceptione){System.err.println("Exception while calling PreviewApi:");e.printStackTrace();}
// For complete examples and data files, please go to https://github.com/groupdocs-comparison-cloud/groupdocs-comparison-cloud-php-samples
useGroupDocs\Comparison\Model;useGroupDocs\Comparison\Model\Requests;$ClientId="";// Get ClientId and ClientSecret from https://dashboard.groupdocs.cloud
$ClientSecret="";// Get ClientId and ClientSecret from https://dashboard.groupdocs.cloud
$configuration=newGroupDocs\Comparison\Configuration();$configuration->setAppSid($ClientId);$configuration->setAppKey($ClientSecret);$apiInstance=newGroupDocs\Comparison\PreviewApi($configuration);$fileInfo=newModel\FileInfo();$fileInfo->setFilePath("source_files/word/source.docx");$options=newModel\PreviewOptions();$options->setFileInfo($fileInfo);$options->setFormat(Model\PreviewOptions::FORMAT_PNG);$options->setOutputFolder("output");$request=newRequests\PreviewRequest($options);$response=$apiInstance->preview($request);echo"Output file count: ",count($response);echo"\n";
// For complete examples and data files, please go to https://github.com/groupdocs-comparison-cloud/groupdocs-comparison-cloud-node-samples
global.comparison_cloud=require("groupdocs-comparison-cloud");global.clientId="XXXX-XXXX-XXXX-XXXX";// Get ClientId and ClientSecret from https://dashboard.groupdocs.cloud
global.clientSecret="XXXXXXXXXXXXXXXX";// Get ClientId and ClientSecret from https://dashboard.groupdocs.cloud
global.previewApi=comparison_cloud.PreviewApi.fromKeys(clientId,clientSecret);letsource=newcomparison_cloud.FileInfo();source.filePath="source_files/word/source.docx";letoptions=newcomparison_cloud.PreviewOptions();options.fileInfo=source;options.format="png";options.outputFolder="output";letrequest=newcomparison_cloud.PreviewRequest(options);letresponse=awaitpreviewApi.preview(request);console.log("Output file count: "+response.length);
# For complete examples and data files, please go to https://github.com/groupdocs-comparison_cloud-cloud/groupdocs-comparison_cloud-cloud-python-samplesfromgroupdocs_comparison_cloudimport*importgroupdocs_comparison_cloudclient_id="XXXX-XXXX-XXXX-XXXX"# Get ClientId and ClientSecret from https://dashboard.groupdocs.cloudclient_secret="XXXXXXXXXXXXXXXX"# Get ClientId and ClientSecret from https://dashboard.groupdocs.cloudapi_instance=groupdocs_comparison_cloud.PreviewApi.from_keys(client_id,client_secret)source=groupdocs_comparison_cloud.FileInfo()source.file_path="source_files/word/source.docx"options=groupdocs_comparison_cloud.PreviewOptions()options.file_info=sourceoptions.format="jpg"options.output_folder="output"request=groupdocs_comparison_cloud.PreviewRequest(options)response=api_instance.preview(request)print("Output file count: "+str(len(response)))
# For complete examples and data files, please go to https://github.com/groupdocs-comparison-cloud/groupdocs-comparison-cloud-ruby-samplesrequire'groupdocs_comparison_cloud'$client_id="XXXX-XXXX-XXXX-XXXX"# Get ClientId and ClientSecret from https://dashboard.groupdocs.cloud$client_secret="XXXXXXXXXXXXXXXX"# Get ClientId and ClientSecret from https://dashboard.groupdocs.cloudapiInstance=GroupDocsComparisonCloud::PreviewApi.from_keys($client_id,$client_secret)source=GroupDocsComparisonCloud::FileInfo.newsource.file_path="source_files/word/source.docx"options=GroupDocsComparisonCloud::PreviewOptions.newoptions.file_info=sourceoptions.format="png"options.output_folder="output"request=GroupDocsComparisonCloud::PreviewRequest.new(options)response=apiInstance.preview(request)puts("Output file count: "+response.length.to_s)
// Create configuration and API instances
Configurationconfig=newConfiguration('YOUR_API_KEY','YOUR_API_SECRET');// Get ClientId and ClientSecret from https://dashboard.groupdocs.cloud
FileApifileApi=newFileApi(config);PreviewApipreviewApi=newPreviewApi(config);// Upload source Word file to cloud storage
List<ContentVersion>sourceVersions=[SELECTId,Title,VersionDataFROMContentVersionWHERETitle='source.docx'LIMIT1];if(sourceVersions.size()>0){fileApi.uploadFile(newUploadFileRequest('source_files/word/source.docx',sourceVersions[0].VersionData,null));}// Set up comparison options
ComparisonOptionsoptions=newPreviewOptions();options.FileInfo=newFileInfo();options.FileInfo.FilePath='source_files/word/source.docx';options.Format='JPEG';// Execute preview
PreviewRequestrequest=newPreviewRequest(options);List<Link>response=previewApi.preview(request);// Debug the result
System.debug('The num of pages: '+response.size());
Was this page helpful?
Any additional feedback you'd like to share with us?
Please tell us how we can improve this page.
Thank you for your feedback!
We value your opinion. Your feedback will help us improve our documentation.