PHP Classes

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

Recommend this page to a friend!
     
  Info   Example   View files Files   Install with Composer Install with Composer   Download Download   Reputation   Support forum   Blog    
Ratings Unique User Downloads Download Rankings
StarStarStarStar 66%Total: 871 All time: 4,034 This week: 60Up
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.

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: 152688 in India India
Week rank: 287 Up22 in India India Up
Innovation award
Innovation award
Nominee: 3x

Recommendations

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

Example

<?php
require_once('wordphp.php');
$rt = new WordPHP(false);
$text = $rt->readDocument('sample.docx');
echo
$text;
?>


Details

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

USAGE

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);

NOTE:

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 (7)  
File Role Description
Files folder imagetmp (3 files)
Accessible without login Plain text file LICENSE Lic. License text
Accessible without login Plain text file README.md 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 (7)  /  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

The PHP Classes site has supported package installation using the Composer tool since 2013, as you may verify by reading this instructions page.
Install with Composer Install with Composer
 Version Control Unique User Downloads Download Rankings  
 100%
Total:871
This week:0
All time:4,034
This week:60Up
 User Ratings  
 
 All time
Utility:91%StarStarStarStarStar
Consistency:75%StarStarStarStar
Documentation:58%StarStarStar
Examples:75%StarStarStarStar
Tests:-
Videos:-
Overall:66%StarStarStarStar
Rank:531