Help needed on addText()

Jul 29, 2013 at 8:41 PM
Hi

I just started using PHPWord, which i think is awesome. I'm trying to put the following text (using custom font) in the word file:

$fontStyleTitle = array('name'=>'Times New Roman', 'color'=>'000000', 'size'=>12, 'bold'=>true);

$PHPWord->addFontStyle('titleStyle', $fontStyleTitle);
$string = "FORM A – CHECKLIST TO BE COMPLETED FOR C1GBL’S APPLICATION";

$text = $section->addText($string, 'titleStyle');

But the output is:

FORM A – CHECKLIST TO BE COMPLETED FOR C1GBL\’S APPLICATION

I don't know how to fix this. Can anyone help? Thanks in advance.

Ashis
Jul 30, 2013 at 5:02 PM
Got it... change the addText function in Section.php to:
public function addText($text, $styleFont = null, $styleParagraph = null) {
    $givenText = $text;
    $text = new PHPWord_Section_Text($givenText, $styleFont, $styleParagraph);
    $this->_elementCollection[] = $text;
    return $text;
}
I removed the utf8_encode function. Hope its of any help to someone...