I
I
IvanIvvanovv2021-07-21 15:05:45
PHP
IvanIvvanovv, 2021-07-21 15:05:45

How to make a string (text) left-aligned using PHPWord?

I am using phpword to generate docx from a template. For example:

$document->setValue('zamena', '<w:br/>Текст для замены.<w:br/>');
this code finds the variable in the ${zamena} docx file and replaces it with the replacement text.
adds a line break. But no matter what I do, it fails to change the text alignment. For example, I use it and it does not bring text alignment in a line to the left. Tried to style
$phpWord->addParagraphStyle('Paragraph', array('bold' => true , 'align' => 'center' ));
and i get an error
Fatal error: Uncaught Error: Call to a member function addParagraphStyle() on null in /home/users/...

Please tell me how to make text alignment to the left in phpword.

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question