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


PHP PhpWord::getDocInfo方法代码示例

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


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

示例1: read

 /**
  * Read meta.xml.
  *
  * @param \PhpOffice\PhpWord\PhpWord $phpWord
  * @return void
  * @todo Process property type
  */
 public function read(PhpWord $phpWord)
 {
     $xmlReader = new XMLReader();
     $xmlReader->getDomFromZip($this->docFile, $this->xmlFile);
     $docProps = $phpWord->getDocInfo();
     $metaNode = $xmlReader->getElement('office:meta');
     // Standard properties
     $properties = array('title' => 'dc:title', 'subject' => 'dc:subject', 'description' => 'dc:description', 'keywords' => 'meta:keyword', 'creator' => 'meta:initial-creator', 'lastModifiedBy' => 'dc:creator');
     foreach ($properties as $property => $path) {
         $method = "set{$property}";
         $propertyNode = $xmlReader->getElement($path, $metaNode);
         if ($propertyNode !== null && method_exists($docProps, $method)) {
             $docProps->{$method}($propertyNode->nodeValue);
         }
     }
     // Custom properties
     $propertyNodes = $xmlReader->getElements('meta:user-defined', $metaNode);
     foreach ($propertyNodes as $propertyNode) {
         $property = $xmlReader->getAttribute('meta:name', $propertyNode);
         // Set category, company, and manager property
         if (in_array($property, array('Category', 'Company', 'Manager'))) {
             $method = "set{$property}";
             $docProps->{$method}($propertyNode->nodeValue);
             // Set other custom properties
         } else {
             $docProps->setCustomProperty($property, $propertyNode->nodeValue);
         }
     }
 }
开发者ID:matiasvillanueva,项目名称:laravel5-CRUD-LOGIN,代码行数:36,代码来源:Meta.php

示例2: testConstruct

 /**
  * Test object creation
  */
 public function testConstruct()
 {
     $phpWord = new PhpWord();
     $this->assertEquals(new DocInfo(), $phpWord->getDocInfo());
     $this->assertEquals(Settings::DEFAULT_FONT_NAME, $phpWord->getDefaultFontName());
     $this->assertEquals(Settings::DEFAULT_FONT_SIZE, $phpWord->getDefaultFontSize());
 }
开发者ID:HaiLeader,项目名称:quizz,代码行数:10,代码来源:PhpWordTest.php

示例3: read

 /**
  * Read custom document properties.
  *
  * @param \PhpOffice\PhpWord\PhpWord $phpWord
  * @return void
  */
 public function read(PhpWord $phpWord)
 {
     $xmlReader = new XMLReader();
     $xmlReader->getDomFromZip($this->docFile, $this->xmlFile);
     $docProps = $phpWord->getDocInfo();
     $nodes = $xmlReader->getElements('*');
     if ($nodes->length > 0) {
         foreach ($nodes as $node) {
             $propertyName = $xmlReader->getAttribute('name', $node);
             $attributeNode = $xmlReader->getElement('*', $node);
             $attributeType = $attributeNode->nodeName;
             $attributeValue = $attributeNode->nodeValue;
             $attributeValue = DocInfo::convertProperty($attributeValue, $attributeType);
             $attributeType = DocInfo::convertPropertyType($attributeType);
             $docProps->setCustomProperty($propertyName, $attributeValue, $attributeType);
         }
     }
 }
开发者ID:matiasvillanueva,项目名称:laravel5-CRUD-LOGIN,代码行数:24,代码来源:DocPropsCustom.php

