當前位置: 首頁>>代碼示例>>PHP>>正文


PHP PhpWord::getDefaultFontSize方法代碼示例

本文整理匯總了PHP中PhpOffice\PhpWord\PhpWord::getDefaultFontSize方法的典型用法代碼示例。如果您正苦於以下問題:PHP PhpWord::getDefaultFontSize方法的具體用法?PHP PhpWord::getDefaultFontSize怎麽用?PHP PhpWord::getDefaultFontSize使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在PhpOffice\PhpWord\PhpWord的用法示例。


在下文中一共展示了PhpWord::getDefaultFontSize方法的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());
 }
開發者ID:kaantunc,項目名稱:MYK-BOR,代碼行數:11,代碼來源:PhpWordTest.php

示例2: writeDefaultStyles

 /**
  * Write default font and other default styles
  *
  * @param \PhpOffice\PhpWord\Shared\XMLWriter $xmlWriter
  * @param array $styles
  */
 private function writeDefaultStyles(XMLWriter $xmlWriter, PhpWord $phpWord, $styles)
 {
     $fontName = $phpWord->getDefaultFontName();
     $fontSize = $phpWord->getDefaultFontSize();
     // Default font
     $xmlWriter->startElement('w:docDefaults');
     $xmlWriter->startElement('w:rPrDefault');
     $xmlWriter->startElement('w:rPr');
     $xmlWriter->startElement('w:rFonts');
     $xmlWriter->writeAttribute('w:ascii', $fontName);
     $xmlWriter->writeAttribute('w:hAnsi', $fontName);
     $xmlWriter->writeAttribute('w:eastAsia', $fontName);
     $xmlWriter->writeAttribute('w:cs', $fontName);
     $xmlWriter->endElement();
     // w:rFonts
     $xmlWriter->startElement('w:sz');
     $xmlWriter->writeAttribute('w:val', $fontSize * 2);
     $xmlWriter->endElement();
     // w:sz
     $xmlWriter->startElement('w:szCs');
     $xmlWriter->writeAttribute('w:val', $fontSize * 2);
     $xmlWriter->endElement();
     // w:szCs
     $xmlWriter->endElement();
     // w:rPr
     $xmlWriter->endElement();
     // w:rPrDefault
     $xmlWriter->endElement();
     // w:docDefaults
     // Normal style
     $xmlWriter->startElement('w:style');
     $xmlWriter->writeAttribute('w:type', 'paragraph');
     $xmlWriter->writeAttribute('w:default', '1');
     $xmlWriter->writeAttribute('w:styleId', 'Normal');
     $xmlWriter->startElement('w:name');
     $xmlWriter->writeAttribute('w:val', 'Normal');
     $xmlWriter->endElement();
     // w:name
     if (array_key_exists('Normal', $styles)) {
         $styleWriter = new ParagraphStyleWriter($xmlWriter, $styles['Normal']);
         $styleWriter->write();
     }
     $xmlWriter->endElement();
     // w:style
     // FootnoteReference style
     if (!array_key_exists('FootnoteReference', $styles)) {
         $xmlWriter->startElement('w:style');
         $xmlWriter->writeAttribute('w:type', 'character');
         $xmlWriter->writeAttribute('w:styleId', 'FootnoteReference');
         $xmlWriter->startElement('w:name');
         $xmlWriter->writeAttribute('w:val', 'Footnote Reference');
         $xmlWriter->endElement();
         // w:name
         $xmlWriter->writeElement('w:semiHidden');
         $xmlWriter->writeElement('w:unhideWhenUsed');
         $xmlWriter->startElement('w:rPr');
         $xmlWriter->startElement('w:vertAlign');
         $xmlWriter->writeAttribute('w:val', 'superscript');
         $xmlWriter->endElement();
         // w:vertAlign
         $xmlWriter->endElement();
         // w:rPr
         $xmlWriter->endElement();
         // w:style
     }
 }
開發者ID:kaantunc,項目名稱:MYK-BOR,代碼行數:72,代碼來源:Styles.php


注:本文中的PhpOffice\PhpWord\PhpWord::getDefaultFontSize方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。