Merge pull request #1 from PHPOffice/develop
Develop update from upstream
This commit is contained in:
commit
277c2fb3e4
|
|
@ -1,7 +1,6 @@
|
||||||
language: php
|
language: php
|
||||||
|
|
||||||
php:
|
php:
|
||||||
- 5.3.3
|
|
||||||
- 5.3
|
- 5.3
|
||||||
- 5.4
|
- 5.4
|
||||||
- 5.5
|
- 5.5
|
||||||
|
|
@ -10,6 +9,7 @@ php:
|
||||||
|
|
||||||
matrix:
|
matrix:
|
||||||
allow_failures:
|
allow_failures:
|
||||||
|
- php: 5.2
|
||||||
- php: hhvm
|
- php: hhvm
|
||||||
|
|
||||||
env:
|
env:
|
||||||
|
|
|
||||||
|
|
@ -25,6 +25,7 @@ This release added form fields (textinput, checkbox, and dropdown), drawing shap
|
||||||
- Word2007 Writer : Support for RTL - @Progi1984 GH-331
|
- Word2007 Writer : Support for RTL - @Progi1984 GH-331
|
||||||
- MsDOC Reader: Basic MsDOC Reader - @Progi1984 GH-23 GH-287
|
- MsDOC Reader: Basic MsDOC Reader - @Progi1984 GH-23 GH-287
|
||||||
- "absolute" horizontal and vertical positioning of Frame - @basjan GH-302
|
- "absolute" horizontal and vertical positioning of Frame - @basjan GH-302
|
||||||
|
- Add new-page function for PDF generation. For multiple PDF-backends - @chc88 GH-426
|
||||||
|
|
||||||
### Bugfixes
|
### Bugfixes
|
||||||
|
|
||||||
|
|
@ -38,6 +39,7 @@ This release added form fields (textinput, checkbox, and dropdown), drawing shap
|
||||||
- "addShape()" magic method in AbstractContainer is mistakenly named as "addObject()" - @GMTA GH-356
|
- "addShape()" magic method in AbstractContainer is mistakenly named as "addObject()" - @GMTA GH-356
|
||||||
- `Element\Section::setPageSizeW()` and `Element\Section::setPageSizeH()` were mentioned in the docs but not implemented.
|
- `Element\Section::setPageSizeW()` and `Element\Section::setPageSizeH()` were mentioned in the docs but not implemented.
|
||||||
- Special Characters (ampersand) in Title break docx output - @RomanSyroeshko GH-401
|
- Special Characters (ampersand) in Title break docx output - @RomanSyroeshko GH-401
|
||||||
|
- `<th>` tag is closed with `</td>` tag: - @franzholz GH-438
|
||||||
|
|
||||||
### Deprecated
|
### Deprecated
|
||||||
|
|
||||||
|
|
|
||||||
105
README.md
105
README.md
|
|
@ -85,51 +85,92 @@ require_once 'path/to/PhpWord/src/PhpWord/Autoloader.php';
|
||||||
The following is a basic usage example of the PHPWord library.
|
The following is a basic usage example of the PHPWord library.
|
||||||
|
|
||||||
```php
|
```php
|
||||||
|
<?php
|
||||||
require_once 'src/PhpWord/Autoloader.php';
|
require_once 'src/PhpWord/Autoloader.php';
|
||||||
\PhpOffice\PhpWord\Autoloader::register();
|
\PhpOffice\PhpWord\Autoloader::register();
|
||||||
|
|
||||||
|
// Creating the new document...
|
||||||
$phpWord = new \PhpOffice\PhpWord\PhpWord();
|
$phpWord = new \PhpOffice\PhpWord\PhpWord();
|
||||||
|
|
||||||
// Every element you want to append to the word document is placed in a section.
|
/* Note: any element you append to a document must reside inside of a Section. */
|
||||||
// To create a basic section:
|
|
||||||
|
// Adding an empty Section to the document...
|
||||||
$section = $phpWord->addSection();
|
$section = $phpWord->addSection();
|
||||||
|
// Adding Text element to the Section having font styled by default...
|
||||||
// After creating a section, you can append elements:
|
$section->addText(
|
||||||
$section->addText('Hello world!');
|
htmlspecialchars(
|
||||||
|
'"Learn from yesterday, live for today, hope for tomorrow. '
|
||||||
// You can directly style your text by giving the addText function an array:
|
. 'The important thing is not to stop questioning." '
|
||||||
$section->addText('Hello world! I am formatted.',
|
. '(Albert Einstein)'
|
||||||
array('name'=>'Tahoma', 'size'=>16, 'bold'=>true));
|
)
|
||||||
|
);
|
||||||
// If you often need the same style again you can create a user defined style
|
|
||||||
// to the word document and give the addText function the name of the style:
|
/*
|
||||||
$phpWord->addFontStyle('myOwnStyle',
|
* Note: it's possible to customize font style of the Text element you add in three ways:
|
||||||
array('name'=>'Verdana', 'size'=>14, 'color'=>'1B2232'));
|
* - inline;
|
||||||
$section->addText('Hello world! I am formatted by a user defined style',
|
* - using named font style (new font style object will be implicitly created);
|
||||||
'myOwnStyle');
|
* - using explicitly created font style object.
|
||||||
|
*/
|
||||||
// You can also put the appended element to local object like this:
|
|
||||||
$fontStyle = array(
|
// Adding Text element with font customized inline...
|
||||||
'name' => 'Verdana',
|
$section->addText(
|
||||||
'size' => 22,
|
htmlspecialchars(
|
||||||
'bold' => true,
|
'"Great achievement is usually born of great sacrifice, '
|
||||||
|
. 'and is never the result of selfishness." '
|
||||||
|
. '(Napoleon Hill)'
|
||||||
|
),
|
||||||
|
array('name' => 'Tahoma', 'size' => 10)
|
||||||
|
);
|
||||||
|
|
||||||
|
// Adding Text element with font customized using named font style...
|
||||||
|
$fontStyleName = 'oneUserDefinedStyle';
|
||||||
|
$phpWord->addFontStyle(
|
||||||
|
$fontStyleName,
|
||||||
|
array('name' => 'Tahoma', 'size' => 10, 'color' => '1B2232', 'bold' => true)
|
||||||
|
);
|
||||||
|
$section->addText(
|
||||||
|
htmlspecialchars(
|
||||||
|
'"The greatest accomplishment is not in never falling, '
|
||||||
|
. 'but in rising again after you fall." '
|
||||||
|
. '(Vince Lombardi)'
|
||||||
|
),
|
||||||
|
$fontStyleName
|
||||||
|
);
|
||||||
|
|
||||||
|
// Adding Text element with font customized using explicitly created font style object...
|
||||||
|
$fontStyle = new \PhpOffice\PhpWord\Style\Font();
|
||||||
|
$fontStyle->setBold(true);
|
||||||
|
$fontStyle->setName('Tahoma');
|
||||||
|
$fontStyle->setSize(13);
|
||||||
|
$myTextElement = $section->addText(
|
||||||
|
htmlspecialchars('"Believe you can and you\'re halfway there." (Theodor Roosevelt)')
|
||||||
);
|
);
|
||||||
$myTextElement = $section->addText('Hello World!');
|
|
||||||
$myTextElement->setFontStyle($fontStyle);
|
$myTextElement->setFontStyle($fontStyle);
|
||||||
|
|
||||||
// Finally, save the document:
|
// Saving the document as OOXML file...
|
||||||
$phpWord->save('helloWorld.docx');
|
$objWriter = \PhpOffice\PhpWord\IOFactory::createWriter($phpWord, 'Word2007');
|
||||||
$phpWord->save('helloWorld.odt', 'ODText');
|
$objWriter->save('helloWorld.docx');
|
||||||
$phpWord->save('helloWorld.rtf', 'RTF');
|
|
||||||
|
// Saving the document as ODF file...
|
||||||
|
$objWriter = \PhpOffice\PhpWord\IOFactory::createWriter($phpWord, 'ODText');
|
||||||
|
$objWriter->save('helloWorld.odt');
|
||||||
|
|
||||||
|
// Saving the document as HTML file...
|
||||||
|
$objWriter = \PhpOffice\PhpWord\IOFactory::createWriter($phpWord, 'HTML');
|
||||||
|
$objWriter->save('helloWorld.html');
|
||||||
|
|
||||||
|
/* Note: we skip RTF, because it's not XML-based and requires a different example. */
|
||||||
|
/* Note: we skip PDF, because "HTML-to-PDF" approach is used to create PDF documents. */
|
||||||
```
|
```
|
||||||
|
:warning: Escape any string you pass to OOXML/ODF/HTML document, otherwise it may get broken.
|
||||||
|
|
||||||
More examples are provided in the [samples folder](samples/). You can also read the [Developers' Documentation](http://phpword.readthedocs.org/) and the [API Documentation](http://phpoffice.github.io/PHPWord/docs/master/) for more detail.
|
More examples are provided in the [samples folder](samples/). You can also read the [Developers' Documentation](http://phpword.readthedocs.org/) and the [API Documentation](http://phpoffice.github.io/PHPWord/docs/master/) for more detail.
|
||||||
|
|
||||||
## Contributing
|
## Contributing
|
||||||
|
|
||||||
We welcome everyone to contribute to PHPWord. Below are some of the things that you can do to contribute:
|
We welcome everyone to contribute to PHPWord. Below are some of the things that you can do to contribute.
|
||||||
|
|
||||||
- Read [our contributing guide](https://github.com/PHPOffice/PHPWord/blob/master/CONTRIBUTING.md)
|
- Read [our contributing guide](https://github.com/PHPOffice/PHPWord/blob/master/CONTRIBUTING.md).
|
||||||
- [Fork us](https://github.com/PHPOffice/PHPWord/fork) and [request a pull](https://github.com/PHPOffice/PHPWord/pulls) to the [develop](https://github.com/PHPOffice/PHPWord/tree/develop) branch
|
- [Fork us](https://github.com/PHPOffice/PHPWord/fork) and [request a pull](https://github.com/PHPOffice/PHPWord/pulls) to the [develop](https://github.com/PHPOffice/PHPWord/tree/develop) branch.
|
||||||
- Submit [bug reports or feature requests](https://github.com/PHPOffice/PHPWord/issues) to GitHub
|
- Submit [bug reports or feature requests](https://github.com/PHPOffice/PHPWord/issues) to GitHub.
|
||||||
- Follow [@PHPWord](https://twitter.com/PHPWord) and [@PHPOffice](https://twitter.com/PHPOffice) on Twitter
|
- Follow [@PHPWord](https://twitter.com/PHPWord) and [@PHPOffice](https://twitter.com/PHPOffice) on Twitter.
|
||||||
|
|
|
||||||
File diff suppressed because it is too large
Load Diff
|
|
@ -47,14 +47,6 @@ column shows the containers while the rows lists the elements.
|
||||||
+-------+-----------------+-----------+----------+----------+---------+------------+------------+
|
+-------+-----------------+-----------+----------+----------+---------+------------+------------+
|
||||||
| 19 | Line | v | v | v | v | v | v |
|
| 19 | Line | v | v | v | v | v | v |
|
||||||
+-------+-----------------+-----------+----------+----------+---------+------------+------------+
|
+-------+-----------------+-----------+----------+----------+---------+------------+------------+
|
||||||
| 20 | Shape | v | v | v | v | v | v |
|
|
||||||
+-------+-----------------+-----------+----------+----------+---------+------------+------------+
|
|
||||||
| 21 | Chart | v | - | - | - | - | - |
|
|
||||||
+-------+-----------------+-----------+----------+----------+---------+------------+------------+
|
|
||||||
| 22 | Form fields | v | v | v | v | v | v |
|
|
||||||
+-------+-----------------+-----------+----------+----------+---------+------------+------------+
|
|
||||||
| 23 | Bookmarks | v | - | - | v | v | - |
|
|
||||||
+-------+-----------------+-----------+----------+----------+---------+------------+------------+
|
|
||||||
|
|
||||||
Legend:
|
Legend:
|
||||||
|
|
||||||
|
|
@ -79,6 +71,9 @@ as follow:
|
||||||
$section->addText($text, [$fontStyle], [$paragraphStyle]);
|
$section->addText($text, [$fontStyle], [$paragraphStyle]);
|
||||||
$textrun = $section->addTextRun([$paragraphStyle]);
|
$textrun = $section->addTextRun([$paragraphStyle]);
|
||||||
|
|
||||||
|
Text styles
|
||||||
|
~~~~~~~~~~~
|
||||||
|
|
||||||
You can use the ``$fontStyle`` and ``$paragraphStyle`` variable to
|
You can use the ``$fontStyle`` and ``$paragraphStyle`` variable to
|
||||||
define text formatting. There are 2 options to style the inserted text
|
define text formatting. There are 2 options to style the inserted text
|
||||||
elements, i.e. inline style by using array or defined style by adding
|
elements, i.e. inline style by using array or defined style by adding
|
||||||
|
|
@ -109,6 +104,47 @@ Defined style examples:
|
||||||
$phpWord->addParagraphStyle('pStyle', $paragraphStyle);
|
$phpWord->addParagraphStyle('pStyle', $paragraphStyle);
|
||||||
$text = $section->addText('Hello world!', 'pStyle');
|
$text = $section->addText('Hello world!', 'pStyle');
|
||||||
|
|
||||||
|
Font style
|
||||||
|
^^^^^^^^^^
|
||||||
|
|
||||||
|
Available font styles:
|
||||||
|
|
||||||
|
- ``name`` Font name, e.g. *Arial*
|
||||||
|
- ``size`` Font size, e.g. *20*, *22*,
|
||||||
|
- ``hint`` Font content type, *default*, *eastAsia*, or *cs*
|
||||||
|
- ``bold`` Bold, *true* or *false*
|
||||||
|
- ``italic`` Italic, *true* or *false*
|
||||||
|
- ``superScript`` Superscript, *true* or *false*
|
||||||
|
- ``subScript`` Subscript, *true* or *false*
|
||||||
|
- ``underline`` Underline, *dash*, *dotted*, etc.
|
||||||
|
- ``strikethrough`` Strikethrough, *true* or *false*
|
||||||
|
- ``doubleStrikethrough`` Double strikethrough, *true* or *false*
|
||||||
|
- ``color`` Font color, e.g. *FF0000*
|
||||||
|
- ``fgColor`` Font highlight color, e.g. *yellow*, *green*, *blue*
|
||||||
|
- ``bgColor`` Font background color, e.g. *FF0000*
|
||||||
|
- ``smallCaps`` Small caps, *true* or *false*
|
||||||
|
- ``allCaps`` All caps, *true* or *false*
|
||||||
|
|
||||||
|
Paragraph style
|
||||||
|
^^^^^^^^^^^^^^^
|
||||||
|
|
||||||
|
Available paragraph styles:
|
||||||
|
|
||||||
|
- ``align`` Paragraph alignment, *left*, *right* or *center*
|
||||||
|
- ``spaceBefore`` Space before paragraph
|
||||||
|
- ``spaceAfter`` Space after paragraph
|
||||||
|
- ``indent`` Indent by how much
|
||||||
|
- ``hanging`` Hanging by how much
|
||||||
|
- ``basedOn`` Parent style
|
||||||
|
- ``next`` Style for next paragraph
|
||||||
|
- ``widowControl`` Allow first/last line to display on a separate page,
|
||||||
|
*true* or *false*
|
||||||
|
- ``keepNext`` Keep paragraph with next paragraph, *true* or *false*
|
||||||
|
- ``keepLines`` Keep all lines on one page, *true* or *false*
|
||||||
|
- ``pageBreakBefore`` Start paragraph on next page, *true* or *false*
|
||||||
|
- ``lineHeight`` text line height, e.g. *1.0*, *1.5*, ect...
|
||||||
|
- ``tabs`` Set of custom tab stops
|
||||||
|
|
||||||
Titles
|
Titles
|
||||||
~~~~~~
|
~~~~~~
|
||||||
|
|
||||||
|
|
@ -131,13 +167,12 @@ You can add Hyperlinks to the document by using the function addLink:
|
||||||
|
|
||||||
.. code-block:: php
|
.. code-block:: php
|
||||||
|
|
||||||
$section->addLink($linkSrc, [$linkName], [$fontStyle], [$paragraphStyle], [$isInternal]);
|
$section->addLink($linkSrc, [$linkName], [$fontStyle], [$paragraphStyle]);
|
||||||
|
|
||||||
- ``$linkSrc`` The URL of the link.
|
- ``$linkSrc`` The URL of the link.
|
||||||
- ``$linkName`` Placeholder of the URL that appears in the document.
|
- ``$linkName`` Placeholder of the URL that appears in the document.
|
||||||
- ``$fontStyle`` See "Font style" section.
|
- ``$fontStyle`` See "Font style" section.
|
||||||
- ``$paragraphStyle`` See "Paragraph style" section.
|
- ``$paragraphStyle`` See "Paragraph style" section.
|
||||||
- ``$isInternal`` Set to true, if the link points to a bookmark inside the document
|
|
||||||
|
|
||||||
Preserve texts
|
Preserve texts
|
||||||
~~~~~~~~~~~~~~
|
~~~~~~~~~~~~~~
|
||||||
|
|
@ -172,9 +207,9 @@ Page breaks
|
||||||
There are two ways to insert a page breaks, using the ``addPageBreak``
|
There are two ways to insert a page breaks, using the ``addPageBreak``
|
||||||
method or using the ``pageBreakBefore`` style of paragraph.
|
method or using the ``pageBreakBefore`` style of paragraph.
|
||||||
|
|
||||||
.. code-block:: php
|
:: code-block:: php
|
||||||
|
|
||||||
$section->addPageBreak();
|
\\$section->addPageBreak();
|
||||||
|
|
||||||
Lists
|
Lists
|
||||||
-----
|
-----
|
||||||
|
|
@ -217,6 +252,23 @@ You can also create your own numbering style by changing the
|
||||||
$section->addListItem('List Item I.b', 1, null, 'multilevel');
|
$section->addListItem('List Item I.b', 1, null, 'multilevel');
|
||||||
$section->addListItem('List Item II', 0, null, 'multilevel');
|
$section->addListItem('List Item II', 0, null, 'multilevel');
|
||||||
|
|
||||||
|
Level styles:
|
||||||
|
|
||||||
|
- ``start`` Starting value
|
||||||
|
- ``format`` Numbering format
|
||||||
|
bullet\|decimal\|upperRoman\|lowerRoman\|upperLetter\|lowerLetter
|
||||||
|
- ``restart`` Restart numbering level symbol
|
||||||
|
- ``suffix`` Content between numbering symbol and paragraph text
|
||||||
|
tab\|space\|nothing
|
||||||
|
- ``text`` Numbering level text e.g. %1 for nonbullet or bullet
|
||||||
|
character
|
||||||
|
- ``align`` Numbering symbol align left\|center\|right\|both
|
||||||
|
- ``left`` See paragraph style
|
||||||
|
- ``hanging`` See paragraph style
|
||||||
|
- ``tabPos`` See paragraph style
|
||||||
|
- ``font`` Font name
|
||||||
|
- ``hint`` See font style
|
||||||
|
|
||||||
Tables
|
Tables
|
||||||
------
|
------
|
||||||
|
|
||||||
|
|
@ -242,6 +294,34 @@ Table style can be defined with ``addTableStyle``:
|
||||||
$phpWord->addTableStyle('myTable', $tableStyle, $firstRowStyle);
|
$phpWord->addTableStyle('myTable', $tableStyle, $firstRowStyle);
|
||||||
$table = $section->addTable('myTable');
|
$table = $section->addTable('myTable');
|
||||||
|
|
||||||
|
Table, row, and cell styles
|
||||||
|
~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||||
|
|
||||||
|
Table styles:
|
||||||
|
|
||||||
|
- ``width`` Table width in percent
|
||||||
|
- ``bgColor`` Background color, e.g. '9966CC'
|
||||||
|
- ``border(Top|Right|Bottom|Left)Size`` Border size in twips
|
||||||
|
- ``border(Top|Right|Bottom|Left)Color`` Border color, e.g. '9966CC'
|
||||||
|
- ``cellMargin(Top|Right|Bottom|Left)`` Cell margin in twips
|
||||||
|
|
||||||
|
Row styles:
|
||||||
|
|
||||||
|
- ``tblHeader`` Repeat table row on every new page, *true* or *false*
|
||||||
|
- ``cantSplit`` Table row cannot break across pages, *true* or *false*
|
||||||
|
- ``exactHeight`` Row height is exact or at least
|
||||||
|
|
||||||
|
Cell styles:
|
||||||
|
|
||||||
|
- ``width`` Cell width in twips
|
||||||
|
- ``valign`` Vertical alignment, *top*, *center*, *both*, *bottom*
|
||||||
|
- ``textDirection`` Direction of text
|
||||||
|
- ``bgColor`` Background color, e.g. '9966CC'
|
||||||
|
- ``border(Top|Right|Bottom|Left)Size`` Border size in twips
|
||||||
|
- ``border(Top|Right|Bottom|Left)Color`` Border color, e.g. '9966CC'
|
||||||
|
- ``gridSpan`` Number of columns spanned
|
||||||
|
- ``vMerge`` *restart* or *continue*
|
||||||
|
|
||||||
Cell span
|
Cell span
|
||||||
~~~~~~~~~
|
~~~~~~~~~
|
||||||
|
|
||||||
|
|
@ -288,6 +368,19 @@ Examples:
|
||||||
$textrun = $section->addTextRun();
|
$textrun = $section->addTextRun();
|
||||||
$textrun->addImage('http://php.net/logo.jpg');
|
$textrun->addImage('http://php.net/logo.jpg');
|
||||||
|
|
||||||
|
Image styles
|
||||||
|
~~~~~~~~~~~~
|
||||||
|
|
||||||
|
Available image styles:
|
||||||
|
|
||||||
|
- ``width`` Width in pixels
|
||||||
|
- ``height`` Height in pixels
|
||||||
|
- ``align`` Image alignment, *left*, *right*, or *center*
|
||||||
|
- ``marginTop`` Top margin in inches, can be negative
|
||||||
|
- ``marginLeft`` Left margin in inches, can be negative
|
||||||
|
- ``wrappingStyle`` Wrapping style, *inline*, *square*, *tight*,
|
||||||
|
*behind*, or *infront*
|
||||||
|
|
||||||
Watermarks
|
Watermarks
|
||||||
~~~~~~~~~~
|
~~~~~~~~~~
|
||||||
|
|
||||||
|
|
@ -390,56 +483,30 @@ Checkbox elements can be added to sections or table cells by using
|
||||||
Textboxes
|
Textboxes
|
||||||
---------
|
---------
|
||||||
|
|
||||||
To be completed.
|
To be completed
|
||||||
|
|
||||||
Fields
|
Fields
|
||||||
------
|
------
|
||||||
|
|
||||||
To be completed.
|
To be completed
|
||||||
|
|
||||||
Lines
|
Line
|
||||||
-----
|
------
|
||||||
|
|
||||||
Line elements can be added to sections by using ``addLine``.
|
Line elements can be added to sections by using ``addLine``.
|
||||||
|
|
||||||
.. code-block:: php
|
.. code-block:: php
|
||||||
|
|
||||||
$linestyle = array('weight' => 1, 'width' => 100, 'height' => 0, 'color' => '#b2a68b');
|
$linestyle = array('weight' => 1, 'width' => 100, 'height' => 0, 'color' => 635552);
|
||||||
$section->addLine($lineStyle)
|
$section->addLine($lineStyle)
|
||||||
|
|
||||||
Available line style attributes:
|
Available line style attributes:
|
||||||
|
|
||||||
- ``weight`` Line width in twips
|
- ``weight`` Line width in twips
|
||||||
- ``color`` Defines the color of stroke. The hex value must be introduced with #.
|
- ``color`` Defines the color of stroke
|
||||||
- ``dash`` Line types: dash, rounddot, squaredot, dashdot, longdash, longdashdot, longdashdotdot
|
- ``dash`` Line types: dash, rounddot, squaredot, dashdot, longdash, longdashdot, longdashdotdot
|
||||||
- ``beginArrow`` Start type of arrow: block, open, classic, diamond, oval
|
- ``beginArrow`` Start type of arrow: block, open, classic, diamond, oval
|
||||||
- ``endArrow`` End type of arrow: block, open, classic, diamond, ovel
|
- ``endArrow`` End type of arrow: block, open, classic, diamond, ovel
|
||||||
- ``width`` Line-object width in pt
|
- ``width`` Line-object width in pt
|
||||||
- ``height`` Line-object height in pt
|
- ``height`` Line-object height in pt
|
||||||
- ``flip`` Flip the line element: true, false
|
- ``flip`` Flip the line element: true, false
|
||||||
|
|
||||||
Shapes
|
|
||||||
------
|
|
||||||
|
|
||||||
To be completed.
|
|
||||||
|
|
||||||
Charts
|
|
||||||
------
|
|
||||||
|
|
||||||
To be completed.
|
|
||||||
|
|
||||||
Form fields
|
|
||||||
-----------
|
|
||||||
|
|
||||||
To be completed.
|
|
||||||
|
|
||||||
Bookmarks
|
|
||||||
~~~~~
|
|
||||||
|
|
||||||
You can add Bookmarks to the document by using the function addBookmark:
|
|
||||||
|
|
||||||
.. code-block:: php
|
|
||||||
|
|
||||||
$section->addBookmark($name);
|
|
||||||
|
|
||||||
- ``$name`` The name of the bookmark which can be referenced in the addLink-Function as target. Should obviously be unique throughout the document.
|
|
||||||
|
|
@ -12,42 +12,82 @@ folder <https://github.com/PHPOffice/PHPWord/tree/master/samples/>`__.
|
||||||
|
|
||||||
.. code-block:: php
|
.. code-block:: php
|
||||||
|
|
||||||
|
<?php
|
||||||
require_once 'src/PhpWord/Autoloader.php';
|
require_once 'src/PhpWord/Autoloader.php';
|
||||||
\PhpOffice\PhpWord\Autoloader::register();
|
\PhpOffice\PhpWord\Autoloader::register();
|
||||||
|
|
||||||
|
// Creating the new document...
|
||||||
$phpWord = new \PhpOffice\PhpWord\PhpWord();
|
$phpWord = new \PhpOffice\PhpWord\PhpWord();
|
||||||
|
|
||||||
// Every element you want to append to the word document is placed in a section.
|
/* Note: any element you append to a document must reside inside of a Section. */
|
||||||
// To create a basic section:
|
|
||||||
|
// Adding an empty Section to the document...
|
||||||
$section = $phpWord->addSection();
|
$section = $phpWord->addSection();
|
||||||
|
// Adding Text element to the Section having font styled by default...
|
||||||
// After creating a section, you can append elements:
|
$section->addText(
|
||||||
$section->addText('Hello world!');
|
htmlspecialchars(
|
||||||
|
'"Learn from yesterday, live for today, hope for tomorrow. '
|
||||||
// You can directly style your text by giving the addText function an array:
|
. 'The important thing is not to stop questioning." '
|
||||||
$section->addText('Hello world! I am formatted.',
|
. '(Albert Einstein)'
|
||||||
array('name'=>'Tahoma', 'size'=>16, 'bold'=>true));
|
)
|
||||||
|
);
|
||||||
// If you often need the same style again you can create a user defined style
|
|
||||||
// to the word document and give the addText function the name of the style:
|
/*
|
||||||
$phpWord->addFontStyle('myOwnStyle',
|
* Note: it's possible to customize font style of the Text element you add in three ways:
|
||||||
array('name'=>'Verdana', 'size'=>14, 'color'=>'1B2232'));
|
* - inline;
|
||||||
$section->addText('Hello world! I am formatted by a user defined style',
|
* - using named font style (new font style object will be implicitly created);
|
||||||
'myOwnStyle');
|
* - using explicitly created font style object.
|
||||||
|
*/
|
||||||
// You can also put the appended element to local object like this:
|
|
||||||
$fontStyle = array(
|
// Adding Text element with font customized inline...
|
||||||
'name' => 'Verdana',
|
$section->addText(
|
||||||
'size' => 22,
|
htmlspecialchars(
|
||||||
'bold' => true,
|
'"Great achievement is usually born of great sacrifice, '
|
||||||
|
. 'and is never the result of selfishness." '
|
||||||
|
. '(Napoleon Hill)'
|
||||||
|
),
|
||||||
|
array('name' => 'Tahoma', 'size' => 10)
|
||||||
|
);
|
||||||
|
|
||||||
|
// Adding Text element with font customized using named font style...
|
||||||
|
$fontStyleName = 'oneUserDefinedStyle';
|
||||||
|
$phpWord->addFontStyle(
|
||||||
|
$fontStyleName,
|
||||||
|
array('name' => 'Tahoma', 'size' => 10, 'color' => '1B2232', 'bold' => true)
|
||||||
|
);
|
||||||
|
$section->addText(
|
||||||
|
htmlspecialchars(
|
||||||
|
'"The greatest accomplishment is not in never falling, '
|
||||||
|
. 'but in rising again after you fall." '
|
||||||
|
. '(Vince Lombardi)'
|
||||||
|
),
|
||||||
|
$fontStyleName
|
||||||
|
);
|
||||||
|
|
||||||
|
// Adding Text element with font customized using explicitly created font style object...
|
||||||
|
$fontStyle = new \PhpOffice\PhpWord\Style\Font();
|
||||||
|
$fontStyle->setBold(true);
|
||||||
|
$fontStyle->setName('Tahoma');
|
||||||
|
$fontStyle->setSize(13);
|
||||||
|
$myTextElement = $section->addText(
|
||||||
|
htmlspecialchars('"Believe you can and you\'re halfway there." (Theodor Roosevelt)')
|
||||||
);
|
);
|
||||||
$myTextElement = $section->addText('Hello World!');
|
|
||||||
$myTextElement->setFontStyle($fontStyle);
|
$myTextElement->setFontStyle($fontStyle);
|
||||||
|
|
||||||
// Finally, save the document:
|
// Saving the document as OOXML file...
|
||||||
$phpWord->save('helloWorld.docx');
|
$objWriter = \PhpOffice\PhpWord\IOFactory::createWriter($phpWord, 'Word2007');
|
||||||
$phpWord->save('helloWorld.odt', 'ODText');
|
$objWriter->save('helloWorld.docx');
|
||||||
$phpWord->save('helloWorld.rtf', 'RTF');
|
|
||||||
|
// Saving the document as ODF file...
|
||||||
|
$objWriter = \PhpOffice\PhpWord\IOFactory::createWriter($phpWord, 'ODText');
|
||||||
|
$objWriter->save('helloWorld.odt');
|
||||||
|
|
||||||
|
// Saving the document as HTML file...
|
||||||
|
$objWriter = \PhpOffice\PhpWord\IOFactory::createWriter($phpWord, 'HTML');
|
||||||
|
$objWriter->save('helloWorld.html');
|
||||||
|
|
||||||
|
/* Note: we skip RTF, because it's not XML-based and requires a different example. */
|
||||||
|
/* Note: we skip PDF, because "HTML-to-PDF" approach is used to create PDF documents. */
|
||||||
|
|
||||||
Settings
|
Settings
|
||||||
--------
|
--------
|
||||||
|
|
|
||||||
|
|
@ -181,15 +181,15 @@ Contributing
|
||||||
------------
|
------------
|
||||||
|
|
||||||
We welcome everyone to contribute to PHPWord. Below are some of the
|
We welcome everyone to contribute to PHPWord. Below are some of the
|
||||||
things that you can do to contribute:
|
things that you can do to contribute.
|
||||||
|
|
||||||
- Read `our contributing
|
- Read `our contributing
|
||||||
guide <https://github.com/PHPOffice/PHPWord/blob/master/CONTRIBUTING.md>`__
|
guide <https://github.com/PHPOffice/PHPWord/blob/master/CONTRIBUTING.md>`__.
|
||||||
- `Fork us <https://github.com/PHPOffice/PHPWord/fork>`__ and `request
|
- `Fork us <https://github.com/PHPOffice/PHPWord/fork>`__ and `request
|
||||||
a pull <https://github.com/PHPOffice/PHPWord/pulls>`__ to the
|
a pull <https://github.com/PHPOffice/PHPWord/pulls>`__ to the
|
||||||
`develop <https://github.com/PHPOffice/PHPWord/tree/develop>`__
|
`develop <https://github.com/PHPOffice/PHPWord/tree/develop>`__
|
||||||
branch
|
branch.
|
||||||
- Submit `bug reports or feature
|
- Submit `bug reports or feature
|
||||||
requests <https://github.com/PHPOffice/PHPWord/issues>`__ to GitHub
|
requests <https://github.com/PHPOffice/PHPWord/issues>`__ to GitHub.
|
||||||
- Follow `@PHPWord <https://twitter.com/PHPWord>`__ and
|
- Follow `@PHPWord <https://twitter.com/PHPWord>`__ and
|
||||||
`@PHPOffice <https://twitter.com/PHPOffice>`__ on Twitter
|
`@PHPOffice <https://twitter.com/PHPOffice>`__ on Twitter.
|
||||||
|
|
|
||||||
|
|
@ -212,42 +212,82 @@ After installation, you can browse and use the samples that we've provided, eith
|
||||||
The following is a basic example of the PHPWord library. More examples are provided in the [samples folder](https://github.com/PHPOffice/PHPWord/tree/master/samples/).
|
The following is a basic example of the PHPWord library. More examples are provided in the [samples folder](https://github.com/PHPOffice/PHPWord/tree/master/samples/).
|
||||||
|
|
||||||
```php
|
```php
|
||||||
|
<?php
|
||||||
require_once 'src/PhpWord/Autoloader.php';
|
require_once 'src/PhpWord/Autoloader.php';
|
||||||
\PhpOffice\PhpWord\Autoloader::register();
|
\PhpOffice\PhpWord\Autoloader::register();
|
||||||
|
|
||||||
|
// Creating the new document...
|
||||||
$phpWord = new \PhpOffice\PhpWord\PhpWord();
|
$phpWord = new \PhpOffice\PhpWord\PhpWord();
|
||||||
|
|
||||||
// Every element you want to append to the word document is placed in a section.
|
/* Note: any element you append to a document must reside inside of a Section. */
|
||||||
// To create a basic section:
|
|
||||||
|
// Adding an empty Section to the document...
|
||||||
$section = $phpWord->addSection();
|
$section = $phpWord->addSection();
|
||||||
|
// Adding Text element to the Section having font styled by default...
|
||||||
// After creating a section, you can append elements:
|
$section->addText(
|
||||||
$section->addText('Hello world!');
|
htmlspecialchars(
|
||||||
|
'"Learn from yesterday, live for today, hope for tomorrow. '
|
||||||
// You can directly style your text by giving the addText function an array:
|
. 'The important thing is not to stop questioning." '
|
||||||
$section->addText('Hello world! I am formatted.',
|
. '(Albert Einstein)'
|
||||||
array('name'=>'Tahoma', 'size'=>16, 'bold'=>true));
|
)
|
||||||
|
);
|
||||||
// If you often need the same style again you can create a user defined style
|
|
||||||
// to the word document and give the addText function the name of the style:
|
/*
|
||||||
$phpWord->addFontStyle('myOwnStyle',
|
* Note: it's possible to customize font style of the Text element you add in three ways:
|
||||||
array('name'=>'Verdana', 'size'=>14, 'color'=>'1B2232'));
|
* - inline;
|
||||||
$section->addText('Hello world! I am formatted by a user defined style',
|
* - using named font style (new font style object will be implicitly created);
|
||||||
'myOwnStyle');
|
* - using explicitly created font style object.
|
||||||
|
*/
|
||||||
// You can also put the appended element to local object like this:
|
|
||||||
$fontStyle = array(
|
// Adding Text element with font customized inline...
|
||||||
'name' => 'Verdana',
|
$section->addText(
|
||||||
'size' => 22,
|
htmlspecialchars(
|
||||||
'bold' => true,
|
'"Great achievement is usually born of great sacrifice, '
|
||||||
|
. 'and is never the result of selfishness." '
|
||||||
|
. '(Napoleon Hill)'
|
||||||
|
),
|
||||||
|
array('name' => 'Tahoma', 'size' => 10)
|
||||||
|
);
|
||||||
|
|
||||||
|
// Adding Text element with font customized using named font style...
|
||||||
|
$fontStyleName = 'oneUserDefinedStyle';
|
||||||
|
$phpWord->addFontStyle(
|
||||||
|
$fontStyleName,
|
||||||
|
array('name' => 'Tahoma', 'size' => 10, 'color' => '1B2232', 'bold' => true)
|
||||||
|
);
|
||||||
|
$section->addText(
|
||||||
|
htmlspecialchars(
|
||||||
|
'"The greatest accomplishment is not in never falling, '
|
||||||
|
. 'but in rising again after you fall." '
|
||||||
|
. '(Vince Lombardi)'
|
||||||
|
),
|
||||||
|
$fontStyleName
|
||||||
|
);
|
||||||
|
|
||||||
|
// Adding Text element with font customized using explicitly created font style object...
|
||||||
|
$fontStyle = new \PhpOffice\PhpWord\Style\Font();
|
||||||
|
$fontStyle->setBold(true);
|
||||||
|
$fontStyle->setName('Tahoma');
|
||||||
|
$fontStyle->setSize(13);
|
||||||
|
$myTextElement = $section->addText(
|
||||||
|
htmlspecialchars('"Believe you can and you\'re halfway there." (Theodor Roosevelt)')
|
||||||
);
|
);
|
||||||
$myTextElement = $section->addText('Hello World!');
|
|
||||||
$myTextElement->setFontStyle($fontStyle);
|
$myTextElement->setFontStyle($fontStyle);
|
||||||
|
|
||||||
// Finally, save the document:
|
// Saving the document as OOXML file...
|
||||||
$phpWord->save('helloWorld.docx');
|
$objWriter = \PhpOffice\PhpWord\IOFactory::createWriter($phpWord, 'Word2007');
|
||||||
$phpWord->save('helloWorld.odt', 'ODText');
|
$objWriter->save('helloWorld.docx');
|
||||||
$phpWord->save('helloWorld.rtf', 'RTF');
|
|
||||||
|
// Saving the document as ODF file...
|
||||||
|
$objWriter = \PhpOffice\PhpWord\IOFactory::createWriter($phpWord, 'ODText');
|
||||||
|
$objWriter->save('helloWorld.odt');
|
||||||
|
|
||||||
|
// Saving the document as HTML file...
|
||||||
|
$objWriter = \PhpOffice\PhpWord\IOFactory::createWriter($phpWord, 'HTML');
|
||||||
|
$objWriter->save('helloWorld.html');
|
||||||
|
|
||||||
|
/* Note: we skip RTF, because it's not XML-based and requires a different example. */
|
||||||
|
/* Note: we skip PDF, because "HTML-to-PDF" approach is used to create PDF documents. */
|
||||||
```
|
```
|
||||||
|
|
||||||
## Settings
|
## Settings
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,7 @@
|
||||||
<?php
|
<?php
|
||||||
|
require_once __DIR__ . '/../src/PhpWord/Autoloader.php';
|
||||||
|
|
||||||
date_default_timezone_set('Europe/Paris');
|
date_default_timezone_set('UTC');
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Header file
|
* Header file
|
||||||
|
|
@ -14,7 +15,6 @@ define('EOL', CLI ? PHP_EOL : '<br />');
|
||||||
define('SCRIPT_FILENAME', basename($_SERVER['SCRIPT_FILENAME'], '.php'));
|
define('SCRIPT_FILENAME', basename($_SERVER['SCRIPT_FILENAME'], '.php'));
|
||||||
define('IS_INDEX', SCRIPT_FILENAME == 'index');
|
define('IS_INDEX', SCRIPT_FILENAME == 'index');
|
||||||
|
|
||||||
require_once __DIR__ . '/../src/PhpWord/Autoloader.php';
|
|
||||||
Autoloader::register();
|
Autoloader::register();
|
||||||
Settings::loadConfig();
|
Settings::loadConfig();
|
||||||
|
|
||||||
|
|
@ -22,7 +22,7 @@ Settings::loadConfig();
|
||||||
$writers = array('Word2007' => 'docx', 'ODText' => 'odt', 'RTF' => 'rtf', 'HTML' => 'html', 'PDF' => 'pdf');
|
$writers = array('Word2007' => 'docx', 'ODText' => 'odt', 'RTF' => 'rtf', 'HTML' => 'html', 'PDF' => 'pdf');
|
||||||
|
|
||||||
// Set PDF renderer
|
// Set PDF renderer
|
||||||
if (Settings::getPdfRendererPath() === null) {
|
if (null === Settings::getPdfRendererPath()) {
|
||||||
$writers['PDF'] = null;
|
$writers['PDF'] = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -55,6 +55,8 @@ if ($handle = opendir('.')) {
|
||||||
* @param \PhpOffice\PhpWord\PhpWord $phpWord
|
* @param \PhpOffice\PhpWord\PhpWord $phpWord
|
||||||
* @param string $filename
|
* @param string $filename
|
||||||
* @param array $writers
|
* @param array $writers
|
||||||
|
*
|
||||||
|
* @return string
|
||||||
*/
|
*/
|
||||||
function write($phpWord, $filename, $writers)
|
function write($phpWord, $filename, $writers)
|
||||||
{
|
{
|
||||||
|
|
@ -63,7 +65,7 @@ function write($phpWord, $filename, $writers)
|
||||||
// Write documents
|
// Write documents
|
||||||
foreach ($writers as $format => $extension) {
|
foreach ($writers as $format => $extension) {
|
||||||
$result .= date('H:i:s') . " Write to {$format} format";
|
$result .= date('H:i:s') . " Write to {$format} format";
|
||||||
if ($extension !== null) {
|
if (null !== $extension) {
|
||||||
$targetFile = __DIR__ . "/results/{$filename}.{$extension}";
|
$targetFile = __DIR__ . "/results/{$filename}.{$extension}";
|
||||||
$phpWord->save($targetFile, $format);
|
$phpWord->save($targetFile, $format);
|
||||||
} else {
|
} else {
|
||||||
|
|
@ -81,6 +83,8 @@ function write($phpWord, $filename, $writers)
|
||||||
* Get ending notes
|
* Get ending notes
|
||||||
*
|
*
|
||||||
* @param array $writers
|
* @param array $writers
|
||||||
|
*
|
||||||
|
* @return string
|
||||||
*/
|
*/
|
||||||
function getEndingNotes($writers)
|
function getEndingNotes($writers)
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -2,8 +2,9 @@
|
||||||
include_once 'Sample_Header.php';
|
include_once 'Sample_Header.php';
|
||||||
|
|
||||||
use PhpOffice\PhpWord\Settings;
|
use PhpOffice\PhpWord\Settings;
|
||||||
|
|
||||||
$requirements = array(
|
$requirements = array(
|
||||||
'php' => array('PHP 5.3.0', version_compare(phpversion(), '5.3.0', '>=')),
|
'php' => array('PHP 5.3.3', version_compare(PHP_VERSION, '5.3.3', '>=')),
|
||||||
'xml' => array('PHP extension XML', extension_loaded('xml')),
|
'xml' => array('PHP extension XML', extension_loaded('xml')),
|
||||||
'temp' => array('Temp folder "<code>' . Settings::getTempDir() . '</code>" is writable', is_writable(Settings::getTempDir())),
|
'temp' => array('Temp folder "<code>' . Settings::getTempDir() . '</code>" is writable', is_writable(Settings::getTempDir())),
|
||||||
'zip' => array('PHP extension ZipArchive (optional)', extension_loaded('zip')),
|
'zip' => array('PHP extension ZipArchive (optional)', extension_loaded('zip')),
|
||||||
|
|
|
||||||
|
|
@ -122,7 +122,7 @@ class PhpWord
|
||||||
|
|
||||||
$styles = array('Paragraph', 'Font', 'Table', 'Numbering', 'Link', 'Title');
|
$styles = array('Paragraph', 'Font', 'Table', 'Numbering', 'Link', 'Title');
|
||||||
foreach ($styles as $style) {
|
foreach ($styles as $style) {
|
||||||
$addStyle[] = strtolower("add{$style}style");
|
$addStyle[] = strtolower("add{$style}Style");
|
||||||
}
|
}
|
||||||
|
|
||||||
// Run get collection method
|
// Run get collection method
|
||||||
|
|
|
||||||
|
|
@ -35,7 +35,7 @@ class ListItem extends AbstractElement
|
||||||
return '';
|
return '';
|
||||||
}
|
}
|
||||||
|
|
||||||
$text = htmlspecialchars($this->element->getTextObject()->getText());
|
$text = $this->element->getTextObject()->getText();
|
||||||
$content = '<p>' . $text . '</p>' . PHP_EOL;
|
$content = '<p>' . $text . '</p>' . PHP_EOL;
|
||||||
|
|
||||||
return $content;
|
return $content;
|
||||||
|
|
|
||||||
|
|
@ -24,4 +24,21 @@ namespace PhpOffice\PhpWord\Writer\HTML\Element;
|
||||||
*/
|
*/
|
||||||
class PageBreak extends TextBreak
|
class PageBreak extends TextBreak
|
||||||
{
|
{
|
||||||
|
/**
|
||||||
|
* Write page break
|
||||||
|
*
|
||||||
|
* @since 0.12.0
|
||||||
|
*
|
||||||
|
* @return string
|
||||||
|
*/
|
||||||
|
public function write()
|
||||||
|
{
|
||||||
|
/** @var \PhpOffice\PhpWord\Writer\HTML $parentWriter Type hint */
|
||||||
|
$parentWriter = $this->parentWriter;
|
||||||
|
if ($parentWriter->isPdf()) {
|
||||||
|
return '<pagebreak style="page-break-before: always;" pagebreak="true"></pagebreak>';
|
||||||
|
}
|
||||||
|
|
||||||
|
return "";
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -51,7 +51,7 @@ class Table extends AbstractElement
|
||||||
$cellTag = $tblHeader ? 'th' : 'td';
|
$cellTag = $tblHeader ? 'th' : 'td';
|
||||||
$content .= "<{$cellTag}>" . PHP_EOL;
|
$content .= "<{$cellTag}>" . PHP_EOL;
|
||||||
$content .= $writer->write();
|
$content .= $writer->write();
|
||||||
$content .= '</td>' . PHP_EOL;
|
$content .= "</{$cellTag}>" . PHP_EOL;
|
||||||
}
|
}
|
||||||
$content .= '</tr>' . PHP_EOL;
|
$content .= '</tr>' . PHP_EOL;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -72,7 +72,7 @@ class Text extends AbstractElement
|
||||||
$content .= $this->writeOpening();
|
$content .= $this->writeOpening();
|
||||||
$content .= $this->openingText;
|
$content .= $this->openingText;
|
||||||
$content .= $this->openingTags;
|
$content .= $this->openingTags;
|
||||||
$content .= htmlspecialchars($element->getText());
|
$content .= $element->getText();
|
||||||
$content .= $this->closingTags;
|
$content .= $this->closingTags;
|
||||||
$content .= $this->closingText;
|
$content .= $this->closingText;
|
||||||
$content .= $this->writeClosing();
|
$content .= $this->writeClosing();
|
||||||
|
|
|
||||||
|
|
@ -36,7 +36,7 @@ class Title extends AbstractElement
|
||||||
}
|
}
|
||||||
|
|
||||||
$tag = 'h' . $this->element->getDepth();
|
$tag = 'h' . $this->element->getDepth();
|
||||||
$text = htmlspecialchars($this->element->getText());
|
$text = $this->element->getText();
|
||||||
$content = "<{$tag}>{$text}</{$tag}>" . PHP_EOL;
|
$content = "<{$tag}>{$text}</{$tag}>" . PHP_EOL;
|
||||||
|
|
||||||
return $content;
|
return $content;
|
||||||
|
|
|
||||||
|
|
@ -18,9 +18,9 @@
|
||||||
namespace PhpOffice\PhpWord\Writer\HTML\Part;
|
namespace PhpOffice\PhpWord\Writer\HTML\Part;
|
||||||
|
|
||||||
use PhpOffice\PhpWord\Settings;
|
use PhpOffice\PhpWord\Settings;
|
||||||
|
use PhpOffice\PhpWord\Style;
|
||||||
use PhpOffice\PhpWord\Style\Font;
|
use PhpOffice\PhpWord\Style\Font;
|
||||||
use PhpOffice\PhpWord\Style\Paragraph;
|
use PhpOffice\PhpWord\Style\Paragraph;
|
||||||
use PhpOffice\PhpWord\Style;
|
|
||||||
use PhpOffice\PhpWord\Writer\HTML\Style\Font as FontStyleWriter;
|
use PhpOffice\PhpWord\Writer\HTML\Style\Font as FontStyleWriter;
|
||||||
use PhpOffice\PhpWord\Writer\HTML\Style\Generic as GenericStyleWriter;
|
use PhpOffice\PhpWord\Writer\HTML\Style\Generic as GenericStyleWriter;
|
||||||
use PhpOffice\PhpWord\Writer\HTML\Style\Paragraph as ParagraphStyleWriter;
|
use PhpOffice\PhpWord\Writer\HTML\Style\Paragraph as ParagraphStyleWriter;
|
||||||
|
|
@ -57,13 +57,13 @@ class Head extends AbstractPart
|
||||||
|
|
||||||
$content .= '<head>' . PHP_EOL;
|
$content .= '<head>' . PHP_EOL;
|
||||||
$content .= '<meta charset="UTF-8" />' . PHP_EOL;
|
$content .= '<meta charset="UTF-8" />' . PHP_EOL;
|
||||||
$content .= '<title>' . htmlspecialchars($title) . '</title>' . PHP_EOL;
|
$content .= '<title>' . $title . '</title>' . PHP_EOL;
|
||||||
foreach ($propertiesMapping as $key => $value) {
|
foreach ($propertiesMapping as $key => $value) {
|
||||||
$value = ($value == '') ? $key : $value;
|
$value = ($value == '') ? $key : $value;
|
||||||
$method = "get" . $key;
|
$method = "get" . $key;
|
||||||
if ($docProps->$method() != '') {
|
if ($docProps->$method() != '') {
|
||||||
$content .= '<meta name="' . $value . '" content="' .
|
$content .= '<meta name="' . $value . '" content="' .
|
||||||
htmlspecialchars($docProps->$method()) . '" />' . PHP_EOL;
|
$docProps->$method() . '" />' . PHP_EOL;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
$content .= $this->writeStyles();
|
$content .= $this->writeStyles();
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue