Forum


Replies: 9   Views: 249
How to reduce space between one line break

Posted by admin  · 26-07-2024 - 10:23

Hello,

Please check the samples included in the package, that illustrate how to use all methods available in phpdocx. You need to use the addText method with the styles you want to apply.

For example, to add an empty paragraph with custom spacing, font family, and font size styles:

$docx->addText('Content 1', array('spacingBottom' => 0));
$docx->addText('', array('fontSize' => 6, 'font' => 'Arial', 'spacingBottom' => 4, 'spacingTop' => 4));
$docx->addText('Content 2');

Or to add a specific text style before a soft break:

$breakFragment = new WordFragment($docx);
$breakFragment->addBreak();

$runs = array();
$runs[] = array('text' => 'Content 1');
$runs[] = array('text' => ' ', 'fontSize' => 6, 'font' => 'Arial');
$runs[] = $breakFragment;
$runs[] = array('text' => 'Content 2');

$docx->addText($runs);

Regards.