当前位置: 首页>>代码示例>>PHP>>正文


PHP PhpWord::addFontStyle方法代码示例

本文整理汇总了PHP中PhpOffice\PhpWord\PhpWord::addFontStyle方法的典型用法代码示例。如果您正苦于以下问题:PHP PhpWord::addFontStyle方法的具体用法?PHP PhpWord::addFontStyle怎么用?PHP PhpWord::addFontStyle使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在PhpOffice\PhpWord\PhpWord的用法示例。


在下文中一共展示了PhpWord::addFontStyle方法的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: read

 /**
  * Read styles.xml.
  *
  * @param \PhpOffice\PhpWord\PhpWord $phpWord
  * @return void
  */
 public function read(PhpWord $phpWord)
 {
     $xmlReader = new XMLReader();
     $xmlReader->getDomFromZip($this->docFile, $this->xmlFile);
     $nodes = $xmlReader->getElements('w:style');
     if ($nodes->length > 0) {
         foreach ($nodes as $node) {
             $type = $xmlReader->getAttribute('w:type', $node);
             $name = $xmlReader->getAttribute('w:styleId', $node);
             if (is_null($name)) {
                 $name = $xmlReader->getAttribute('w:val', $node, 'w:name');
             }
             preg_match('/Heading(\\d)/', $name, $headingMatches);
             // $default = ($xmlReader->getAttribute('w:default', $node) == 1);
             switch ($type) {
                 case 'paragraph':
                     $paragraphStyle = $this->readParagraphStyle($xmlReader, $node);
                     $fontStyle = $this->readFontStyle($xmlReader, $node);
                     if (!empty($headingMatches)) {
                         $phpWord->addTitleStyle($headingMatches[1], $fontStyle, $paragraphStyle);
                     } else {
                         if (empty($fontStyle)) {
                             if (is_array($paragraphStyle)) {
                                 $phpWord->addParagraphStyle($name, $paragraphStyle);
                             }
                         } else {
                             $phpWord->addFontStyle($name, $fontStyle, $paragraphStyle);
                         }
                     }
                     break;
                 case 'character':
                     $fontStyle = $this->readFontStyle($xmlReader, $node);
                     if (!empty($fontStyle)) {
                         $phpWord->addFontStyle($name, $fontStyle);
                     }
                     break;
                 case 'table':
                     $tStyle = $this->readTableStyle($xmlReader, $node);
                     if (!empty($tStyle)) {
                         $phpWord->addTableStyle($name, $tStyle);
                     }
                     break;
             }
         }
     }
 }
开发者ID:doit05,项目名称:relProject,代码行数:52,代码来源:Styles.php

示例2: testWriteStyles

 /**
  * Test write styles
  */
 public function testWriteStyles()
 {
     $phpWord = new PhpWord();
     $pStyle = array('align' => 'both');
     $pBase = array('basedOn' => 'Normal');
     $pNew = array('basedOn' => 'Base Style', 'next' => 'Normal');
     $rStyle = array('size' => 20);
     $tStyle = array('bgColor' => 'FF0000', 'cellMarginTop' => 120, 'cellMarginBottom' => 120, 'cellMarginLeft' => 120, 'cellMarginRight' => 120, 'borderTopSize' => 120, 'borderBottomSize' => 120, 'borderLeftSize' => 120, 'borderRightSize' => 120, 'borderInsideHSize' => 120, 'borderInsideVSize' => 120);
     $phpWord->setDefaultParagraphStyle($pStyle);
     $phpWord->addParagraphStyle('Base Style', $pBase);
     $phpWord->addParagraphStyle('New Style', $pNew);
     $phpWord->addFontStyle('New Style', $rStyle, $pStyle);
     $phpWord->addTableStyle('Table Style', $tStyle, $tStyle);
     $phpWord->addTitleStyle(1, $rStyle, $pStyle);
     $doc = TestHelperDOCX::getDocument($phpWord);
     $file = 'word/styles.xml';
     // Normal style generated?
     $path = '/w:styles/w:style[@w:styleId="Normal"]/w:name';
     $element = $doc->getElement($path, $file);
     $this->assertEquals('Normal', $element->getAttribute('w:val'));
     // Parent style referenced?
     $path = '/w:styles/w:style[@w:styleId="New Style"]/w:basedOn';
     $element = $doc->getElement($path, $file);
     $this->assertEquals('Base Style', $element->getAttribute('w:val'));
     // Next paragraph style correct?
     $path = '/w:styles/w:style[@w:styleId="New Style"]/w:next';
     $element = $doc->getElement($path, $file);
     $this->assertEquals('Normal', $element->getAttribute('w:val'));
 }
