phpWord 中的粗体、间距和缩进文本

Bolding, spacing and indenting text in phpWord

我有一些文字需要加粗、与前后段落分开并缩进。 我无法让所有三个属性一起工作。

这适用于粗体和空格:

$section = $phpWord->addSection();
$section->addText(
    'Re: Your Application for Post of Security Guard',
    array('bold' => true),
    array('space' => array('before' => 360, 'after' => 280))
  );

这适用于缩进:

$section = $phpWord->addSection();
$section->addText(
    'Re: Your Application for Post of Security Guard',
   array('indentation' => array('left' => 540, 'right' => 120))
   );

但这不起作用:

$section = $phpWord->addSection();
$section->addText(
    'Re: Your Application for Post of Security Guard',
    array('bold' => true),
    array('space' => array('before' => 360, 'after' => 280)),
    array('indentation' => array('left' => 540, 'right' => 120))
  );

谁能帮帮我?

该部分的 addText 函数是:

$section->addText($text, [$fontStyle], [$paragraphStyle]);

即正确的方法是将您的段落样式组合成一个数组:

$section = $phpWord->addSection();
$section->addText(
    'Re: Your Application for Post of Security Guard',
    array('bold' => true),
    array(
        'space' => array('before' => 360, 'after' => 280), 
        'indentation' => array('left' => 540, 'right' => 120)
    )
  );