How to do Indentation Right or left in phpword

Jan 31, 2011 at 3:46 AM

It is possible to do Indentation Right or left in phpword ? i am waiting for u r replay.. please help me ..

Apr 8, 2011 at 3:23 PM
Edited Apr 8, 2011 at 3:24 PM

I have to work again with this wonderfull library =) and I had to do the same of you. First, I reviewed the library but I didn't found nothing of indentation....
I did some changes to support this, and works with textrun and text:
First you have to modified the file PHPword/Style/Paragraph.php, you have to modified the constructor and you have to added the next attributes and methods:



private $_indLeft;
private $_indRight;

public function __construct() {
		$this->_align           = null;
		$this->_spaceBefore     = null;
		$this->_spaceAfter      = null;
		$this->_spacing         = null;
		$this->_indLeft         = null;
		$this->_indRight         = null;

public function getIndLeft() {
		return $this->_indLeft;

public function setIndLeft($pValue = null) {
	   $this->_indLeft = $pValue;
	   return $this;

public function getIndRight() {
		return $this->_indRight;

public function setIndRight($pValue = null) {
	   $this->_indRight = $pValue;
	   return $this;


and in the file PHPWord/Writer/Word2007/Base.php in the method _writeParagraphStyle you have to added this at the begining



$indLeft = $style->getIndLeft();
$indRight = $style->getIndRight();	



and modified the next if


if(!is_null($align) || !is_null($spacing) || !is_null($spaceBefore) || !is_null($spaceAfter) || !is_null($indLeft) || !is_null($indRight)) 


 and for last add the next text inside of the if


					$objWriter->writeAttribute('w:left', $indLeft);
					$objWriter->writeAttribute('w:right', $indRight);


and it's done



Nov 13, 2011 at 9:35 PM
Edited Nov 13, 2011 at 9:36 PM

hi yoyitonin

i modified file,but how i can use it?