Skip to main content
drupalreleases

Use direct release data with your AI assistant.

Learn more

DOC to HTML

Security covered Under active development 3 sites

This module allows editors to upload documents, convert them to HTML using LibreOffice, review the markup in CKEditor, and save it to a text field. It primarily supports DOC and DOCX formats, with options to enable others like ODT and PPTX.

DOC to HTML (doc_to_html) is a Drupal module for Word to HTML conversion: it turns DOCX, DOC, ODT, RTF and PPTX files into HTML inside the node form with LibreOffice on your own server, and makes no network call, so documents never leave your infrastructure. Editors upload a file, click Convert and check the result in the editor before saving. Headings, lists, tables, links and images come across, images become managed files, and the original document can stay attached to the node.

The document stays on your server

LibreOffice runs as a local process on the web server. The module makes no network call: the upload, the conversion and the cleanup all happen in a private temporary folder, one per conversion.

See where the files go and how it compares with the alternatives.

Features

Convert inside the form

DOC to HTML is a widget for long text fields, with or without a summary. The upload section sits under the field, and the converted HTML lands in the editor before anything is saved.

DOCX, DOC, ODT, RTF and PPTX

DOC and DOCX are on by default. ODT, RTF and PPTX are switched on in Basic Settings. A PowerPoint file keeps the text of its slides.

Keep the original document

Point the widget to a file field and the source document is saved there, in the directory of that field. It becomes permanent only when the node is saved. If the form is abandoned, the cron of core removes the temporary file.

Images as managed files

Pictures in the document become managed files in a directory you choose, tracked by the core editor module like any image added in the editor.

Clean and safe HTML

Scripts, frames, event attributes and javascript: links are removed, and the styles of the LibreOffice page never reach the field. A DOM regex can strip what your site does not want, for example the classes LibreOffice adds.

Your text format

Each widget picks the text format for converted content, and can drop the first heading of the document and use it as the title.

Test Wizard

An admin page converts a sample document and shows the raw HTML, the extracted body and the final result, so you can try a regex before you save it.

Built for themers

The formatter DOC to HTML converted content wraps the HTML in a template with suggestions by entity type, bundle, field and view mode. Its small containment library can be turned off or replaced.

Drush commands

drush dth:convert converts a file and prints the HTML, drush dth:version checks LibreOffice and drush dth:clean removes abandoned working folders.

Status report

The status page checks LibreOffice and proc_open, and lists the roles that hold the restricted settings permission.

For developers

hook_doc_to_html_pre_convert() and hook_doc_to_html_post_convert() change the options and the final HTML, and the same steps are available as events. ConversionManager::convert() runs the whole chain from code.

Documentation

Installation, a step by step setup for the Article content type, configuration, the data flow, theming and the developer guide.

Read the documentation

Installation

Install LibreOffice on the machine or in the container where PHP runs, then install the module with Composer and enable it. On Debian or Ubuntu:

apt install libreoffice-writer-nogui libreoffice-impress-nogui
composer require drupal/doc_to_html
drush en doc_to_html

Check the path of LibreOffice at /admin/config/content/doc_to_html/libreoffice-settings, then choose the DOC to HTML widget for a text field in Manage form display. The getting started guide walks through it.

Requirements

Drupal 11.2 or later, or Drupal 12, and PHP 8.3. LibreOffice on the server and the PHP function proc_open. The core editor module. Drush 13.7 or later for the commands. On Drupal 12, fields with a summary need the Text With Summary Field module.

Sites on Drupal 10, 11.0 or 11.1 use the 2.0.x branch.

Updating from 2.0.x changes where files are kept, applies the widget permission and sets the text format of existing widgets. Read the upgrade guide before you run drush updb.

Maintainer

Created in 2017 at Kelyon to turn the clients' Word privacy policies into HTML, and maintained since by Giorgio Alfredo Pagano. More on the project page on giorgiopagano.org.

Drupal 11 · not 10 PHP >=8.3

Ask your assistant about DOC to HTML

Check compatibility with your Drupal and PHP version, maintenance and security coverage, from current release data. How it works

Depends on

Dependencies of the latest stable release

  • editor Drupal core
  • file Drupal core
  • text Drupal core

Required by

Tracked projects that depend on this one

No tracked projects depend on this one yet.

Activity

Tracked releases
6
Tracked since
Nov 2025
Latest release
1 week ago
Releases (12 mo)
6 ▲ from 0
Maintenance
Active

Release Timeline

Releases

Version Type Core PHP Release date
2.1.0 Stable 11 PHP >=8.3 Oct 4, 2026
2.1.x-dev Dev 11 PHP >=8.3 Oct 4, 2026
2.0.2 Stable 10–11 PHP >=8.1 Oct 4, 2026
2.0.x-dev Dev 10–11 May 2, 2026
2.0.1 Stable 10–11 May 2, 2026
2.0.0-rc1 Pre-release 10–11 Nov 21, 2025