Forum


Replies: 7   Views: 4244
Combining addtext and createwordmlfragment consumes huge memory resource
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 gang  · 31-10-2013 - 04:54

Hi,



I am trying to preserve line breaks taken from database content to a newly generated .docx document. Basically, I have entries in the database similar to the following:




blabalabalalalala

* bala

*bala


when the above text is put using addText($var), the line breaks seem to be removed. Hence I did the following:



$Question = array();

$QuestionArray = explode("\n",$content['Question'][$i]);

$i = 0;

foreach($QuestionArray as $QA){

    if ($i > 0){

        $Question[] = array('text'=>$QA,'lineBreak'=>true);

    } else {

        $Question[] = array('text'=>$QA);

    }

}



$temp = $Docx->addText($Question,array('rawWordML'=>true));    

$col4 = $Docx->createWordMLFragment($temp);



$Table[] = array($col4,$col5,$col6,$col7);



$TableOptions = array('size_col'=>array(400,400,400,400,400,400,400));

$TableProperties = array();

$TableProperties[0] = array('tableHeader'=>true);

$Docx->addTable($Table, $TableOptions, $TableProperties);



 



As you can see, I'd like to put the result in the table. Unfortunately, that code fragment seems to drain a huge memory resource. Any idea on how to fix this ?