Skip to content

Commit db1d89a

Browse files
author
Roman Syroeshko
committed
Merge remote-tracking branch 'origin/develop' into develop
Conflicts: src/PhpWord/Element/Section.php src/PhpWord/Endnotes.php src/PhpWord/Footnotes.php src/PhpWord/Media.php src/PhpWord/PhpWord.php src/PhpWord/Reader/Word2007.php src/PhpWord/Writer/AbstractWriter.php src/PhpWord/Writer/ODText/Content.php src/PhpWord/Writer/Word2007.php src/PhpWord/Writer/Word2007/Notes.php
2 parents 2c1c1ea + 898be23 commit db1d89a

File tree

97 files changed

+4080
-1001
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

97 files changed

+4080
-1001
lines changed

.travis.yml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,9 @@ before_script:
1818
## Composer
1919
# - curl -s http://getcomposer.org/installer | php
2020
# - php composer.phar install --prefer-source
21+
- composer self-update
22+
- composer require dompdf/dompdf:0.6.*
2123
- composer install --prefer-source
22-
- composer selfupdate --quiet
2324
## PHP_CodeSniffer
2425
- pyrus install pear/PHP_CodeSniffer
2526
- phpenv rehash

CHANGELOG.md

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,9 @@
22

33
This is the changelog between releases of PHPWord. Releases are listed in reverse chronological order with the latest version listed on top, while additions/changes in each release are listed in chronological order. Changes in each release are divided into three parts: added or change features, bugfixes, and miscellaneous improvements. Each line contains short information about the change made, the person who made it, and the related issue number(s) in GitHub.
44

5-
## 0.9.2 - Not yet released
5+
## 0.10.0 - Not yet released
66

7-
This release marked heavy refactorings on internal code structure with the creation of some abstract classes to reduce code duplication. `Element` subnamespace is introduced in this release to replace `Section`. Word2007 reader capability is greatly enhanced. Endnote is introduced.
7+
This release marked heavy refactorings on internal code structure with the creation of some abstract classes to reduce code duplication. `Element` subnamespace is introduced in this release to replace `Section`. Word2007 reader capability is greatly enhanced. Endnote is introduced. List numbering is now customizable. Basic HTML and PDF writing support is enabled.
88

99
### Features
1010

@@ -27,12 +27,18 @@ This release marked heavy refactorings on internal code structure with the creat
2727
- Object: Ability to add object in header, footer, textrun, and footnote - @ivanlanin GH-187
2828
- Media: Add `Media::resetElements()` to reset all media data - @juzi GH-19
2929
- General: Add `Style::resetStyles()`, `Footnote::resetElements()`, and `TOC::resetTitles()` - @ivanlanin GH-187
30-
- Reader: Ability to read header, footer, footnotes, link, preservetext, textbreak, pagebreak, table - @ivanlanin
30+
- DOCX Reader: Ability to read header, footer, footnotes, link, preservetext, textbreak, pagebreak, table, list, image - @ivanlanin
3131
- Endnote: Ability to add endnotes - @ivanlanin
32+
- ListItem: Ability to create custom list and reset list number - @ivanlanin GH-10 GH-198
33+
- ODT Writer: Basic table writing support - @ivanlanin
34+
- Image: Keep image aspect ratio if only 1 dimension styled - @japonicus GH-194
35+
- HTML Writer: Basic HTML writer: text, textrun, link, title, textbreak, table, image (as Base64), footnote, endnote - @ivanlanin GH-203 GH-67 GH-147
36+
- PDF Writer: Basic PDF writer using DomPDF: All HTML element except image - @ivanlanin GH-68
3237

3338
### Bugfixes
3439

3540
- Footnote: Footnote content doesn't show footnote reference number - @ivanlanin GH-170
41+
- Documentation : Error in a fonction - @theBeerNut GH-195
3642

3743
### Deprecated
3844

@@ -61,6 +67,8 @@ This release marked heavy refactorings on internal code structure with the creat
6167
- Style: New `Style\AbstractStyle` abstract class - @ivanlanin GH-187
6268
- Writer: New 'ODText\Base` class - @ivanlanin GH-187
6369
- General: Rename `Footnote` to `Footnotes` to reflect the nature of collection - @ivanlanin
70+
- General: Add some unit tests for Shared & Element (100%!) - @Progi1984
71+
- Test: Add some samples and tests for image wrapping style - @brunocasado GH-59
6472

6573
## 0.9.1 - 27 Mar 2014
6674

