Python package for communicating with the GroupDocs.Viewer Cloud API. This SDK allows you to work with GroupDocs.Viewer Cloud REST APIs in your python applications, which allows rendering a specific document in HTML, image or PDF format with the flexibility to render the whole document or custom range of pages.
Python 3.4+
Install groupdocs-viewer-cloud with PIP from PyPI by:
pip install groupdocs-viewer-cloudOr clone repository and install it via Setuptools:
python setup.py installPlease follow the installation procedure and then run following:
# Import moduleimportgroupdocs_viewer_cloud# Get your app_sid and app_key at https://dashboard.groupdocs.cloud (free registration is required).client_id="XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX"client_secret="XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX"apiInstance=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)Below is an example demonstrating how to upload the document, render it, and download the result using GroupDocs.Viewer Cloud SDK for Python.
# Import moduleimportgroupdocs_viewer_cloud# Get your app_sid and app_key at https://dashboard.groupdocs.cloud (free registration is required).client_id="XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX"client_secret="XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX"# Upload input file to cloud storagefileApiInstance=groupdocs_viewer_cloud.FileApi.from_keys(client_id, client_secret)
request=groupdocs_viewer_cloud.UploadFileRequest("myfile.txt", "C:\\Data\\myfile.txt")
fileApiInstance.upload_file(request)
# Render to html formatapiInstance=groupdocs_viewer_cloud.ViewApi.from_keys(client_id, client_secret)
view_options=groupdocs_viewer_cloud.ViewOptions()
view_options.file_info=groupdocs_viewer_cloud.FileInfo()
view_options.file_info.file_path="myfile.txt"view_options.view_format="HTML"view_options.output_path="myfile.html"request=groupdocs_viewer_cloud.CreateViewRequest(view_options)
response=apiInstance.create_view(request)
# Download resultrequest=groupdocs_viewer_cloud.DownloadFileRequest("myfile.html")
response=fileApiInstance.download_file(request)
print("Expected response type is Stream: "+str(len(response)))
GroupDocs.Viewer Cloud Python SDK licensed under MIT License.
Your feedback is very important to us. Please feel free to contact us using our Support Forums.