Forum


Replies: 6   Views: 4113
Addtext doesnt make text bold and 20 points fontsize
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 jasonva  · 24-06-2014 - 06:27

require_once 'phpdocx_3.6/classes/CreateDocx.inc'; define('PHPDOCX_INCLUDE_PATH', '/opt/web/php/includes/phpdocx_3.6'); spl_autoload_unregister('my_autoload'); require_once PHPDOCX_INCLUDE_PATH . '/classes/AutoLoader.inc'; spl_autoload_register(array('AutoLoader', 'load')); spl_autoload_register('my_autoload'); class PHPDocx extends \CreateDocx { /** * @var string */ protected $language; /** * constructor */ public function __construct($language) { parent::__construct(); $this->setLanguage($language); } /** * createAndDownloadDocx * @param SurveyModel $survey * @param array $answers */ public function createAndDownloadDocx(SurveyModel $survey, $answers) { $this->setDefaultFont('Arial'); $salutation = ($this->getLanguage() == 'nl') ? $survey->getGender()->getNameNlBE() : $survey->getGender()->getNameFrBE(); $salutationText = array(); $salutationText[] = array( 'text' => $salutation . ' ' . $survey->getFirstname() . ' ' . $survey->getLastname(), 'bold' => 'true', 'fontSize' => '20' ); $this->addText($salutationText, array('bold' => 'true', 'fontSize' => '20')); $this->embedHTML('

' . $GLOBALS['lang']->getLang('str_birthdate') . ' ' . htmlspecialchars($survey->getBirthdate()) . '

'); $this->embedHTML('

' . $GLOBALS['lang']->getLang('str_filled_in_date') . ' ' . htmlspecialchars($survey->getCreation()) . '

'); $this->embedHTML('

' . $GLOBALS['lang']->getLang('str_answers') . '

'); foreach ($answers as $answer) { $this->embedHTML('

' . ($this->getLanguage() == 'nl') ? htmlspecialchars($answer[0]->getQuestion()->getCodeNlBE()) : htmlspecialchars($answer[0]->getQuestion()->getCodeFrBE()) . '

'); foreach ($answer as $ans) { $color = ($ans->getAttention() == 'Y') ? 'FF0000' : '000000'; $name = ($this->getLanguage() == 'nl') ? $ans->getNameNlBE() : $ans->getNameFrBE(); $listArray[$ans->getQuestion()->getId()][] = $this->addText(htmlspecialchars($name), array( 'color' => $color ) ); } $this->addList($listArray[$answer[0]->getQuestion()->getId()]); } //$this->embedHTML('

' . htmlspecialchars($GLOBALS['lang']->getLang('str_details_message')) . '

'); $this->createDocxAndDownload('/tmp/report_' . htmlspecialchars($survey->getFirstname()) . ' ' . htmlspecialchars($survey->getLastname())); unlink('/tmp/report_' . htmlspecialchars($survey->getFirstname()) . ' ' . htmlspecialchars($survey->getLastname()) . '.docx'); } This is how i make the docx export