1. Go to this page and download the library: Download epse/html2opendocument library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
epse / html2opendocument example snippets
$html = '<p>This is a demo for the converter.</p>
<p>The converter supports the following styles:</p>
<ul>
<li>Lists (UL / OL)</li>
<li><strong>STRONG</strong></li>
<li><u>U</u> (underlined)</li>
<li><s>S</s> (strike-through)</li>
<li><em>EM</em> (emphasis / italic)</li>
<li><ins>INS</ins> (Inserted text)</li>
<li><del>DEL</del> (Deleted text)</li>
<li>Line<br>breaks with BR</li>
</ul>
<blockquote>You can also use BLOCKQUOTE, it is even styled!</blockquote>';
$html2 = '<p>You might be interested<br>in the fact that this converter<br>
also supports<br>line numbering<br>for selected paragraphs</p>
<p>Dummy Line<br>Dummy Line<br>Dummy Line<br>
Dummy Line<br>Dummy Line</p>';
$odt = new \CatoTH\HTML2OpenDocument\Text();
$odt->addHtmlTextBlock('<h1>Test Page</h1>');
$odt->addHtmlTextBlock($html, false);
$odt->addHtmlTextBlock('<h2>Line Numbering</h2>');
$odt->addHtmlTextBlock($html2, true);
$odt->finishAndOutputOdt('demo.odt');
use CatoTH\HTML2OpenDocument\Spreadsheet;
eadsheet();
// Setting to landscape mode with custom page margins
$ods->setMargins("20mm", "10mm", "10mm", "20mm");
$ods->setPageOrientation("297mm", "210mm", "landscape");
// Plain text
$ods->setCell(0, 0, Spreadsheet::TYPE_TEXT, 'Plain text with native formatting');
$ods->setCellStyle(0, 0, [], ['fo:font-weight' => 'bold']);
// Print a number as an actual number, just a little bit bigger
$ods->setCell(1, 0, Spreadsheet::TYPE_NUMBER, 23);
$ods->setCellStyle(1, 0, [], [
'fo:font-size' => '16pt',
'fo:font-weight' => 'bold',
]);
$ods->setMinRowHeight(1, 1.5);
// Print a number as text
$ods->setCell(2, 0, Spreadsheet::TYPE_TEXT, '42');
// Draw a border around two of the cells
$ods->drawBorder(1, 0, 2, 0, 1);
// Now we use HTML, and we need a bit more space for that
$html = '<p>The converter supports the following styles:</p>
<ul>
<li><strong>STRONG</strong></li>
<li><u>U</u> (underlined)</li>
<li><s>S</s> (strike-through)</li>
<li><em>EM</em> (emphasis / italic)</li>
<li><ins>Inserted text</ins></li>
<li><del>Deleted text</del></li>
<li>Line<br>breaks with BR</li>
<li>Lists (UL / OL) cannot be displayed as lists, but will be flattened to paragraphs</li>
</ul>
<blockquote>You can also use BLOCKQUOTE, it will be styled!</blockquote>';
$ods->setMinRowHeight(3, 10);
$ods->setColumnWidth(1, 20);
$ods->setCell(3, 1, Spreadsheet::TYPE_HTML, $html);
$ods->finishAndOutputOds('demo.ods');
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.