Text Document Generation Demo

HTML52PDF http://www.html52pdf.com/

This is a proof of concept for generating text documents (Open Document (odt), Word (docx) and Portable Document Format (pdf)) files from HTML and table data using the HTML52PDF library. Edit the HTML and table data below and press one of the document type button at the bottom to create a document.

HTML

Adding element via HTML

Some well formed HTML snippet needs to be used

With for example some1 inline formatting1

Without paragraph tag some1 inline formatting1

Unordered (bulleted) list:

  • Item 1
  • Item 2
    • Item 2.1
    • Item 2.1

Ordered (numbered) list:

  1. Item 1
  2. Item 2

Table data Click cells to edit

Code

<?php 
            
require_once 'vendor/html52pdf/CreateDocument.inc';
            
$doc = new \Html52pdf\createDocument();
            
$doc->html(array('html' => $html));
            
            if (!empty(
$data)) {
                
$table $doc->table(array('grid' => count($data[0])))->style('border: 1px solid #EEEEEE');
                if (!empty(
$columns)) {
                    
$row $table->row()->style('background-color: #DDDDDD');
                    foreach (
$columns as $name) {
                        
$row->cell(array('style' => 'border: 1px solid #EEEEEE; padding: 5px 0 0 0'))->paragraph(array('text' => $name))
                            ->
style('font-weight: bold; text-align: center');
                    }
                }
                foreach (
$data as $set) {
                    
$row $table->row();
                    foreach (
$set as $item) {
                        
$row->cell()->style('border: 1px solid #DDDDDD')->paragraph(array('text' => $item));
                    }
                }
            }
            
$errorReporting error_reporting(E_ERROR);
            
$doc->render($filename);
            
error_reporting($errorReporting);
             
?>