Overview

Packages

  • PHP
  • PHPWord

Classes

  • PHPWord
  • PHPWord_Autoloader
  • PHPWord_DocumentProperties
  • PHPWord_HashTable
  • PHPWord_IOFactory
  • PHPWord_Media
  • PHPWord_Section
  • PHPWord_Section_Footer
  • PHPWord_Section_Footer_PreserveText
  • PHPWord_Section_Header
  • PHPWord_Section_Image
  • PHPWord_Section_Link
  • PHPWord_Section_ListItem
  • PHPWord_Section_MemoryImage
  • PHPWord_Section_Object
  • PHPWord_Section_PageBreak
  • PHPWord_Section_Settings
  • PHPWord_Section_Table
  • PHPWord_Section_Table_Cell
  • PHPWord_Section_Table_Row
  • PHPWord_Section_Text
  • PHPWord_Section_TextBreak
  • PHPWord_Section_TextRun
  • PHPWord_Section_Title
  • PHPWord_Shared_Drawing
  • PHPWord_Shared_File
  • PHPWord_Shared_Font
  • PHPWord_Shared_String
  • PHPWord_Shared_XMLWriter
  • PHPWord_Shared_ZipStreamWrapper
  • PHPWord_Style
  • PHPWord_Style_Cell
  • PHPWord_Style_Font
  • PHPWord_Style_Image
  • PHPWord_Style_ListItem
  • PHPWord_Style_Paragraph
  • PHPWord_Style_Row
  • PHPWord_Style_Tab
  • PHPWord_Style_Table
  • PHPWord_Style_TableFull
  • PHPWord_Style_Tabs
  • PHPWord_Style_TOC
  • PHPWord_Template
  • PHPWord_TOC
  • PHPWord_Writer_ODText
  • PHPWord_Writer_ODText_Content
  • PHPWord_Writer_ODText_Manifest
  • PHPWord_Writer_ODText_Meta
  • PHPWord_Writer_ODText_Mimetype
  • PHPWord_Writer_ODText_Styles
  • PHPWord_Writer_ODText_WriterPart
  • PHPWord_Writer_RTF
  • PHPWord_Writer_Word2007
  • PHPWord_Writer_Word2007_Base
  • PHPWord_Writer_Word2007_ContentTypes
  • PHPWord_Writer_Word2007_DocProps
  • PHPWord_Writer_Word2007_Document
  • PHPWord_Writer_Word2007_DocumentRels
  • PHPWord_Writer_Word2007_Footer
  • PHPWord_Writer_Word2007_Header
  • PHPWord_Writer_Word2007_Rels
  • PHPWord_Writer_Word2007_Styles
  • PHPWord_Writer_Word2007_WriterPart

Interfaces

  • PHPWord_Writer_IWriter

