Forum


Replies: 6   Views: 4228
Error generating header and footer
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 blankdemon  · 28-08-2014 - 21:43

Hello! I have error using corporate 3.6. Error say: Location: Part: /word/defaultFooter.xml, Line 11, Column 247. Can you help me? The method that generate footer looks like next lines: public function createFooter($texto, $rutaLogoFooter) { $logo = $this->driver->addImage(array('name' => $rutaLogoFooter, 'rawWordML' => true, 'target' => 'defaultFooter', 'textWrap' => 1, 'float' => 'right')); $texto = $this->driver->addText($texto, array('jc' => 'left', 'b' => 'off', 'sz' => 10, 'rawWordML' => true)); $numeroPagina = $this->driver->addPageNumber('numerical', array('jc' => 'center', 'rawWordML' => true)); $logoFooter = $this->driver->createWordMLFragment(array($logo)); $textoFooter = $this->driver->createWordMLFragment(array($texto)); $numPaginaFooter = $this->driver->createWordMLFragment(array($numeroPagina)); $valuesTable = array( array( $textoFooter, $numPaginaFooter, $logoFooter ) ); $options = array('tableWidth' => array('pct', 100), 'size_col' => array(7000,6000,7000), 'border' => 0, 'jc' => 'center', 'rawWordML' => true); $footerTable = $this->driver->addTable($valuesTable, $options); $myFooter = $this->driver->createWordMLFragment(array($footerTable)); $this->driver->addFooter(array('default' => $myFooter)); } Regards

Posted by admin  · 29-08-2014 - 06:45

Hello, Please upgrade to phpdocx 3.7, you can download it from your account, and try again. If the error is still there, send us or post the DOCX and a script (without external connections) we can run to check it. Regards.

Posted by rcid  · 29-08-2014 - 19:19

Deleted by rcid · 29-08-2014 - 19:24

Posted by blankdemon  · 29-08-2014 - 19:28

Hello, Thank you for you answer. Yes, library was upgraded to 3.7 but error persists. Curiously error happens when we try to open a document generated with Word 2007, it do not occur with Office 2010 version. The error was reported by some of our users. require_once("libs/phpdocx_37/classes/TransformDoc.inc"); require_once("libs/phpdocx_37/classes/CreateDocx.inc"); class Report { private $driver; public function __construct() { $this->driver = new CreateDocx(); $this->driver->modifyPageLayout('letter'); //$this->driver->setEncodeUTF8(); } public function agregaTextoNegrita($texto = NULL, $texto2 = NULL) { $text = array(); $text[] = array( 'text' => $texto, 'b' => 'on', 'font' => 'Arial', 'sz' => 10 ); $text[] = array( 'text' => $texto2, 'font' => 'Arial', 'sz' => 10 ); $this->driver->addText($text); } public function bajar($nombre, $isPDF = FALSE) { if ($isPDF) { $this->driver->createDocx($nombre); // Creating the PDF $document = new TransformDoc(); $document->setStrFile($nombre . '.docx'); $document->generatePDF(); unlink($nombre . '.docx'); } else { $this->driver->createDocxAndDownload($nombre); } } public function crearFooter($texto, $rutaLogoFooter) { $logo = $this->driver->addImage(array('name' => $rutaLogoFooter, 'rawWordML' => true, 'target' => 'defaultFooter', 'textWrap' => 1, 'float' => 'right')); $texto = $this->driver->addText($texto, array('jc' => 'left', 'b' => 'off', 'sz' => 10, 'rawWordML' => true)); $numeroPagina = $this->driver->addPageNumber('numerical', array('jc' => 'center', 'rawWordML' => true)); $logoFooter = $this->driver->createWordMLFragment(array($logo)); $textoFooter = $this->driver->createWordMLFragment(array($texto)); $numPaginaFooter = $this->driver->createWordMLFragment(array($numeroPagina)); $valuesTable = array( array( $textoFooter, $numPaginaFooter, $logoFooter ) ); $options = array('tableWidth' => array('pct', 100), 'size_col' => array(7000, 6000, 7000), 'border' => 0, 'jc' => 'center', 'rawWordML' => true); $footerTable = $this->driver->addTable($valuesTable, $options); $myFooter = $this->driver->createWordMLFragment(array($footerTable)); $this->driver->addFooter(array('default' => $myFooter)); } } function insertaLogo($reporte) { if (file_exists($logo = 'logo.png') !== FALSE) { $reporte->crearFooter('Date: ' . date("d-m-Y H:i"), $logo); } else { $logo = 'logo.png'; $reporte->crearFooter('Date: ' . date("d-m-Y H:i"), 'logo.png'); } } function reporteCantidadStakeholder() { $reporte = new Report(); insertaLogo($reporte); $reporte->agregaTextoNegrita('Report: ', 'Something'); $reporte->bajar('/tmp/FileName'); } reporteCantidadStakeholder(); Thank you from now on. Regards.

Posted by admin  · 01-09-2014 - 08:27

Hola, Vemos métodos en español, por lo que te escribimos en este idioma. Por favor mándanos uno de los DOCX que te funciona y otro que no, para poder comprobarlos. Puedes subirlo a un servicio de compartir archivos o mandárnoslos por correo electrónico mediante el formulario de contacto. Saludos.

Posted by admin  · 03-09-2014 - 09:06

Hello, This is the problem: array('tableWidth' => array('pct', 100) Please change how do you set the width and try again. Regards.