开发者ID:kaantunc,项目名称:MYK-BOR,代码行数:32,代码来源:StylesTest.php

示例3: testSave

 /**
  * Save
  */
 public function testSave()
 {
     $localImage = __DIR__ . '/../_files/images/earth.jpg';
     $remoteImage = 'http://php.net//images/logos/php-med-trans-light.gif';
     $phpWord = new PhpWord();
     $phpWord->addFontStyle('Font', array('size' => 11));
     $phpWord->addParagraphStyle('Paragraph', array('alignment' => Jc::CENTER));
     $section = $phpWord->addSection();
     $section->addText(htmlspecialchars('Test 1', ENT_COMPAT, 'UTF-8'), 'Font', 'Paragraph');
     $section->addTextBreak();
     $section->addText(htmlspecialchars('Test 2', ENT_COMPAT, 'UTF-8'));
     $section = $phpWord->addSection();
     $textrun = $section->addTextRun();
     $textrun->addText(htmlspecialchars('Test 3', ENT_COMPAT, 'UTF-8'));
     $footnote = $textrun->addFootnote();
     $footnote->addLink('https://github.com/PHPOffice/PHPWord');
     $header = $section->addHeader();
     $header->addImage($localImage);
     $footer = $section->addFooter();
     $footer->addImage($remoteImage);
     $writer = new Word2007($phpWord);
     $file = __DIR__ . '/../_files/temp.docx';
     $writer->save($file);
     $this->assertTrue(file_exists($file));
     unlink($file);
 }
开发者ID:doit05,项目名称:relProject,代码行数:29,代码来源:Word2007Test.php

示例4: testSave

 /**
  * Save
  */
 public function testSave()
 {
     $imageSrc = __DIR__ . "/../_files/images/PhpWord.png";
     $objectSrc = __DIR__ . "/../_files/documents/sheet.xls";
     $file = __DIR__ . "/../_files/temp.odt";
     $phpWord = new PhpWord();
     $phpWord->addFontStyle('Font', array('size' => 11));
     $phpWord->addParagraphStyle('Paragraph', array('align' => 'center'));
     $section = $phpWord->addSection();
     $section->addText('Test 1', 'Font');
     $section->addTextBreak();
     $section->addText('Test 2', null, 'Paragraph');
     $section->addLink('http://test.com');
     $section->addTitle('Test', 1);
     $section->addPageBreak();
     $section->addTable()->addRow()->addCell()->addText('Test');
     $section->addListItem('Test');
     $section->addImage($imageSrc);
     $section->addObject($objectSrc);
     $section->addTOC();
     $section = $phpWord->addSection();
     $textrun = $section->addTextRun();
     $textrun->addText('Test 3');
     $writer = new ODText($phpWord);
     $writer->save($file);
     $this->assertTrue(file_exists($file));
     unlink($file);
 }
开发者ID:productioncompilers,项目名称:PHPWord,代码行数:31,代码来源:ODTextTest.php

示例5: testSave

 /**
  * Save
  */
 public function testSave()
 {
     $imageSrc = __DIR__ . '/../_files/images/PhpWord.png';
     $objectSrc = __DIR__ . '/../_files/documents/sheet.xls';
     $file = __DIR__ . '/../_files/temp.rtf';
     $phpWord = new PhpWord();
     $phpWord->addFontStyle('Font', array('name' => 'Verdana', 'size' => 11, 'color' => 'FF0000', 'fgColor' => '00FF00'));
     $phpWord->addParagraphStyle('Paragraph', array('alignment' => Jc::CENTER));
     $section = $phpWord->addSection();
     $section->addText(htmlspecialchars('Test 1', ENT_COMPAT, 'UTF-8'), 'Font', 'Paragraph');
     $section->addTextBreak();
     $section->addText(htmlspecialchars('Test 2', ENT_COMPAT, 'UTF-8'), array('name' => 'Tahoma', 'bold' => true, 'italic' => true));
     $section->addLink('https://github.com/PHPOffice/PHPWord');
     $section->addTitle(htmlspecialchars('Test', ENT_COMPAT, 'UTF-8'), 1);
     $section->addPageBreak();
     // Rowspan
     $table = $section->addTable();
     $table->addRow()->addCell(null, array('vMerge' => 'restart'))->addText('Test');
     $table->addRow()->addCell(null, array('vMerge' => 'continue'))->addText('Test');
     // Nested table
     $cell = $section->addTable()->addRow()->addCell();
     $cell->addTable()->addRow()->addCell();
     $section->addListItem(htmlspecialchars('Test', ENT_COMPAT, 'UTF-8'));
     $section->addImage($imageSrc);
     $section->addObject($objectSrc);
     $section->addTOC();
     $section = $phpWord->addSection();
     $textrun = $section->addTextRun();
     $textrun->addText(htmlspecialchars('Test 3', ENT_COMPAT, 'UTF-8'));
     $textrun->addTextBreak();
     $writer = new RTF($phpWord);
     $writer->save($file);
     $this->assertTrue(file_exists($file));
     @unlink($file);
 }
