This project is read-only.

is possible to set margin to paragraph ?

Jun 1, 2012 at 4:52 AM

Hi guys:

is possible to set margin to paragraph?

<p style="margin-left: 20px">bla bla bla</p>

or use space to replace


Thank you

Jan 23, 2015 at 1:03 PM
Edited Jan 23, 2015 at 1:06 PM
I am also facing the same problem.
How can i add some spaces/tabs/margin before paragraph (<p> tag) . Actually i want to start my paragraph after some spaces/tabs.Is it possible?

Thanks in advance
Nov 3, 2016 at 12:43 AM
Edited Nov 3, 2016 at 12:45 AM
I created a solution that works for me. I don't know if is the right way, if works every time, if works to everyone, the following:

FILE -> /PHPWord/Style/Paragraph.php

ADD TO THE CLASS PHPWord_Style_Paragraph
private $_indentLeft;
private $_indentRight;
public function getIndentLeft() {
    return $this->_indentLeft;
public function getIndentRight() {
    return $this->_indentRight;
public function setIndentLeft($pValue = null) {
    $this->_indentLeft = $pValue;
    return $this;
public function setIndentRight($pValue = null) {
    $this->_indentRight = $pValue;
    return $this;
AND ADD TO __construct() FUNCTION
$this->_indentLeft         = null;
$this->_indentRight         = null;

FILE -> /PHPWord/Writer/Word2007/Base.php

ADD TO _writeParagraphStyle() FUNCTION
    $indentLeft = $style->getIndentLeft();
    $indentRight = $style->getIndentRight();

    if(!is_null($indentLeft) || !is_null($indentRight)) {
                    $objWriter->writeAttribute('w:left', $indentLeft);
                    $objWriter->writeAttribute('w:right', $indentRight);
$paragraph = $section->createTextRun(array('indentLeft' => 500,'indentRight'=>500))->addText('YOUR TEXT' );