Exceptions

  • PHPWord_Exception
  • Overview
  • Package
  • Class
  • Tree
  1: <?php
  2: /**
  3:  * PHPWord
  4:  *
  5:  * Copyright (c) 2013 PHPWord
  6:  *
  7:  * This library is free software; you can redistribute it and/or
  8:  * modify it under the terms of the GNU Lesser General Public
  9:  * License as published by the Free Software Foundation; either
 10:  * version 2.1 of the License, or (at your option) any later version.
 11:  *
 12:  * This library is distributed in the hope that it will be useful,
 13:  * but WITHOUT ANY WARRANTY; without even the implied warranty of
 14:  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 15:  * Lesser General Public License for more details.
 16:  *
 17:  * You should have received a copy of the GNU Lesser General Public
 18:  * License along with this library; if not, write to the Free Software
 19:  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
 20:  *
 21:  * @category   PHPWord
 22:  * @package    PHPWord
 23:  * @copyright  Copyright (c) 2013 PHPWord
 24:  * @license    http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt    LGPL
 25:  * @version    0.7.0
 26:  */
 27: 
 28: /** PHPWORD_BASE_PATH */
 29: if (!defined('PHPWORD_BASE_PATH')) {
 30:     define('PHPWORD_BASE_PATH', dirname(__FILE__) . '/');
 31:     require PHPWORD_BASE_PATH . 'PHPWord/Autoloader.php';
 32:     PHPWord_Autoloader::Register();
 33: }
 34: 
 35: 
 36: /**
 37:  * PHPWord
 38:  */
 39: class PHPWord
 40: {
 41: 
 42:     const DEFAULT_FONT_NAME = 'Arial';
 43:     const DEFAULT_FONT_SIZE = 20;
 44: 
 45:     /**
 46:      * Document properties
 47:      *
 48:      * @var PHPWord_DocumentProperties
 49:      */
 50:     private $_properties;
 51: 
 52:     /**
 53:      * Default Font Name
 54:      *
 55:      * @var string
 56:      */
 57:     private $_defaultFontName;
 58: 
 59:     /**
 60:      * Default Font Size
 61:      *
 62:      * @var int
 63:      */
 64:     private $_defaultFontSize;
 65: 
 66:     /**
 67:      * Collection of section elements
 68:      *
 69:      * @var array
 70:      */
 71:     private $_sectionCollection = array();
 72: 
 73: 
 74:     /**
 75:      * Create a new PHPWord Document
 76:      */
 77:     public function __construct()
 78:     {
 79:         $this->_properties = new PHPWord_DocumentProperties();
 80:         $this->_defaultFontName = PHPWord::DEFAULT_FONT_NAME;
 81:         $this->_defaultFontSize = PHPWord::DEFAULT_FONT_SIZE;
 82:     }
 83: 
 84:     /**
 85:      * Get properties
 86:      * @return PHPWord_DocumentProperties
 87:      */
 88:     public function getProperties()
 89:     {
 90:         return $this->_properties;
 91:     }
 92: 
 93:     /**
 94:      * Set properties
 95:      *
 96:      * @param PHPWord_DocumentProperties $value
 97:      * @return PHPWord
 98:      */
 99:     public function setProperties(PHPWord_DocumentProperties $value)
100:     {
101:         $this->_properties = $value;
102:         return $this;
103:     }
104: 
105:     /**
106:      * Create a new Section
107:      *
108:      * @param PHPWord_Section_Settings $settings
109:      * @return PHPWord_Section
110:      */
111:     public function createSection($settings = null)
112:     {
113:         $sectionCount = $this->_countSections() + 1;
114: 
115:         $section = new PHPWord_Section($sectionCount, $settings);
116:         $this->_sectionCollection[] = $section;
117:         return $section;
118:     }
119: 
120:     /**
121:      * Get default Font name
122:      * @return string
123:      */
124:     public function getDefaultFontName()
125:     {
126:         return $this->_defaultFontName;
127:     }
128: 
129:     /**
130:      * Set default Font name
131:      * @param string $pValue
132:      */
133:     public function setDefaultFontName($pValue)
134:     {
135:         $this->_defaultFontName = $pValue;
136:     }
137: 
138:     /**
139:      * Get default Font size
140:      * @return string
141:      */
142:     public function getDefaultFontSize()
143:     {
144:         return $this->_defaultFontSize;
145:     }
146: 
147:     /**
148:      * Set default Font size
149:      * @param int $pValue
150:      */
151:     public function setDefaultFontSize($pValue)
152:     {
153:         $pValue = $pValue * 2;
154:         $this->_defaultFontSize = $pValue;
155:     }
156: 
157:     /**
158:      * Adds a paragraph style definition to styles.xml
159:      *
160:      * @param $styleName string
161:      * @param $styles array
162:      */
163:     public function addParagraphStyle($styleName, $styles)
164:     {
165:         PHPWord_Style::addParagraphStyle($styleName, $styles);
166:     }
167: 
168:     /**
169:      * Adds a font style definition to styles.xml
170:      *
171:      * @param $styleName string
172:      * @param $styles array
173:      */
174:     public function addFontStyle($styleName, $styleFont, $styleParagraph = null)
175:     {
176:         PHPWord_Style::addFontStyle($styleName, $styleFont, $styleParagraph);
177:     }
178: 
179:     /**
180:      * Adds a table style definition to styles.xml
181:      *
182:      * @param $styleName string
183:      * @param $styles array
184:      */
185:     public function addTableStyle($styleName, $styleTable, $styleFirstRow = null)
186:     {
187:         PHPWord_Style::addTableStyle($styleName, $styleTable, $styleFirstRow);
188:     }
189: 
190:     /**
191:      * Adds a heading style definition to styles.xml
192:      *
193:      * @param $titleCount int
194:      * @param $styles array
195:      */
196:     public function addTitleStyle($titleCount, $styleFont, $styleParagraph = null)
197:     {
198:         PHPWord_Style::addTitleStyle($titleCount, $styleFont, $styleParagraph);
199:     }
200: 
201:     /**
202:      * Adds a hyperlink style to styles.xml
203:      *
204:      * @param $styleName string
205:      * @param $styles array
206:      */
207:     public function addLinkStyle($styleName, $styles)
208:     {
209:         PHPWord_Style::addLinkStyle($styleName, $styles);
210:     }
211: 
212:     /**
213:      * Get sections
214:      * @return PHPWord_Section[]
215:      */
216:     public function getSections()
217:     {
218:         return $this->_sectionCollection;
219:     }
220: 
221:     /**
222:      * Get section count
223:      * @return int
224:      */
225:     private function _countSections()
226:     {
227:         return count($this->_sectionCollection);
228:     }
229: 
230:     /**
231:      * Load a Template File
232:      *
233:      * @param string $strFilename
234:      * @return PHPWord_Template
235:      */
236:     public function loadTemplate($strFilename)
237:     {
238:         if (file_exists($strFilename)) {
239:             $template = new PHPWord_Template($strFilename);
240:             return $template;
241:         } else {
242:             trigger_error('Template file ' . $strFilename . ' not found.', E_USER_ERROR);
243:         }
244:     }
245: }
PHPWord API Docs API documentation generated by ApiGen 2.8.0