Topic closed:
Please note this is an old forum thread. Information in this post may be out-to-date and/or erroneous.
Every phpdocx version includes new features and improvements. Previously unsupported features may have been added to newer releases, or past issues may have been corrected.
The documentation for the addText method has a parameter for the line spacing. The document states that line spacing is a float where:
1 corresponds to single line spacing
2 to double line spacing and so long so forth
However, when I set line spacing to 1, it puts each line on a single page? When I use a line spacing of 0.0015 it seems to use standard line spacing. How can I set the line spacing to 1.15?
My code:
$contentFragment->addText($line, [
'font' => 'Trebuchet MS',
'color' => '000000',
'fontSize' => 11,
'widowControl' => true,
'lineBreak' => 'after',
'lineSpacing' => 1
]);
Hi,
We're normalizing the measures of all methods for the next release. So the easiest choice is that you do a minor change in the library.
Please open the CreateDocx.inc class and comment or remove this line (around line 5433):
$options['lineSpacing'] = ceil($options['lineSpacing'] * 240);
And set the lineSpacing in twips. For example to set it as 1.5:
$text = 'Lorem ipsum dolor';
$paragraphOptions = array(
'bold' => true,
'font' => 'Arial',
'lineSpacing' => 480
);
$docx->addText($text, $paragraphOptions);
360 is the value 1. So you can change it to fit your needs.
Thank you. Let's say that I wanted to set a line height of 1.15 [which is 276 = 240 * 1.15] but I was using HTML, what should my line-height style be?
For example: style="line-height: 276;" or should it be style="line-height: 1.15em;", etc?
Many thanks
Hello,
You may use pixels, points or ems.
You can get more info on:
http://www.phpdocx.com/introduction/html-to-word-PHP
Regards.