问题
I have some text that I want bold, separated from previous and subsequent paragraphs, and indented. I can't get all three properties to work together.
This works for bold and spaced:
$section = $phpWord->addSection();
$section->addText(
'Re: Your Application for Post of Security Guard',
array('bold' => true),
array('space' => array('before' => 360, 'after' => 280))
);
and this works for indented:
$section = $phpWord->addSection();
$section->addText(
'Re: Your Application for Post of Security Guard',
array('indentation' => array('left' => 540, 'right' => 120))
);
but this doesn't work:
$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))
);
Can anyone help me?
回答1:
The section addText function is:
$section->addText($text, [$fontStyle], [$paragraphStyle]);
i.e. the right way is to combine your paragraph styles into one array:
$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)
)
);
来源:https://stackoverflow.com/questions/40651897/bolding-spacing-and-indenting-text-in-phpword