Browse our Products

If so you can download any of the below versions for testing. The product will function as normal except for an evaluation limitation. At the time of purchase we provide a license file via email that will allow the product to work in its full capacity. If you would also like an evaluation license to test without any restrictions for 30 days, please follow the directions provided here.


Product Docs Swagger Examples Blog Support Dashboard

Installation

The package is available at PyPI and it can be installed via pip by executing following command:

pip install groupdocs-viewer-cloud

PyPI - Version PyPI - Downloads Python-GroupDocsCloud


Requirements

Dependencies

The SDK automatically installs the following packages:

PackageConstraint
urllib3>= 1.15
six>= 1.10
certifi
python-dateutil

Quick Start

Get your API credentials

To use GroupDocs.Viewer Cloud, sign up at GroupDocs.Cloud Dashboard and get your Client ID and Client Secret.

Initialize the API

Use the following code to start using the GroupDocs.Viewer Cloud SDK for Python:

import groupdocs_viewer_cloud

# Get your ClientId and ClientSecret at https://dashboard.groupdocs.cloud
client_id = "YourClientId"
client_secret = "YourClientSecret"

# Create API configuration
configuration = groupdocs_viewer_cloud.Configuration(client_id, client_secret)
configuration.api_base_url = "https://api.groupdocs.cloud"

# Create instance of the View API
view_api = groupdocs_viewer_cloud.ViewApi.from_config(configuration)

Render a document to HTML

Once initialized, use this basic example to render a document from cloud storage:

import groupdocs_viewer_cloud

client_id = "YourClientId"
client_secret = "YourClientSecret"

view_api = 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 = "SampleFiles/sample.docx"
view_options.view_format = "HTML"

request = groupdocs_viewer_cloud.CreateViewRequest(view_options)
response = view_api.create_view(request)

print("Document rendered: " + str(len(response.pages)) + " pages")

With this quick start guide, you’re all set to begin rendering documents using GroupDocs.Viewer Cloud in your Python applications. For more details, visit the documentation.

Get Supported File Formats

Retrieve the full list of supported file formats available through the Viewer API.

import groupdocs_viewer_cloud

info_api = groupdocs_viewer_cloud.InfoApi.from_keys("YourClientId", "YourClientSecret")

try:
    response = info_api.get_supported_file_formats()

    print("Supported file-formats:")
    for fmt in response.formats:
        print("{0} ({1})".format(fmt.file_format, fmt.extension))
except groupdocs_viewer_cloud.ApiException as e:
    print("Exception when calling get_supported_file_formats: {0}".format(e.message))

Render a Document as PDF

This example demonstrates how to render a Word document to PDF format using GroupDocs.Viewer Cloud API.

import groupdocs_viewer_cloud

view_api = groupdocs_viewer_cloud.ViewApi.from_keys("YourClientId", "YourClientSecret")

view_options = groupdocs_viewer_cloud.ViewOptions()
view_options.file_info = groupdocs_viewer_cloud.FileInfo()
view_options.file_info.file_path = "SampleFiles/sample.docx"
view_options.view_format = "PDF"
view_options.render_options = groupdocs_viewer_cloud.PdfOptions()

request = groupdocs_viewer_cloud.CreateViewRequest(view_options)
response = view_api.create_view(request)

print("Document rendered to PDF: " + response.file.path)

Render Spreadsheet as HTML

This code sample converts an Excel spreadsheet into HTML using GroupDocs.Viewer Cloud API.

import groupdocs_viewer_cloud

view_api = groupdocs_viewer_cloud.ViewApi.from_keys("YourClientId", "YourClientSecret")

view_options = groupdocs_viewer_cloud.ViewOptions()
view_options.file_info = groupdocs_viewer_cloud.FileInfo()
view_options.file_info.file_path = "SampleFiles/sample.xlsx"
view_options.view_format = "HTML"
view_options.render_options = groupdocs_viewer_cloud.HtmlOptions()

request = groupdocs_viewer_cloud.CreateViewRequest(view_options)
response = view_api.create_view(request)

print("Spreadsheet rendered to HTML: " + str(len(response.pages)) + " pages")

Render Document with Responsive HTML Layout

Render a document as responsive HTML that adapts to various screen sizes and devices.

import groupdocs_viewer_cloud

view_api = groupdocs_viewer_cloud.ViewApi.from_keys("YourClientId", "YourClientSecret")

view_options = groupdocs_viewer_cloud.ViewOptions()
view_options.file_info = groupdocs_viewer_cloud.FileInfo()
view_options.file_info.file_path = "SampleFiles/sample.docx"
view_options.view_format = "HTML"
view_options.render_options = groupdocs_viewer_cloud.HtmlOptions()
view_options.render_options.is_responsive = True

