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 (3)   Blog    
Last Updated Ratings Unique User Downloads Download Rankings
2020-10-12 (6 days ago) RSS 2.0 feedNot enough user ratingsTotal: 133 This week: 87All time: 9,049 This week: 2Up
Version License PHP version Categories
wordtohtml 1.0.1Custom (specified...5HTML, PHP 5, Files and Folders
Description Author

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.

Picture of Rohit Arya
  Performance   Level  
Name: Rohit Arya <contact>
Classes: 3 packages by
Country: India India
Age: 30
All time rank: 3741262 in India India
Week rank: 3 Up1 in India India Up
Innovation award
Innovation award
Nominee: 1x


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:87
All time:9,049
This week:2Up

For more information send a message to info at phpclasses dot org.