Sample 30 ReadHTML

05:02:31 Reading contents from `/var/www/html/testword/includes/PHPWord/samples/resources/Sample_30_ReadHTML.html`
05:02:32 Write to Word2007 format
05:02:32 Write to ODText format
05:02:32 Write to RTF format
05:02:32 Write to HTML format
05:02:32 Write to PDF format
05:02:33 Done writing file(s)
05:02:33 Peak memory usage: 10 MB

 

Results: docx odt rtf html pdf


<?php

include_once 'Sample_Header.php';

// Read contents
$name basename(__FILE__'.php');
$source realpath(__DIR__ "/resources/{$name}.html");

echo 
date('H:i:s'), " Reading contents from `{$source}`"EOL;
$phpWord = \PhpOffice\PhpWord\IOFactory::load($source'HTML');

// Save file
echo write($phpWordbasename(__FILE__'.php'), $writers);
if (!
CLI) {
    include_once 
'Sample_Footer.php';
}