示例4: testWriteContent

 /**
  * Test write content
  */
 public function testWriteContent()
 {
     $imageSrc = __DIR__ . '/../../../_files/images/PhpWord.png';
     $objectSrc = __DIR__ . '/../../../_files/documents/sheet.xls';
     $expected = 'Expected';
     $phpWord = new PhpWord();
     $docProps = $phpWord->getDocInfo();
     $docProps->setCustomProperty('Company', 'PHPWord');
     $phpWord->setDefaultFontName('Verdana');
     $phpWord->addFontStyle('Font', array('size' => 11));
     $phpWord->addParagraphStyle('Paragraph', array('alignment' => Jc::CENTER));
     $phpWord->addTableStyle('tblStyle', array('width' => 100));
     $section = $phpWord->addSection(array('colsNum' => 2));
     $section->addText(htmlspecialchars($expected, ENT_COMPAT, 'UTF-8'));
     $section->addText(htmlspecialchars('Test font style', ENT_COMPAT, 'UTF-8'), 'Font');
     $section->addText(htmlspecialchars('Test paragraph style', ENT_COMPAT, 'UTF-8'), null, 'Paragraph');
     $section->addLink('https://github.com/PHPOffice/PHPWord', htmlspecialchars('PHPWord on GitHub', ENT_COMPAT, 'UTF-8'));
     $section->addTitle(htmlspecialchars('Test title', ENT_COMPAT, 'UTF-8'), 1);
     $section->addTextBreak();
     $section->addPageBreak();
     $section->addListItem(htmlspecialchars('Test list item', ENT_COMPAT, 'UTF-8'));
     $section->addImage($imageSrc, array('width' => 50));
     $section->addObject($objectSrc);
     $section->addTOC();
     $textrun = $section->addTextRun();
     $textrun->addText(htmlspecialchars('Test text run', ENT_COMPAT, 'UTF-8'));
     $table = $section->addTable(array('width' => 50));
     $cell = $table->addRow()->addCell();
     $cell = $table->addRow()->addCell();
     $cell->addText(htmlspecialchars('Test', ENT_COMPAT, 'UTF-8'));
     $cell->addLink('https://github.com/PHPOffice/PHPWord', htmlspecialchars('PHPWord on GitHub', ENT_COMPAT, 'UTF-8'));
     $cell->addTextBreak();
     $cell->addListItem(htmlspecialchars('Test list item', ENT_COMPAT, 'UTF-8'));
     $cell->addImage($imageSrc);
     $cell->addObject($objectSrc);
     $textrun = $cell->addTextRun();
     $textrun->addText(htmlspecialchars('Test text run', ENT_COMPAT, 'UTF-8'));
     $footer = $section->addFooter();
     $footer->addPreserveText(htmlspecialchars('{PAGE}', ENT_COMPAT, 'UTF-8'));
     $table = $section->addTable('tblStyle')->addRow()->addCell();
     $doc = TestHelperDOCX::getDocument($phpWord, 'ODText');
     $element = '/office:document-content/office:body/office:text/text:section/text:p';
     $this->assertEquals($expected, $doc->getElement($element, 'content.xml')->nodeValue);
 }
开发者ID:doit05,项目名称:relProject,代码行数:47,代码来源:ContentTest.php

示例5: read

 /**
  * Read core/extended document properties.
  *
  * @param \PhpOffice\PhpWord\PhpWord $phpWord
  * @return void
  */
 public function read(PhpWord $phpWord)
 {
     $xmlReader = new XMLReader();
     $xmlReader->getDomFromZip($this->docFile, $this->xmlFile);
     $docProps = $phpWord->getDocInfo();
     $nodes = $xmlReader->getElements('*');
     if ($nodes->length > 0) {
         foreach ($nodes as $node) {
             if (!isset($this->mapping[$node->nodeName])) {
                 continue;
             }
             $method = $this->mapping[$node->nodeName];
             $value = $node->nodeValue == '' ? null : $node->nodeValue;
             if (isset($this->callbacks[$node->nodeName])) {
                 $value = $this->callbacks[$node->nodeName]($value);
             }
             if (method_exists($docProps, $method)) {
                 $docProps->{$method}($value);
             }
         }
     }
 }
开发者ID:matiasvillanueva,项目名称:laravel5-CRUD-LOGIN,代码行数:28,代码来源:DocPropsCore.php

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