开发者ID:HaiLeader,项目名称:quizz,代码行数:38,代码来源:RTFTest.php

示例6: testSave

 /**
  * Save
  */
 public function testSave()
 {
     $localImage = __DIR__ . '/../_files/images/earth.jpg';
     $remoteImage = 'http://php.net//images/logos/php-med-trans-light.gif';
     $phpWord = new PhpWord();
     $phpWord->addFontStyle('Font', array('size' => 11));
     $phpWord->addParagraphStyle('Paragraph', array('align' => 'center'));
     $section = $phpWord->addSection();
     $section->addText('Test 1', 'Font', 'Paragraph');
     $section->addTextBreak();
     $section->addText('Test 2');
     $section = $phpWord->addSection();
     $textrun = $section->addTextRun();
     $textrun->addText('Test 3');
     $footnote = $textrun->addFootnote();
     $footnote->addLink('http://test.com');
     $header = $section->addHeader();
     $header->addImage($localImage);
     $footer = $section->addFooter();
     $footer->addImage($remoteImage);
     $writer = new Word2007($phpWord);
     $file = __DIR__ . "/../_files/temp.docx";
     $writer->save($file);
     $this->assertTrue(file_exists($file));
     unlink($file);
 }
开发者ID:productioncompilers,项目名称:PHPWord,代码行数:29,代码来源:Word2007Test.php

示例7: testSave

 /**
  * Save
  */
 public function testSave()
 {
     $imageSrc = __DIR__ . "/../_files/images/PhpWord.png";
     $objectSrc = __DIR__ . "/../_files/documents/sheet.xls";
     $file = __DIR__ . "/../_files/temp.rtf";
     $phpWord = new PhpWord();
     $phpWord->addFontStyle('Font', array('name' => 'Verdana', 'size' => 11, 'color' => 'FF0000', 'fgColor' => 'FF0000'));
     $phpWord->addParagraphStyle('Paragraph', array('align' => 'center'));
     $section = $phpWord->addSection();
     $section->addText('Test 1', 'Font', 'Paragraph');
     $section->addTextBreak();
     $section->addText('Test 2', array('name' => 'Tahoma', 'bold' => true, 'italic' => true));
     $section->addLink('http://test.com');
     $section->addTitle('Test', 1);
     $section->addPageBreak();
     $section->addTable();
     $section->addListItem('Test');
     $section->addImage($imageSrc);
     $section->addObject($objectSrc);
     $section->addTOC();
     $section = $phpWord->addSection();
     $textrun = $section->addTextRun();
     $textrun->addText('Test 3');
     $textrun->addTextBreak();
     $writer = new RTF($phpWord);
     $writer->save($file);
     $this->assertTrue(file_exists($file));
     unlink($file);
 }
开发者ID:kaantunc,项目名称:MYK-BOR,代码行数:32,代码来源:RTFTest.php

