Sample 22 CheckBox

19:29:51 Create new PhpWord object
19:29:51 Write to Word2007 format
19:29:51 Write to ODText format
19:29:51 Write to RTF format
19:29:51 Write to HTML format
19:29:51 Write to PDF format ... NOT DONE!
19:29:51 Write to EPub3 format
19:29:51 Done writing file(s)
19:29:51 Peak memory usage: 2 MB

 

Results: docx odt rtf html epub


<?php


include_once 'Sample_Header.php';

// New Word document
echo date('H:i:s'), ' Create new PhpWord object', EOL;
$phpWord = new PhpOffice\PhpWord\PhpWord();

// New section
$section = $phpWord->addSection();

$section->addText('Check box in section');
$section->addCheckBox('chkBox1', 'Checkbox 1');
$section->addText('Check box in table cell');
$table = $section->addTable();
$table->addRow();
$cell = $table->addCell();
$cell->addCheckBox('chkBox2', 'Checkbox 2');

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