How to Run Examples

This page explains how to set up and run the code examples for GroupDocs.Viewer for Python via .NET. The examples demonstrate common usage scenarios such as rendering documents to HTML, PDF, PNG, and JPEG, working with documents inside archives, extracting attachments, and retrieving document information.

Prerequisites

Before running the examples, ensure that you have:

  1. A configured environment that meets the requirements described in the System Requirements topic.
  2. The examples repository, cloned or downloaded from GitHub:
    https://github.com/groupdocs-viewer/GroupDocs.Viewer-for-Python-via-.NET

Project Structure

The examples repository mirrors the structure of this documentation — every page in the Developer Guide and Rendering Basics sections has a matching folder under Examples/:

📂 GroupDocs.Viewer-for-Python-via-.NET
├── Demos
│   ├── hello-world-docker
│   │   ├── Dockerfile
│   │   ├── README.md
│   │   ├── render_docx_to_html.py
│   │   ├── requirements.txt
│   │   └── sample.docx
│   └── hello-world-macos
│       ├── README.md
│       ├── render_docx_to_html.py
│       ├── requirements.txt
│       └── sample.docx
├── Examples
│   ├── getting-started
│   │   └── quick-start-guide
│   │       ├── render_docx_to_html.py
│   │       ├── render_docx_to_pdf.py
│   │       ├── render_docx_to_png.py
│   │       └── sample.docx
│   ├── developer-guide
│   │   ├── get-document-info
│   │   ├── loading-documents
│   │   ├── logging-and-diagnostics
│   │   ├── processing-attachments
│   │   └── rendering-documents
│   ├── rendering-basics
│   │   ├── render-archive-files
│   │   ├── render-cad-documents
│   │   ├── render-email-messages
│   │   ├── render-images
│   │   ├── render-pdf-documents
│   │   ├── render-presentations
│   │   ├── render-spreadsheets
│   │   ├── render-text-files
│   │   ├── render-visio-documents
│   │   ├── render-web-documents
│   │   └── render-word-documents
│   ├── licensing
│   │   ├── set_license_from_file.py
│   │   ├── set_license_from_stream.py
│   │   └── set_metered_license.py
│   ├── requirements.txt
│   └── run_all_examples.py
├── Dockerfile
├── LICENSE
└── README.md

Setup Instructions

1. Create and Activate a Virtual Environment

Navigate to the Examples directory and create a virtual environment.

Create a virtual environment:

py -m venv .venv
python3 -m venv .venv
python3 -m venv .venv

Activate the virtual environment:

.venv\Scripts\activate
source .venv/bin/activate
source .venv/bin/activate

2. Install Dependencies

After activating the virtual environment, install the required dependencies:

py -m pip install -r requirements.txt
python3 -m pip install -r requirements.txt
python3 -m pip install -r requirements.txt

3. Configure License (Optional)

If you have a license file, you can configure it in the run_all_examples.py script. By default, GroupDocs.Viewer for Python via .NET searches for:

  • The GROUPDOCS_LIC_PATH environment variable, then
  • Any file with the .lic extension in the current working directory.
Note
For more details about licensing, evaluation limitations, and obtaining a temporary license, see the Licensing and Subscription page.

Running Examples

1. Run All Examples

To execute all available examples, run the run_all_examples.py script:

py run_all_examples.py
python3 run_all_examples.py
python3 run_all_examples.py

This script runs each example sequentially and demonstrates:

  • Rendering documents to HTML, PDF, PNG, and JPEG.
  • Processing documents stored in archives.
  • Retrieving document information.
  • Applying various rendering options.

2. Run a Specific Example

To run a single example, navigate to the directory containing the desired script and execute it directly with Python.

3. Output Files

Most examples generate one or more output files. These files are typically saved in the same directory as the example script.

Troubleshooting

If you experience issues while running the examples:

Close
Loading

Analyzing your prompt, please hold on...

An error occurred while retrieving the results. Please refresh the page and try again.