示例8: testSave

 /**
  * Save
  */
 public function testSave()
 {
     $imageSrc = __DIR__ . '/../_files/images/PhpWord.png';
     $objectSrc = __DIR__ . '/../_files/documents/sheet.xls';
     $file = __DIR__ . '/../_files/temp.odt';
     $phpWord = new PhpWord();
     $phpWord->addFontStyle('Font', array('size' => 11));
     $phpWord->addParagraphStyle('Paragraph', array('alignment' => Jc::CENTER));
     $section = $phpWord->addSection();
     $section->addText(htmlspecialchars('Test 1', ENT_COMPAT, 'UTF-8'), 'Font');
     $section->addTextBreak();
     $section->addText(htmlspecialchars('Test 2', ENT_COMPAT, 'UTF-8'), null, 'Paragraph');
     $section->addLink('https://github.com/PHPOffice/PHPWord');
     $section->addTitle(htmlspecialchars('Test', ENT_COMPAT, 'UTF-8'), 1);
     $section->addPageBreak();
     $section->addTable()->addRow()->addCell()->addText(htmlspecialchars('Test', ENT_COMPAT, 'UTF-8'));
     $section->addListItem(htmlspecialchars('Test', ENT_COMPAT, 'UTF-8'));
     $section->addImage($imageSrc);
     $section->addObject($objectSrc);
     $section->addTOC();
     $section = $phpWord->addSection();
     $textrun = $section->addTextRun();
     $textrun->addText(htmlspecialchars('Test 3', ENT_COMPAT, 'UTF-8'));
     $writer = new ODText($phpWord);
     $writer->save($file);
     $this->assertTrue(file_exists($file));
     unlink($file);
 }
开发者ID:brunodebarros,项目名称:phpword,代码行数:31,代码来源:ODTextTest.php

示例9: testWriteTextBreak

 /**
  * Test write text break
  */
 public function testWriteTextBreak()
 {
     $fArray = array('size' => 12);
     $pArray = array('spacing' => 240);
     $fName = 'fStyle';
     $pName = 'pStyle';
     $phpWord = new PhpWord();
     $phpWord->addFontStyle($fName, $fArray);
     $phpWord->addParagraphStyle($pName, $pArray);
     $section = $phpWord->addSection();
     $section->addTextBreak();
     $section->addTextBreak(1, $fArray, $pArray);
     $section->addTextBreak(1, $fName, $pName);
     $doc = TestHelperDOCX::getDocument($phpWord);
     $element = $doc->getElement('/w:document/w:body/w:p/w:pPr/w:rPr/w:rStyle');
     $this->assertEquals($fName, $element->getAttribute('w:val'));
     $element = $doc->getElement('/w:document/w:body/w:p/w:pPr/w:pStyle');
     $this->assertEquals($pName, $element->getAttribute('w:val'));
 }
开发者ID:var23rav,项目名称:toword_by_PhpWord,代码行数:22,代码来源:DocumentTest.php

示例10: testWriteNoStyle

 /**
  * Test no paragraph style
  */
 public function testWriteNoStyle()
 {
     $phpWord = new PhpWord();
     $phpWord->addFontStyle('Font', array('size' => 11));
     $doc = TestHelperDOCX::getDocument($phpWord, 'ODText');
     $element = "/office:document-content/office:automatic-styles/style:style";
     $this->assertTrue($doc->elementExists($element, 'content.xml'));
 }
开发者ID:hcvcastro,项目名称:pxp,代码行数:11,代码来源:ContentTest.php

示例11: 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);
 }
开发者ID:honzatrtik,项目名称:esa2015,代码行数:80,代码来源:Book.php

示例12: getAutomaticStyles

 /**
  * Set automatic styles
  */
 private function getAutomaticStyles(PhpWord $phpWord)
 {
     $sections = $phpWord->getSections();
     $sectionCount = count($sections);
     if ($sectionCount > 0) {
         $paragraphStyleCount = 0;
         $fontStyleCount = 0;
         foreach ($sections as $section) {
             $elements = $section->getElements();
             foreach ($elements as $element) {
                 if ($element instanceof Text) {
                     $fontStyle = $element->getFontStyle();
                     $paragraphStyle = $element->getParagraphStyle();
                     // Font
                     if ($fontStyle instanceof Font) {
                         $fontStyleCount++;
                         $arrStyle = array('color' => $fontStyle->getColor(), 'name' => $fontStyle->getName());
                         $phpWord->addFontStyle('T' . $fontStyleCount, $arrStyle);
                         $element->setFontStyle('T' . $fontStyleCount);
                         // Paragraph
                     } elseif ($paragraphStyle instanceof Paragraph) {
                         $paragraphStyleCount++;
                         $phpWord->addParagraphStyle('P' . $paragraphStyleCount, array());
                         $element->setParagraphStyle('P' . $paragraphStyleCount);
                     }
                 }
             }
         }
     }
 }
开发者ID:kaantunc,项目名称:MYK-BOR,代码行数:33,代码来源:Content.php

