Is there any way to align a justified text in Phpword?

Asked

Viewed 564 times

0

I would like to align a text with phpWord as follows:

$doc->addText('Meu texto justificado', array('size' => 9), array('align' => 'justify')

But he doesn’t line up the text, I saw that instead of justify can I use the both but I also did not get the result justified. Left and right align work. There is no way to justify a text in phpWord?

1 answer

1

For what I found mining on the internet there is no parameter Justify.

If you enter the directory src\PhpWord\SimpleType\Jc.php you will find:

const START = 'start';
const CENTER = 'center';
const END = 'end';
const BOTH = 'both';
const MEDIUM_KASHIDA = 'mediumKashida';
const DISTRIBUTE = 'distribute';
const NUM_TAB = 'numTab';
const HIGH_KASHIDA = 'highKashida';
const LOW_KASHIDA = 'lowKashida';
const THAI_DISTRIBUTE = 'thaiDistribute';

The option that comes closest to justify is the distribute, if I’m not mistaken the problem will be on the last line.

Try and give me one feedback

  • Actually, Distribute lines up but the last line goes wrong. But Both works perfectly when using the main Section. That’s why mine is not working, because I have this alignment in a Section created with createTextRun(), and then it does not accept the formatting. I need this createTextRun() because I have to bold key words inside the text.

  • 1

    I was able to justify by passing the style inside the createTextRun() method, as follows: $doc = $Section->createTextRun(array('align' => 'Both')); , so it puts the entire $doc session in the past format.

  • @Leandro glad you made it.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.