本文整理汇总了PHP中PhpOffice\PhpWord\PhpWord::setDefaultFontSize方法的典型用法代码示例。如果您正苦于以下问题:PHP PhpWord::setDefaultFontSize方法的具体用法?PHP PhpWord::setDefaultFontSize怎么用?PHP PhpWord::setDefaultFontSize使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类PhpOffice\PhpWord\PhpWord
的用法示例。
在下文中一共展示了PhpWord::setDefaultFontSize方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: testSetGetDefaultFontSize
/**
* Test set/get default font size
*/
public function testSetGetDefaultFontSize()
{
$phpWord = new PhpWord();
$fontSize = 16;
$this->assertEquals(PhpWord::DEFAULT_FONT_SIZE, $phpWord->getDefaultFontSize());
$phpWord->setDefaultFontSize($fontSize);
$this->assertEquals($fontSize, $phpWord->getDefaultFontSize());
}
示例2: export
public function export($path)
{
$phpWord = new PhpWord();
$phpWord->setDefaultFontName('Times New Roman');
$phpWord->setDefaultFontSize(12);
$phpWord->addTitleStyle(1, ['size' => 26, 'bold' => true], []);
$phpWord->addTitleStyle(2, ['size' => 22, 'bold' => true], []);
$phpWord->addTitleStyle(3, ['size' => 18, 'bold' => true], []);
$phpWord->addTitleStyle(4, ['size' => 16, 'bold' => true], []);
$phpWord->addFontStyle('f_timeAndPlace', ['size' => 16, 'bold' => false]);
$phpWord->addFontStyle('f_bold', ['bold' => true]);
$phpWord->addFontStyle('f_italic', ['italic' => true]);
$phpWord->addFontStyle('f_label', []);
$phpWord->addFontStyle('f_chairName', []);
$phpWord->addFontStyle('f_chairOrganisation', []);
$phpWord->addFontStyle('f_presentationAuthor', ['bold' => true]);
$phpWord->addFontStyle('f_presentationOrganisation', []);
$phpWord->addFontStyle('f_presentationName', ['italic' => true]);
$phpWord->addFontStyle('f_contributionPaperLabel', []);
$phpWord->addParagraphStyle('p_contributionPaperLabel', ['lineHeight' => 1]);
$phpWord->addParagraphStyle('p_presentation', ['lineHeight' => 1]);
$phpWord->addParagraphStyle('p_presentationContributionPaper', ['lineHeight' => 1, 'basedOn' => 'presentation']);
$phpWord->addParagraphStyle('p_chairs', []);
$phpWord->addParagraphStyle('p_timeAndPlace', []);
$section = $phpWord->addSection();
$section->addTitle($this->text('Research Network / Research Stream Sessions'));
foreach ($this->getTypes() as $type) {
if (!$this->isExportType($type)) {
continue;
}
$section->addTitle($this->text(sprintf('%s - %s', $type, static::$typeNames[$type])), 2);
foreach ($this->getSessions($type) as $session) {
$start = new \DateTime($session['start']);
$end = new \DateTime($session['end']);
$timeAndPlace = sprintf('%s - %s / %s / %s', $start->format('H:i'), $end->format('H:i'), $start->format('jS l'), $session['room']);
$section->addText($timeAndPlace, 'f_timeAndPlace', 'p_timeAndPlace');
$section->addTitle($this->text(sprintf('%s / %s', $session['short'], $session['title'])), 3);
$chairs = $this->getChairs($session);
if ($chairs) {
$textRun = $section->addTextRun('p_chairs');
$text = count($chairs) == 1 ? 'Chair: ' : 'Chairs: ';
$textRun->addText($this->text($text), 'f_label', null);
foreach ($chairs as $chair) {
$textRun->addText($this->text(sprintf('%s ', $chair['name'])), 'f_chairName', null);
$textRun->addText($this->text(sprintf('(%s)', $chair['organisation'])), 'f_chairOrganisation', null);
}
}
$presentations = $this->getPresentations($session['id']);
$contributingPapers = array_filter($presentations, function ($p) {
return $p['acceptance'] === 'Contributing Paper';
});
$otherPresentations = array_filter($presentations, function ($p) {
return $p['acceptance'] !== 'Contributing Paper';
});
foreach ($otherPresentations as $presentation) {
$textRun = $section->addTextRun('p_presentation');
foreach ($this->getAuthors($presentation) as $author) {
$textRun->addText($this->text(sprintf('%s ', $author['name'])), 'f_presentationAuthor');
$textRun->addText($this->text(sprintf('(%s)', $author['organisation'])), 'f_presentationOrganisation');
$textRun->addText(', ');
}
$textRun->addText($this->text($presentation['title']), 'f_presentationName');
}
if ($contributingPapers) {
$section->addText('Contributed papers', 'f_contributionPaperLabel', 'p_contributionPaperLabel');
foreach ($contributingPapers as $presentation) {
$textRun = $section->addTextRun('p_presentationContributionPaper');
foreach ($this->getAuthors($presentation) as $author) {
$textRun->addText($this->text(sprintf('%s ', $author['name'])), 'f_presentationAuthor');
$textRun->addText($this->text(sprintf('(%s)', $author['organisation'])), 'f_presentationOrganisation');
$textRun->addText(', ');
}
$textRun->addText($this->text($presentation['title']), 'f_presentationName');
}
}
}
$section->addPageBreak();
}
$phpWord->save($path);
}