News

Line spacing

  • 06 / 03 / 2011

Since PHPdocx 2.3 it is posible to control the line spacing of a paragraph. Now you can select the space between lines using the 'lineSpacing' on the code.
240 is the value that Word uses to define "simple" or normal spacing. Word recalculate this spacing if the size of the text is modified in the document. If you need double spacing you must use 480 and so on.
This is an example:



require_once '../../classes/CreateDocx.inc';

$docx = new CreateDocx();

$text = 'Lorem ipsum dolor sit amet, consectetur adipisicing elit, ' .
'sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.';

$paramsText = array(
'b' => 'single',
'font' => 'Arial',
// Defining spacing for the first text with simple spacing
'lineSpacing' => 240
);

$docx->addText($text, $paramsText);

$text = 'Lorem ipsum dolor sit amet, consectetur adipisicing elit, ' .
'sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.';

$paramsText = array(
'b' => 'single',
'font' => 'Arial',
// Defining spacing for the second text for double spacing
'lineSpacing' => 480
);

$docx->addText($text, $paramsText);

$text = 'Lorem ipsum dolor sit amet, consectetur adipisicing elit, ' .
'sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.';

$paramsText = array(
'b' => 'single',
'font' => 'Arial',
// Defining spacing for the third text for half spacing
'lineSpacing' => 120
);

$docx->addText($text, $paramsText);

$docx->createDocx('example_text_linespacing');