phpWord中的粗体,空格和缩进文本

Ben*_*min 1 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))
  );
Run Code Online (Sandbox Code Playgroud)

这适用于缩进:

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

但这不起作用:

$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))
  );
Run Code Online (Sandbox Code Playgroud)

谁能帮我?

eju*_*jav 5

该部分的addText函数是:

$section->addText($text, [$fontStyle], [$paragraphStyle]);
Run Code Online (Sandbox Code Playgroud)

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

$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)
    )
  );
Run Code Online (Sandbox Code Playgroud)