GroupDocs.Viewer Cloud API enables you to to render documents using single API call, passing input file in the request body, and getting result file stream in the response.
This example demonstrates how to render document without using cloud storage.
Method parameters:
Name
Type
Description
Comment
format
string
Requested conversion format: HTML, JPG, PNG or PDF
Required.
File
binary
Input file to convert
Form data, Required
pages
string
Pages range to render, like “1,2” or “3-5,10”
Default value : all pages
password
string
Input document password
Required for password-protected documents.
Resource URI
HTTP PUT ~/convertAndDownload
Swagger UI lets you call this REST API directly from the browser.
cURL 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"\
-X POST \
-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 informationcurl -v "https://api.groupdocs.cloud/v2.0/viewer/convertAndDownload"\
-X PUT \
-H "Content-Type: multipart/form-data"\
-H "Accept: application/json"\
-H "Authorization: Bearer <jwt token>"--data-binary "@path/to/file"
Code200<binaryfile>
SDK examples
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.
// For complete examples and data files, please go to https://github.com/groupdocs-viewer-cloud/groupdocs-viewer-cloud-dotnet-samplesstringMyClientSecret="";// Get Client Id and Client Secret from https://dashboard.groupdocs.cloudstringMyClientId="";// Get Client Id and Client Secret from https://dashboard.groupdocs.cloudvarconfiguration=newConfiguration(MyClientId,MyClientSecret);varapiInstance=newViewApi(configuration);varformat="jpg";varrequest=newConvertAndDownloadRequest(format,File.OpenRead("myfile.txt"));varresult=apiInstance.ConvertAndDownload(request);
// For complete examples and data files, please go to https://github.com/groupdocs-viewer-cloud/groupdocs-viewer-cloud-php-samples
useGroupDocs\Viewer\Model;useGroupDocs\Viewer\Model\Requests;$ClientId="";// Get Client Id and Client Secret from https://dashboard.groupdocs.cloud
$ClientSecret="";// Get Client Id and Client Secret from https://dashboard.groupdocs.cloud
$configuration=newGroupDocs\Viewer\Configuration();$configuration->setAppSid($ClientId);$configuration->setAppKey($ClientSecret);$apiInstance=newGroupDocs\Viewer\ViewApi($configuration);$format="jpg";$path=__DIR__.'myfile.txt';$request=newRequests\convertAndDownloadRequest($format,$path);$result=$apiInstance->convertAndDownload($request);
// For complete examples and data files, please go to https://github.com/groupdocs-viewer-cloud/groupdocs-viewer-cloud-java-samples
stringMyClientSecret="";// Get Client Id and Client Secret from https://dashboard.groupdocs.cloud
stringMyClientId="";// Get Client Id and Client Secret from https://dashboard.groupdocs.cloud
Configurationconfiguration=newConfiguration(MyClientId,MyClientSecret);ViewApiapiInstance=newViewApi(configuration);Stringformat="pdf";FilefileObj=newFile("myfile.txt");ConvertAndDownloadRequestrequest=newConvertAndDownloadRequest(format,fileObj,null,null);Filefile=apiInstance.convertAndDownload(request);
# For complete examples and data files, please go to https://github.com/groupdocs-viewer-cloud/groupdocs-viewer-cloud-ruby-samplesrequire'groupdocs_viewer_cloud'$client_id="XXXX-XXXX-XXXX-XXXX"# Get Client Id and Client Secret from https://dashboard.groupdocs.cloud$client_secret="XXXXXXXXXXXXXXXX"# Get Client Id and Client Secret from https://dashboard.groupdocs.cloudapiInstance=GroupDocsViewerCloud::ViewApi.from_keys($client_id,$client_secret)format="jpg"file=File.open("myfile.txt","r")request=ConvertAndDownloadRequest.newformat,fileresponse=apiInstance.convert_and_download(request)
// For complete examples and data files, please go to https://github.com/groupdocs-viewer-cloud/groupdocs-viewer-cloud-node-samples
global.viewer#require("groupdocs-viewer-cloud");global.clientId="XXXX-XXXX-XXXX-XXXX";// Get Client Id and Client Secret from https://dashboard.groupdocs.cloud
global.clientSecret="XXXXXXXXXXXXXXXX";// Get Client Id and Client Secret from https://dashboard.groupdocs.cloud
global.viewApi=viewer_cloud.ViewApi.fromKeys(clientId,clientSecret);varformat="jpg";letfilebuf=fs.readFileSync("myfile.txt");varrequest=newConvertAndDownloadRequest(format,filebuf);letresponse=awaitviewApi.convertAndDownload(request);
# For complete examples and data files, please go to https://github.com/groupdocs-viewer-cloud/groupdocs-viewer-cloud-python-samplesimportgroupdocs_viewer_cloudclient_id="XXXX-XXXX-XXXX-XXXX"# Get Client Id and Client Secret from https://dashboard.groupdocs.cloudclient_secret="XXXXXXXXXXXXXXXX"# Get Client Id and Client Secret from https://dashboard.groupdocs.cloudapiInstance=groupdocs_viewer_cloud.ViewApi.from_keys(client_id,client_secret)format="jpg"file=File.open("myfile.txt","r")request=ConvertAndDownloadRequest.newformat,fileresponse=apiInstance.convert_and_download(request)
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.