在 phppresentation 中使特定单词或一堆单词加粗
Making specific words or bunch of words bold in phppresentation
如何使用 phppresentation 将段落中的特定单词或行加粗。
$textRun = $shape->createTextRun('Your content is centered around promotion of events. While we encourage continuing this practice based on the strong results.');
$textRun->getFont()->setSize(13);
$textRun->getFont()->setColor($colorBlack);
$textRun->getFont()->setName('Montserrat');
在上面的文字中,我想将 'promotion of events' 设为粗体,而其他文字则保持原样。我如何在 phppresentation 库中做到这一点。
提前致谢。
您必须将文本分成多个部分。
您可以使用此代码:
$oFont = new Font();
$oFont->setSize(13);
$oFont->setColor($colorBlack);
$oFont->setName('Montserrat');
$oFontBold = clone $oFont;
$oFontBold->setBold(true);
$textRun = $shape->createTextRun('Your content is centered around ');
$textRun->setFont($oFont);
$textRun = $shape->createTextRun('promotion of events');
$textRun->setFont($oFontBold);
$textRun = $shape->createTextRun('. While we encourage continuing this practice based on the strong results.');
$textRun->setFont($oFont);
如何使用 phppresentation 将段落中的特定单词或行加粗。
$textRun = $shape->createTextRun('Your content is centered around promotion of events. While we encourage continuing this practice based on the strong results.');
$textRun->getFont()->setSize(13);
$textRun->getFont()->setColor($colorBlack);
$textRun->getFont()->setName('Montserrat');
在上面的文字中,我想将 'promotion of events' 设为粗体,而其他文字则保持原样。我如何在 phppresentation 库中做到这一点。
提前致谢。
您必须将文本分成多个部分。
您可以使用此代码:
$oFont = new Font();
$oFont->setSize(13);
$oFont->setColor($colorBlack);
$oFont->setName('Montserrat');
$oFontBold = clone $oFont;
$oFontBold->setBold(true);
$textRun = $shape->createTextRun('Your content is centered around ');
$textRun->setFont($oFont);
$textRun = $shape->createTextRun('promotion of events');
$textRun->setFont($oFontBold);
$textRun = $shape->createTextRun('. While we encourage continuing this practice based on the strong results.');
$textRun->setFont($oFont);