示例13: testWriteCheckbox

 /**
  * covers ::_writeCheckbox
  */
 public function testWriteCheckbox()
 {
     $rStyle = 'rStyle';
     $pStyle = 'pStyle';
     $phpWord = new PhpWord();
     $phpWord->addFontStyle($rStyle, array('bold' => true));
     $phpWord->addParagraphStyle($pStyle, array('hanging' => 120, 'indent' => 120));
     $section = $phpWord->addSection();
     $section->addCheckbox('Check1', 'Test', $rStyle, $pStyle);
     $doc = TestHelperDOCX::getDocument($phpWord);
     $element = '/w:document/w:body/w:p/w:r/w:fldChar/w:ffData/w:name';
     $this->assertEquals('Check1', $doc->getElementAttribute($element, 'w:val'));
 }
开发者ID:kaantunc,项目名称:MYK-BOR,代码行数:16,代码来源:DocumentTest.php

示例14: testSave

 /**
  * Save
  */
 public function testSave()
 {
     $localImage = __DIR__ . '/../_files/images/PhpWord.png';
     $archiveImage = 'zip://' . __DIR__ . '/../_files/documents/reader.docx#word/media/image1.jpeg';
     $gdImage = 'http://php.net/images/logos/php-med-trans-light.gif';
     $objectSrc = __DIR__ . '/../_files/documents/sheet.xls';
     $file = __DIR__ . '/../_files/temp.html';
     $phpWord = new PhpWord();
     $docProps = $phpWord->getDocInfo();
     $docProps->setTitle(htmlspecialchars('HTML Test', ENT_COMPAT, 'UTF-8'));
     $phpWord->addTitleStyle(1, array('bold' => true));
     $phpWord->addFontStyle('Font', array('name' => 'Verdana', 'size' => 11, 'color' => 'FF0000', 'fgColor' => 'FF0000'));
     $phpWord->addParagraphStyle('Paragraph', array('align' => 'center', 'spaceAfter' => 20, 'spaceBefore' => 20));
     $section = $phpWord->addSection();
     $section->addText(htmlspecialchars('Test 1', ENT_COMPAT, 'UTF-8'), 'Font', 'Paragraph');
     $section->addTextBreak();
     $section->addText(htmlspecialchars('Test 2', ENT_COMPAT, 'UTF-8'), array('name' => 'Tahoma', 'bold' => true, 'italic' => true, 'subscript' => true));
     $section->addLink('https://github.com/PHPOffice/PHPWord');
     $section->addTitle(htmlspecialchars('Test', ENT_COMPAT, 'UTF-8'), 1);
     $section->addPageBreak();
     $section->addListItem(htmlspecialchars('Test', ENT_COMPAT, 'UTF-8'));
     $section->addImage($localImage);
     $section->addImage($archiveImage);
     $section->addImage($gdImage);
     $section->addObject($objectSrc);
     $section->addFootnote();
     $section->addEndnote();
     $section = $phpWord->addSection();
     $textrun = $section->addTextRun(array('align' => 'center'));
     $textrun->addText(htmlspecialchars('Test 3', ENT_COMPAT, 'UTF-8'));
     $textrun->addTextBreak();
     $textrun = $section->addTextRun('Paragraph');
     $textrun->addLink('https://github.com/PHPOffice/PHPWord');
     $textrun->addImage($localImage);
     $textrun->addFootnote()->addText(htmlspecialchars('Footnote', ENT_COMPAT, 'UTF-8'));
     $textrun->addEndnote()->addText(htmlspecialchars('Endnote', ENT_COMPAT, 'UTF-8'));
     $section = $phpWord->addSection();
     $table = $section->addTable();
     $cell = $table->addRow()->addCell();
     $cell->addText(htmlspecialchars('Test 1', ENT_COMPAT, 'UTF-8'), array('superscript' => true, 'underline' => 'dash', 'strikethrough' => true));
     $cell->addTextRun();
     $cell->addLink('https://github.com/PHPOffice/PHPWord');
     $cell->addTextBreak();
     $cell->addListItem(htmlspecialchars('Test', ENT_COMPAT, 'UTF-8'));
     $cell->addImage($localImage);
     $cell->addObject($objectSrc);
     $cell->addFootnote();
     $cell->addEndnote();
     $cell = $table->addRow()->addCell();
     $writer = new HTML($phpWord);
     $writer->save($file);
     $this->assertTrue(file_exists($file));
     unlink($file);
 }
开发者ID:var23rav,项目名称:toword_by_PhpWord,代码行数:57,代码来源:HTMLTest.php


注:本文中的PhpOffice\PhpWord\PhpWord::addFontStyle方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。