Quick Start Guide

This guide provides a quick overview of how to set up and start using GroupDocs.Editor for Python via .NET. The library loads a document, converts it to editable HTML/CSS, lets you edit that markup, and saves it back to the original format — or to a different one.

Prerequisites

To proceed, make sure you have:

  1. Configured environment as described in the System Requirements topic.
  2. Optionally you may Get a Temporary License to test all the product features.

Set Up Your Development Environment

For best practices, use a virtual environment to manage dependencies in Python applications. Learn more about virtual environment at Create and Use Virtual Environments documentation topic.

Create and Activate a Virtual Environment

Create a virtual environment:

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

Activate a virtual environment:

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

Install groupdocs-editor-net Package

After activating the virtual environment, run the following command in your terminal to install the latest version of the package:

py -m pip install groupdocs-editor-net
python3 -m pip install groupdocs-editor-net
python3 -m pip install groupdocs-editor-net

Ensure the package is installed successfully. You should see the message

Successfully installed groupdocs-editor-net-*

Example 1: Edit a Word document

To quickly test the library, let’s load a DOCX file, edit its HTML, and save it back to DOCX.

import os
from groupdocs.editor import Editor, EditableDocument, License
from groupdocs.editor.formats import WordProcessingFormats
from groupdocs.editor.options import WordProcessingSaveOptions

def edit_word_document():
    # Optionally set a license
    license_path = os.path.abspath("./GroupDocs.Editor.lic")
    if os.path.exists(license_path):
        License().set_license(license_path)

    # Load the document
    with Editor("./sample-document.docx") as editor:
        # Convert the document to editable HTML
        editable = editor.edit()
        html = editable.get_embedded_html()

        # Edit the HTML markup (rename the document title)
        edited_html = html.replace("Title of the document", "Title of the edited document")

        # Build an editable document from the modified markup and save it back to DOCX
        after_edit = EditableDocument.from_markup(edited_html)
        editor.save(after_edit, "./edited-document.docx", WordProcessingSaveOptions(WordProcessingFormats.DOCX))

if __name__ == "__main__":
    edit_word_document()

sample-document.docx is the sample file used in this example. Click here to download it.

Binary file (DOCX, 49 KB)

Download full output

Your folder tree should look similar to the following directory structure:

📂 demo-app
 ├──edit_word_document.py
 ├──sample-document.docx
 └──GroupDocs.Editor.lic (Optionally)

Run the App

py edit_word_document.py
python3 edit_word_document.py
python3 edit_word_document.py

After running the app you can deactivate virtual environment by executing deactivate or closing your shell.

Explanation

  • Editor("./sample-document.docx"): Loads the document into the editor.
  • editor.edit(): Converts the document to an EditableDocument and get_embedded_html() returns a self-contained HTML string.
  • EditableDocument.from_markup(edited_html): Wraps the modified markup back into an editable document.
  • editor.save(..., WordProcessingSaveOptions(WordProcessingFormats.DOCX)): Saves the edited document back to DOCX.

Example 2: Convert a document to another format

In this example we convert a DOCX file to PDF. GroupDocs.Editor converts through its HTML intermediate — saving an EditableDocument with a different *SaveOptions produces a different output format.

import os
from groupdocs.editor import Editor, License
from groupdocs.editor.options import PdfSaveOptions

def convert_word_to_pdf():
    # Optionally set a license
    license_path = os.path.abspath("./GroupDocs.Editor.lic")
    if os.path.exists(license_path):
        License().set_license(license_path)

    # Load the document
    with Editor("./sample-document.docx") as editor:
        # Convert the document to editable HTML
        editable = editor.edit()

        # Save the editable document as PDF
        editor.save(editable, "./sample-document.pdf", PdfSaveOptions())

if __name__ == "__main__":
    convert_word_to_pdf()

sample-document.docx is the sample file used in this example. Click here to download it.

Binary file (PDF, 155 KB)

Download full output

Your folder tree should look similar to the following directory structure:

📂 demo-app
 ├──convert_word_to_pdf.py
 ├──sample-document.docx
 └──GroupDocs.Editor.lic (Optionally)

Run the App

py convert_word_to_pdf.py
python3 convert_word_to_pdf.py
python3 convert_word_to_pdf.py

Explanation

  • editor.edit(): Converts the source document to an EditableDocument.
  • PdfSaveOptions(): Selects PDF as the output format.
  • editor.save(editable, "./sample-document.pdf", PdfSaveOptions()): Writes the document out as PDF through the HTML intermediate.

Example 3: Read document information

Sometimes you only need a document’s metadata. get_document_info() returns format, page count, size, and encryption status without a full edit pass.

import os
from groupdocs.editor import Editor, License

def get_document_info():
    # Optionally set a license
    license_path = os.path.abspath("./GroupDocs.Editor.lic")
    if os.path.exists(license_path):
        License().set_license(license_path)

    # Load the document and read its metadata
    with Editor("./sample-document.docx") as editor:
        info = editor.get_document_info()

        print("Format:", info.format.name)
        print("Extension:", info.format.extension)
        print("Pages:", info.page_count)
        print("Size, bytes:", info.size)
        print("Encrypted:", info.is_encrypted)

if __name__ == "__main__":
    get_document_info()

sample-document.docx is the sample file used in this example. Click here to download it.

Format: Office Open XML WordProcessingML Macro-Free Document (DOCX)
Extension: docx
Pages: 3
Size, bytes: 49455
Encrypted: False

Download full output

Your folder tree should look similar to the following directory structure:

📂 demo-app
 ├──get_document_info.py
 ├──sample-document.docx
 └──GroupDocs.Editor.lic (Optionally)

Run the App

py get_document_info.py
python3 get_document_info.py
python3 get_document_info.py

Explanation

  • editor.get_document_info(): Returns a lightweight view of the document’s metadata.
  • The view supports snake_case attribute access (info.page_count, info.format.name) as well as dict-style access for the underlying PascalCase keys (info["PageCount"]).

Next Steps

After completing the basics, explore additional resources to enhance your usage: