加粗,间距和phpWord文本缩进(Bolding, spacing and indenting t

2019-09-25 22:48发布

我有一些文字,我想大胆,从前面和后面的段落分开,并缩进。 我不能让所有的三个属性的共同努力。

这适用于大胆且间隔:

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

谁能帮我?

Answer 1:

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


文章来源: Bolding, spacing and indenting text in phpWord
标签: php phpword