Forum


Replies: 8   Views: 4584
Word error message when opening document
Topic closed:
Please note this is an old forum thread. Information in this post may be out-to-date and/or erroneous.
Every phpdocx version includes new features and improvements. Previously unsupported features may have been added to newer releases, or past issues may have been corrected.
We encourage you to download the current phpdocx version and check the Documentation available.

Posted by tonioseiler  · 21-05-2015 - 11:41

OK. Here is my isolated sample code: $fileName = 'test'; $columnWidth = 3000; $template = WWW_ROOT.'files/templates/export-portrait.docx'; $docX = new CreateDocxFromTemplate($template); $docX->replaceVariableByText(array('TITLE' => 'Test'), array('target' => 'header', 'parseLineBreaks' => false)); $docX->replaceVariableByText(array('DATE' => date('d.m.Y'), 'FOOTER' => 'UES ART COLLECTION'), array('target' => 'footer', 'parseLineBreaks' => false)); $docX->enableCompatibilityMode(); $docX->setDefaultFont('Open Sans'); $tableValues = array(); $imageFragment = new WordFragment($docX); $paramsImg = array( 'src' => '/Users/tse/Documents/workspaces/web/ues-art-collection/app/tmp/thumbs//Samm3808.JPG', 'dpi' => 120, 'width' => intval(178.59), 'height' => intval(215.655849057), 'verticalOffset' => 0, 'textWrap' => 0, 'target' => 'document', 'spacingTop' => 0, 'spacingBottom' => 0, 'spacingLeft' => 0, 'spacingRight' => 0, 'borderWidth' => 0, 'rawWordML' => true, 'borderStyle' => 'none', 'borderColor' => 'FFFFFF', 'borderWidth' => 0 ); $imageFragment->addImage($paramsImg); array_push($tableValues, array( array('value' => $imageFragment, 'borderTopSpacing' => 10, 'borderTop' => 'single', 'borderTopWidth' => 4, 'borderTopColor' => 'DDDDDD', 'width' => intval($columnWidth)), array('value' => '', 'borderTopSpacing' => 10, 'borderTop' => 'single', 'borderTopWidth' => 4, 'borderTopColor' => 'DDDDDD', 'width' => intval(2 * $columnWidth))) ); array_push($tableValues, array('', '')); $paramsTable = array( 'textProperties' => array('fontSize' => 9), 'border' => 'none', 'borderSpacing' => 0, 'borderColor' => 'FFFFFF', 'columnWidths' => array(intval($columnWidth), intval(2 * $columnWidth - 1000)), 'cantSplitRows' => false, 'tableLayout' => 'fixed', 'tableWidth' => array('type' => 'dxa', 'value' => intval(3 * $columnWidth)) ); $docX->addTable($tableValues, $paramsTable); $docX->addBreak(array('type' => 'line')); $docX->removeTemplateVariable('EMPTY', 'block', 'document'); $fileName = 'tmp/'.$fileName; $docX -> createDocxAndDownload(WWW_ROOT.$fileName);