PHP Classes

PHP Word DOCX to HTML with Images: Convert Microsoft Word DOCX document to HTML

Recommend this page to a friend!
  Info   View files Example   View files View files (7)   DownloadInstall with Composer Download .zip   Reputation   Support forum (8)   Blog (1)    
Ratings Unique User Downloads Download Rankings
StarStarStarStar 66%Total: 863 All time: 4,060 This week: 78Up
Version License PHP version Categories
wordtohtml 1.0.1Custom (specified...5HTML, PHP 5, Files and Folders


This class can convert Microsoft Word DOCX document to HTML.

It can take file name of a Microsoft Word DOCX and extract its contents to obtain the XHTML document and image files.

The class can parse the contained XHTML files and process its tags to convert Microsoft Word XHTML tags into regular HTML tags.

Currently it can convert paragraph tags, formatting tags, image tags, link tags and table tags.

Innovation Award
PHP Programming Innovation award nominee
October 2020
Number 3
Many people use Microsoft Word application to create Word processing documents. However, Web applications use HTML to display documents in Web pages or send those documents as email messages to other people.

This class can convert Microsoft Word DOCX document with images to HTML to solve the problem of using Microsoft Word to create content to display Web pages or send it via email.

Manuel Lemos
Picture of Rohit Arya
  Performance   Level  
Name: Rohit Arya <contact>
Classes: 3 packages by
Country: India India
Age: 34
All time rank: 153288 in India India
Week rank: 284 Up22 in India India Up
Innovation award
Innovation award
Nominee: 3x


What is the best PHP convert docx to html with images class?
Send generated docx document as body of email message


$rt = new WordPHP(false);
$text = $rt->readDocument('sample.docx');


This class read a DOCX file and output it to HTML format.


debug mode

$rt = new WordPHP(true);

without debug

$rt = new WordPHP(false); or $rt = new WordPHP();

Set output encoding

$rt = new WordPHP(false, OUTPUT_ENCODING);

Read docx file and returns the html code

$text = $rt->readDocument(FILENAME);


To load images, please create a tmp folder where images can be extracted and saved from the document. Don't forget to change the permissions in that folder so that the user that runs this class can write the images in it.

  Files folder image Files  
File Role Description
Files folder imagetmp (3 files)
Accessible without login Plain text file LICENSE Lic. License text
Accessible without login Plain text file Doc. Documentation
Accessible without login Plain text file test.php Example Example script
Plain text file wordphp.php Class Class source

  Files folder image Files  /  tmp  
File Role Description
  Accessible without login Image file rId4.jpg Data Auxiliary data
  Accessible without login Image file rId5.jpeg Data Auxiliary data
  Accessible without login Image file rId6.jpeg Data Auxiliary data

 Version Control Unique User Downloads Download Rankings  
This week:0
All time:4,060
This week:78Up
 User Ratings  
 All time