In PHPWord, Right and Left Align Words

You can achieve the effect of different alignment on the same line of text using a paragraph style with a single custom tab stop, right aligned against the right margin.

$section = $phpWord->addSection();

$section_style = $section->getStyle();
$position =
    $section_style->getPageSizeW()
    - $section_style->getMarginRight()
    - $section_style->getMarginLeft();
$phpWord->addParagraphStyle("leftRight", array("tabs" => array(
    new \PhpOffice\PhpWord\Style\Tab("right", $position)
)));

$section->addText("Left Text\tRight Text", array(), "leftRight");

Tags:

Php

Phpword