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, 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, downloaded or cloned from GitHub:
    https://github.com/groupdocs-viewer/GroupDocs.Viewer-for-Python-via-.NET

Project Structure

The examples repository closely follows the structure of this documentation, making it easy to locate specific examples and related input files.

📂 GroupDocs.Viewer-for-Python-via-.NET
├── Demos
│   ├── hello-world-docker
│   │   ├── output
│   │   ├── Dockerfile
│   │   ├── README.md
│   │   ├── render_docx_to_html.py
│   │   ├── requirements.txt
│   │   └── sample.docx
│   └── hello-world-macos
│       ├── output
│       ├── README.md
│       ├── render_docx_to_html.py
│       ├── requirements.txt
│       └── sample.docx
├── Examples
│   ├── getting-started
│   │   └── hello-world
│   │       ├── render_docx_to_html.py
│   │       ├── render_docx_to_pdf.py
│   │       ├── render_docx_to_png.py
│   │       └── sample.docx
│   ├── licensing
│   │   ├── set_license_from_file.py
│   │   ├── set_license_from_stream.py
│   │   └── set_metered_license.py
│   ├── requirements.txt
│   └── run_all_examples.py
├── LICENSE

Setup Instructions

1. Create and Activate a Virtual Environment

Navigate to the Examples directory and create a virtual environment.

Create a virtual environment:

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

Activate the virtual environment:

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

2. Install Dependencies

After activating the virtual environment, install the required dependencies:

python3 -m pip install -r requirements.txt
python3 -m pip install -r requirements.txt
py -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 file.
By default, GroupDocs.Viewer for Python via .NET searches for:

  • The GROUPDOCS_LIC_PATH environment variable, or
  • A file with the .lic extension located in the project root directory.
Note
For more details about licensing, evaluation limitations, and obtaining a temporary license, see the Licensing documentation.

Running Examples

1. Run All Examples

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

python3 run_all_examples.py
python3 run_all_examples.py
py 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 using 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:

  • Verify that all dependencies are installed correctly.
  • Ensure your environment meets the documented system requirements.
  • Visit the Technical Support page for additional help.
Close
Loading

Analyzing your prompt, please hold on...

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