request = groupdocs_viewer_cloud.CreateViewRequest(view_options)
response = view_api.create_view(request)

print("Responsive HTML rendered: " + str(len(response.pages)) + " pages")

Render Selected Pages

Convert only specific pages of a document, saving processing time when only part of the document is needed.

import groupdocs_viewer_cloud

view_api = groupdocs_viewer_cloud.ViewApi.from_keys("YourClientId", "YourClientSecret")

view_options = groupdocs_viewer_cloud.ViewOptions()
view_options.file_info = groupdocs_viewer_cloud.FileInfo()
view_options.file_info.file_path = "SampleFiles/sample.docx"
view_options.view_format = "HTML"
view_options.render_options = groupdocs_viewer_cloud.HtmlOptions()
view_options.render_options.pages_to_render = [2, 3]

request = groupdocs_viewer_cloud.CreateViewRequest(view_options)
response = view_api.create_view(request)

print("Selected pages rendered: " + str(len(response.pages)) + " pages")

Render Word Document with Tracked Changes

Render a Word document including tracked changes in the output HTML.

import groupdocs_viewer_cloud

view_api = groupdocs_viewer_cloud.ViewApi.from_keys("YourClientId", "YourClientSecret")

view_options = groupdocs_viewer_cloud.ViewOptions()
view_options.file_info = groupdocs_viewer_cloud.FileInfo()
view_options.file_info.file_path = "SampleFiles/with_tracked_changes.docx"
view_options.view_format = "HTML"
view_options.render_options = groupdocs_viewer_cloud.HtmlOptions()
view_options.render_options.word_processing_options = groupdocs_viewer_cloud.WordProcessingOptions()
view_options.render_options.word_processing_options.render_tracked_changes = True

request = groupdocs_viewer_cloud.CreateViewRequest(view_options)
response = view_api.create_view(request)

print("Tracked changes rendered: " + str(len(response.pages)) + " pages")

Get Document Information

Retrieve document metadata such as page count before rendering.

import groupdocs_viewer_cloud

info_api = groupdocs_viewer_cloud.InfoApi.from_keys("YourClientId", "YourClientSecret")

view_options = groupdocs_viewer_cloud.ViewOptions()
view_options.file_info = groupdocs_viewer_cloud.FileInfo()
view_options.file_info.file_path = "SampleFiles/sample.docx"

request = groupdocs_viewer_cloud.GetInfoRequest(view_options)
result = info_api.get_info(request)

print("Document pages: " + str(len(result.pages)))

Convert and Download Without Cloud Storage

Render a local document directly and receive the output file without uploading to cloud storage first.

import groupdocs_viewer_cloud

view_api = groupdocs_viewer_cloud.ViewApi.from_keys("YourClientId", "YourClientSecret")

with open("sample.docx", "rb") as file:
    request = groupdocs_viewer_cloud.ConvertAndDownloadRequest("jpg", file)
    output_path = view_api.convert_and_download(request)

print("Convert and download completed: " + output_path)

Sample Projects on GitHub

The GroupDocs.Viewer Cloud Python Samples repository includes ready-to-run examples covering:

CategoryExamples
Basic UsageSupported formats, document info, attachments, convert and download
HTML ViewerResponsive layout, minify HTML, exclude fonts, optimize for printing
Image ViewerAdjust image size, JPG quality, text overlay, text coordinates
PDF ViewerProtect PDF, adjust JPG quality
Common Rendering OptionsWatermarks, selected pages, consecutive pages, comments, notes, custom fonts
Loading OptionsProtected documents, specify encoding
Rendering by File TypeArchive, CAD, email, Outlook, PDF, spreadsheet, Visio, Word, Lotus Notes, MS Project, text

How to run the examples

  1. Clone or download the samples repository
  2. Go to the Examples directory
  3. Edit RunExamples.py and set your client_id and client_secret
  4. Run pip install groupdocs-viewer-cloud -U
  5. Execute python RunExamples.py

For more details, visit Getting Started.


Product Docs Swagger Examples Blog Support Dashboard


Tags

Document Rendering API | Python Cloud API | GroupDocs.Viewer Cloud | REST API | HTML Rendering | PDF Conversion | Image Rendering | Document Viewing | Multi-Page Rendering | Document Streaming | CAD Rendering | E-Mail Message Rendering | Visio Rendering | MS Project Rendering | Outlook Data Rendering | Spreadsheet Rendering | Word Processing Rendering | Custom View Options | Responsive HTML | Attachment Rendering | Secure API Access | Cloud Storage Integration



 English