phpWord

时间:2016-11-17 10:04:02

标签: php 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))
  );

任何人都可以帮助我吗?

1 个答案:

答案 0 :(得分:3)

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)
    )
  );