Sample 28 ReadRTF

04:26:28 Reading contents from `/var/www/html/testword/includes/PHPWord/samples/resources/Sample_28_ReadRTF.rtf`
04:26:28 Write to Word2007 format
04:26:28 Write to ODText format
04:26:28 Write to RTF format
04:26:28 Write to HTML format
04:26:28 Write to PDF format
04:26:29 Done writing file(s)
04:26:29 Peak memory usage: 8 MB

 

Results: docx odt rtf html pdf


<?php

include_once 'Sample_Header.php';

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

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

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