composer.json

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -40,9 +40,10 @@
4040
"phpunit/phpunit": "3.7.*"
4141
},
4242
"suggest": {
43-
"ext-gd2": "*",
44-
"ext-xmlwriter": "*",
45-
"ext-xsl": "*"
43+
"ext-gd2": "Required to add images",
44+
"ext-xmlwriter": "Required to write DOCX and ODT",
45+
"ext-xsl": "Required to apply XSL style sheet to template part",
46+
"dompdf/dompdf": "Required to write PDF"
4647
},
4748
"autoload": {
4849
"psr-4": {

docs/elements.rst

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -207,10 +207,14 @@ Lists
207207

208208
To add a list item use the function ``addListItem``.
209209

210+
Basic usage:
211+
210212
.. code-block:: php
211213
212214
$section->addListItem($text, [$depth], [$fontStyle], [$listStyle], [$paragraphStyle]);
213215
216+
Parameters:
217+
214218
- ``$text`` Text that appears in the document.
215219
- ``$depth`` Depth of list item.
216220
- ``$fontStyle`` See "Font style" section.
@@ -219,6 +223,40 @@ To add a list item use the function ``addListItem``.
219223
PHPWord\_Style\_ListItem.
220224
- ``$paragraphStyle`` See "Paragraph style" section.
221225

226+
Advanced usage:
227+
228+
You can also create your own numbering style by changing the ``$listStyle`` parameter
229+
with the name of your numbering style.
230+
231+
.. code-block:: php
232+
233+
$phpWord->addNumberingStyle(
234+
'multilevel',
235+
array('type' => 'multilevel', 'levels' => array(
236+
array('format' => 'decimal', 'text' => '%1.', 'left' => 360, 'hanging' => 360, 'tabPos' => 360),
237+
array('format' => 'upperLetter', 'text' => '%2.', 'left' => 720, 'hanging' => 360, 'tabPos' => 720),
238+
)
239+
)
240+
);
241+
$section->addListItem('List Item I', 0, null, 'multilevel');
242+
$section->addListItem('List Item I.a', 1, null, 'multilevel');
243+
$section->addListItem('List Item I.b', 1, null, 'multilevel');
244+
$section->addListItem('List Item II', 0, null, 'multilevel');
245+
246+
Level styles:
247+
248+
- ``start`` Starting value
249+
- ``format`` Numbering format bullet|decimal|upperRoman|lowerRoman|upperLetter|lowerLetter
250+
- ``restart`` Restart numbering level symbol
251+
- ``suffix`` Content between numbering symbol and paragraph text tab|space|nothing
252+
- ``text`` Numbering level text e.g. %1 for nonbullet or bullet character
253+
- ``align`` Numbering symbol align left|center|right|both
254+
- ``left`` See paragraph style
255+
- ``hanging`` See paragraph style
256+
- ``tabPos`` See paragraph style
257+
- ``font`` Font name
258+
- ``hint`` See font style
259+
222260
Tables
223261
------
224262

docs/general.rst

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -63,9 +63,9 @@ XML Writer compatibility
6363
~~~~~~~~~~~~~~~~~~~~~~~~
6464

6565
This option sets
66-
```XMLWriter::setIndent`` <http://www.php.net/manual/en/function.xmlwriter-set-indent.php>`__
66+
`XMLWriter::setIndent <http://www.php.net/manual/en/function.xmlwriter-set-indent.php>`__
6767
and
68-
```XMLWriter::setIndentString`` <http://www.php.net/manual/en/function.xmlwriter-set-indent-string.php>`__.
68+
`XMLWriter::setIndentString <http://www.php.net/manual/en/function.xmlwriter-set-indent-string.php>`__.
6969
The default value of this option is ``true`` (compatible), which is
7070
`required for OpenOffice <https://github.com/PHPOffice/PHPWord/issues/103>`__ to
7171
render OOXML document correctly. You can set this option to ``false``
@@ -108,7 +108,7 @@ name. Use the following functions:
108108

109109
.. code-block:: php
110110
111-
$properties = $phpWord->getProperties();
111+
$properties = $phpWord->getDocumentProperties();
112112
$properties->setCreator('My name');
113113
$properties->setCompany('My factory');
114114
$properties->setTitle('My title');

docs/intro.rst

Lines changed: 57 additions & 57 deletions
Original file line numberDiff line numberDiff line change
@@ -62,63 +62,63 @@ Below are the supported features for each file formats.
6262
Writers
6363
~~~~~~~
6464

65-
+-------------------------------------------------+--------+-------+-------+
66-
| Features | DOCX | ODT | RTF |
67-
+=========================+=======================+========+=======+=======+
68-
| **Document Properties** | Standard | | | |
69-
+ +-----------------------+--------+-------+-------+
70-
| | Extended | | | |
71-
+ +-----------------------+--------+-------+-------+
72-
| | UserDefined | | | |
73-
+-------------------------+-----------------------+--------+-------+-------+
74-
| **Element Type** | Text ||||
75-
+ +-----------------------+--------+-------+-------+
76-
| | Text Run ||||
77-
+ +-----------------------+--------+-------+-------+
78-
| | Title || | |
79-
+ +-----------------------+--------+-------+-------+
80-
| | Link || | |
81-
+ +-----------------------+--------+-------+-------+
82-
| | Preserve Text || | |
83-
+ +-----------------------+--------+-------+-------+
84-
| | Text Break ||||
85-
+ +-----------------------+--------+-------+-------+
86-
| | Page Break || | |
87-
+ +-----------------------+--------+-------+-------+
88-
| | List || | |
89-
+ +-----------------------+--------+-------+-------+
90-
| | Table || | |
91-
+ +-----------------------+--------+-------+-------+
92-
| | Image || | |
93-
+ +-----------------------+--------+-------+-------+
94-
| | Object || | |
95-
+ +-----------------------+--------+-------+-------+
96-
| | Watermark || | |
97-
+ +-----------------------+--------+-------+-------+
98-
| | Table of Contents || | |
99-
+ +-----------------------+--------+-------+-------+
100-
| | Header || | |
101-
+ +-----------------------+--------+-------+-------+
102-
| | Footer || | |
103-
+ +-----------------------+--------+-------+-------+
104-
| | Footnote || | |
105-
+ +-----------------------+--------+-------+-------+
106-
| | Endnote || | |
107-
+-------------------------+-----------------------+--------+-------+-------+
108-
| **Graphs** | 2D basic graphs | | | |
109-
+ +-----------------------+--------+-------+-------+
110-
| | 2D advanced graphs | | | |
111-
+ +-----------------------+--------+-------+-------+
112-
| | 3D graphs | | | |
113-
+-------------------------+-----------------------+--------+-------+-------+
114-
| **Math** | OMML support | | | |
115-
+ +-----------------------+--------+-------+-------+
116-
| | MathML support | | | |
117-
+-------------------------+-----------------------+--------+-------+-------+
118-
| **Bonus** | Encryption | | | |
119-
+ +-----------------------+--------+-------+-------+
120-
| | Protection | | | |
121-
+-------------------------+-----------------------+--------+-------+-------+
65+
+-------------------------------------------------+--------+-------+-------+-------+-------+
66+
| Features | DOCX | ODT | RTF | HTML | PDF |
67+
+=========================+=======================+========+=======+=======+=======+=======+
68+
| **Document Properties** | Standard | | | | | |
69+
+ +-----------------------+--------+-------+-------+-------+-------+
70+
| | Extended | | | | | |
71+
+ +-----------------------+--------+-------+-------+-------+-------+
72+
| | UserDefined | | | | | |
73+
+-------------------------+-----------------------+--------+-------+-------+-------+-------+
74+
| **Element Type** | Text ||||||
75+
+ +-----------------------+--------+-------+-------+-------+-------+
76+
| | Text Run ||||||
77+
+ +-----------------------+--------+-------+-------+-------+-------+
78+
| | Title || | |||
79+
+ +-----------------------+--------+-------+-------+-------+-------+
80+
| | Link || | |||
81+
+ +-----------------------+--------+-------+-------+-------+-------+
82+
| | Preserve Text || | | | |
83+
+ +-----------------------+--------+-------+-------+-------+-------+
84+
| | Text Break ||||||
85+
+ +-----------------------+--------+-------+-------+-------+-------+
86+
| | Page Break || | | | |
87+
+ +-----------------------+--------+-------+-------+-------+-------+
88+
| | List || | | | |
89+
+ +-----------------------+--------+-------+-------+-------+-------+
90+
| | Table || | || |
91+
+ +-----------------------+--------+-------+-------+-------+-------+
92+
| | Image || | || |
93+
+ +-----------------------+--------+-------+-------+-------+-------+
94+
| | Object || | | | |
95+
+ +-----------------------+--------+-------+-------+-------+-------+
96+
| | Watermark || | | | |
97+
+ +-----------------------+--------+-------+-------+-------+-------+
98+
| | Table of Contents || | | | |
99+
+ +-----------------------+--------+-------+-------+-------+-------+
100+
| | Header || | | | |
101+
+ +-----------------------+--------+-------+-------+-------+-------+
102+
| | Footer || | | | |
103+
+ +-----------------------+--------+-------+-------+-------+-------+
104+
| | Footnote || | || |
105+
+ +-----------------------+--------+-------+-------+-------+-------+
106+
| | Endnote || | || |
107+
+-------------------------+-----------------------+--------+-------+-------+-------+-------+
108+
| **Graphs** | 2D basic graphs | | | | | |
109+
+ +-----------------------+--------+-------+-------+-------+-------+
110+
| | 2D advanced graphs | | | | | |
111+
+ +-----------------------+--------+-------+-------+-------+-------+
112+
| | 3D graphs | | | | | |
113+
+-------------------------+-----------------------+--------+-------+-------+-------+-------+
114+
| **Math** | OMML support | | | | | |
115+
+ +-----------------------+--------+-------+-------+-------+-------+
116+
| | MathML support | | | | | |
117+
+-------------------------+-----------------------+--------+-------+-------+-------+-------+
118+
| **Bonus** | Encryption | | | | | |
119+
+ +-----------------------+--------+-------+-------+-------+-------+
120+
| | Protection | | | | | |
121+
+-------------------------+-----------------------+--------+-------+-------+-------+-------+
122122

123123

124124
Readers

samples/Sample_01_SimpleText.php

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -45,13 +45,7 @@
4545
$section->addImage('resources/_earth.jpg', array('width'=>18, 'height'=>18));
4646

4747
// Save file
48-
$name = basename(__FILE__, '.php');
49-
$writers = array('Word2007' => 'docx', 'ODText' => 'odt', 'RTF' => 'rtf');
50-
foreach ($writers as $writer => $extension) {
51-
echo date('H:i:s'), " Write to {$writer} format", EOL;
52-
$xmlWriter = \PhpOffice\PhpWord\IOFactory::createWriter($phpWord, $writer);
53-
$xmlWriter->save("{$name}.{$extension}");
54-
rename("{$name}.{$extension}", "results/{$name}.{$extension}");
48+
echo write($phpWord, basename(__FILE__, '.php'), $writers);
49+
if (!CLI) {
50+
include_once 'Sample_Footer.php';
5551
}
56-
57-
include_once 'Sample_Footer.php';

samples/Sample_02_TabStops.php

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -33,13 +33,7 @@
3333
$section->addText("\tCenter Aligned", null, 'centerTab');
3434

3535
// Save file
36-
$name = basename(__FILE__, '.php');
37-
$writers = array('Word2007' => 'docx', 'ODText' => 'odt', 'RTF' => 'rtf');
38-
foreach ($writers as $writer => $extension) {
39-
echo date('H:i:s'), " Write to {$writer} format", EOL;
40-
$xmlWriter = \PhpOffice\PhpWord\IOFactory::createWriter($phpWord, $writer);
41-
$xmlWriter->save("{$name}.{$extension}");
42-
rename("{$name}.{$extension}", "results/{$name}.{$extension}");
36+
echo write($phpWord, basename(__FILE__, '.php'), $writers);
37+
if (!CLI) {
38+
include_once 'Sample_Footer.php';
4339
}
44-
45-
include_once 'Sample_Footer.php';

samples/Sample_03_Sections.php

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -26,13 +26,7 @@
2626
$section->addFooter()->addText('Footer');
2727

2828
// Save file
29-
$name = basename(__FILE__, '.php');
30-
$writers = array('Word2007' => 'docx', 'ODText' => 'odt', 'RTF' => 'rtf');
31-
foreach ($writers as $writer => $extension) {
32-
echo date('H:i:s'), " Write to {$writer} format", EOL;
33-
$xmlWriter = \PhpOffice\PhpWord\IOFactory::createWriter($phpWord, $writer);
34-
$xmlWriter->save("{$name}.{$extension}");
35-
rename("{$name}.{$extension}", "results/{$name}.{$extension}");
29+
echo write($phpWord, basename(__FILE__, '.php'), $writers);
30+
if (!CLI) {
31+
include_once 'Sample_Footer.php';
3632
}
37-
38-
include_once 'Sample_Footer.php';

samples/Sample_04_Textrun.php

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -34,13 +34,7 @@
3434
$textrun->addText(' Here is some more text. ');
3535

3636
// Save file
37-
$name = basename(__FILE__, '.php');
38-
$writers = array('Word2007' => 'docx', 'ODText' => 'odt', 'RTF' => 'rtf');
39-
foreach ($writers as $writer => $extension) {
40-
echo date('H:i:s'), " Write to {$writer} format", EOL;
41-
$xmlWriter = \PhpOffice\PhpWord\IOFactory::createWriter($phpWord, $writer);
42-
$xmlWriter->save("{$name}.{$extension}");
43-
rename("{$name}.{$extension}", "results/{$name}.{$extension}");
37+
echo write($phpWord, basename(__FILE__, '.php'), $writers);
38+
if (!CLI) {
39+
include_once 'Sample_Footer.php';
4440
}
45-
46-
include_once 'Sample_Footer.php';

0 commit comments

Comments
 (0)