Skip to content

Commit a4df134

Browse files
committed
Merge remote-tracking branch 'origin/develop' into develop
Conflicts: samples/Sample_27_Field.php src/PhpWord/Element/AbstractElement.php src/PhpWord/Element/Comment.php src/PhpWord/Element/TrackChange.php src/PhpWord/Writer/Word2007/Element/AbstractElement.php tests/PhpWord/Writer/Word2007/Part/StylesTest.php
2 parents a6c6f9f + 0beeb27 commit a4df134

Some content is hidden

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

83 files changed

+2008
-336
lines changed

.travis.yml

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,19 @@
11
language: php
22

3+
dist: precise
4+
35
php:
46
- 5.3
57
- 5.4
68
- 5.5
79
- 5.6
810
- 7.0
9-
- hhvm
11+
## - hhvm
1012

1113
matrix:
1214
allow_failures:
1315
- php: 7.0
14-
- php: hhvm
16+
## - php: hhvm
1517

1618
env:
1719
global:

CHANGELOG.md

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,33 @@ Change Log
33
All notable changes to this project will be documented in this file.
44
This project adheres to [Semantic Versioning](http://semver.org/).
55

6+
v0.14.0 (?? ???? 2017)
7+
----------------------
8+
This release fixes several bugs and adds some new features.
9+
This is the last version to support PHP 5.3
10+
11+
### Added
12+
- Possibility to control the footnote numbering - @troosan #1068
13+
- Image creation from string - @troosan #937
14+
- Introduced the `\PhpOffice\PhpWord\SimpleType\NumberFormat` simple type. - @troosan
15+
- Support for ContextualSpacing - @postHawk #1088
16+
- Possiblity to hide spelling and/or grammatical errors - @troosan #542
17+
- Possiblity to set default document language as well as changing the language for each text element - @troosan #1108
18+
- Support for Comments - @troosan #1067
19+
20+
### Fixed
21+
- Loosen dependency to Zend
22+
- Images are not being printed when generating PDF - @hubertinio #1074 #431
23+
- Fixed some PHP 7 warnings - @ likeuntomurphy #927
24+
- Fixed Word 97 reader - @alsofronie @Benpxpx @mario-rivera #912 #920 #892
25+
- Fixed image loading over https - @troosan #988
26+
- Impossibility to set different even and odd page headers - @troosan #981
27+
- Fixed Word2007 reader where unnecessary paragraphs were being created - @donghaobo #1043 #620
28+
- Fixed Word2007 reader where margins were not being read correctly - @slowprog #885 #1008
29+
- Impossible to add element PreserveText in Section - @rvanlaak #452
30+
- Added missing options for numbering format - @troosan #1041
31+
- Fixed impossibility to set a different footer for first page - @ctrlaltca #1116
32+
633
v0.13.0 (31 July 2016)
734
-------------------
835
This release brings several improvements in `TemplateProcessor`, automatic output escaping feature for OOXML, ODF, HTML, and RTF (turned off, by default).

README.md

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
11
# ![PHPWord](https://rawgit.com/PHPOffice/PHPWord/develop/docs/images/phpword.svg "PHPWord")
22

3-
## :mag_right: PHPWord is looking for a new maintainer :crown: :pencil: ([#948](https://github.com/PHPOffice/PHPWord/issues/948))
4-
53
[![Latest Stable Version](https://poser.pugx.org/phpoffice/phpword/v/stable.png)](https://packagist.org/packages/phpoffice/phpword)
64
[![Build Status](https://travis-ci.org/PHPOffice/PHPWord.svg?branch=master)](https://travis-ci.org/PHPOffice/PHPWord)
75
[![Code Quality](https://scrutinizer-ci.com/g/PHPOffice/PHPWord/badges/quality-score.png?s=b5997ce59ac2816b4514f3a38de9900f6d492c1d)](https://scrutinizer-ci.com/g/PHPOffice/PHPWord/)
@@ -14,6 +12,8 @@ PHPWord is a library written in pure PHP that provides a set of classes to write
1412

1513
PHPWord is an open source project licensed under the terms of [LGPL version 3](https://github.com/PHPOffice/PHPWord/blob/develop/COPYING.LESSER). PHPWord is aimed to be a high quality software product by incorporating [continuous integration](https://travis-ci.org/PHPOffice/PHPWord) and [unit testing](http://phpoffice.github.io/PHPWord/coverage/develop/). You can learn more about PHPWord by reading the [Developers' Documentation](http://phpword.readthedocs.org/) and the [API Documentation](http://phpoffice.github.io/PHPWord/docs/develop/).
1614

15+
If you have any questions, please ask on [StackOverFlow](https://stackoverflow.com/questions/tagged/phpword)
16+
1717
Read more about PHPWord:
1818

1919
- [Features](#features)
@@ -57,8 +57,7 @@ PHPWord requires the following:
5757
- PHP 5.3.3+
5858
- [XML Parser extension](http://www.php.net/manual/en/xml.installation.php)
5959
- [Zend\Escaper component](http://framework.zend.com/manual/current/en/modules/zend.escaper.introduction.html)
60-
- Zend\Stdlib component
61-
- [Zend\Validator component](http://framework.zend.com/manual/current/en/modules/zend.validator.html)
60+
- [Zend\Stdlib component](http://framework.zend.com/manual/current/en/modules/zend.stdlib.hydrator.html)
6261
- [Zip extension](http://php.net/manual/en/book.zip.php) (optional, used to write OOXML and ODF)
6362
- [GD extension](http://php.net/manual/en/book.image.php) (optional, used to add images)
6463
- [XMLWriter extension](http://php.net/manual/en/book.xmlwriter.php) (optional, used to write OOXML and ODF)

composer.json

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
},
2121
{
2222
"name": "Franck Lefevre",
23-
"homepage": "http://blog.rootslabs.net"
23+
"homepage": "https://rootslabs.net/blog/"
2424
},
2525
{
2626
"name": "Ivan Lanin",
@@ -34,10 +34,9 @@
3434
"require": {
3535
"php": ">=5.3.3",
3636
"ext-xml": "*",
37-
"zendframework/zend-escaper": "2.4.*",
38-
"zendframework/zend-stdlib": "2.4.*",
39-
"zendframework/zend-validator": "2.4.*",
40-
"phpoffice/common": "0.2.*"
37+
"zendframework/zend-escaper": "^2.2",
38+
"zendframework/zend-stdlib": "^2.2",
39+
"phpoffice/common": "^0.2"
4140
},
4241
"require-dev": {
4342
"phpunit/phpunit": "3.7.*",

docs/containers.rst

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -98,6 +98,12 @@ that are available for the footer. See "Footer" section for detail.
9898
Additionally, only inside of the header reference you can add watermarks
9999
or background pictures. See "Watermarks" section.
100100

101+
You can pass an optional parameter to specify where the header/footer should be applied, it can be
102+
103+
- ``Footer::AUTO`` default, all pages except if overridden by first or even
104+
- ``Footer::FIRST`` each first page of the section
105+
- ``Footer::EVEN`` each even page of the section. Will only be applied if the evenAndOddHeaders is set to true in phpWord->settings
106+
101107
Footers
102108
-------
103109

docs/elements.rst

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -158,8 +158,8 @@ Parameters:
158158
- ``$text``. Text that appears in the document.
159159
- ``$depth``. Depth of list item.
160160
- ``$fontStyle``. See :ref:`font-style`.
161-
- ``$listStyle``. List style of the current element TYPE\_NUMBER,
162-
TYPE\_ALPHANUM, TYPE\_BULLET\_FILLED, etc. See list of constants in PHPWord\_Style\_ListItem.
161+
- ``$listStyle``. List style of the current element TYPE\_NUMBER,
162+
TYPE\_ALPHANUM, TYPE\_BULLET\_FILLED, etc. See list of constants in PHPWord\\Style\\ListItem.
163163
- ``$paragraphStyle``. See :ref:`paragraph-style`.
164164

165165
Advanced usage:
@@ -297,7 +297,7 @@ Your TOC can only be generated if you have add at least one title (See "Titles")
297297

298298
Options for ``$tocStyle``:
299299

300-
- ``tabLeader``. Fill type between the title text and the page number. Use the defined constants in PHPWord\_Style\_TOC.
300+
- ``tabLeader``. Fill type between the title text and the page number. Use the defined constants in PHPWord\\Style\\TOC.
301301
- ``tabPos``. The position of the tab where the page number appears in twips.
302302
- ``indent``. The indent factor of the titles in twips.
303303

docs/general.rst

Lines changed: 78 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -80,8 +80,8 @@ folder <https://github.com/PHPOffice/PHPWord/tree/master/samples/>`__.
8080
/* Note: we skip RTF, because it's not XML-based and requires a different example. */
8181
/* Note: we skip PDF, because "HTML-to-PDF" approach is used to create PDF documents. */
8282
83-
Settings
84-
--------
83+
PHPWord Settings
84+
----------------
8585

8686
The ``PhpOffice\PhpWord\Settings`` class provides some options that will
8787
affect the behavior of PHPWord. Below are the options.
@@ -130,6 +130,35 @@ To turn it on set ``outputEscapingEnabled`` option to ``true`` in your PHPWord c
130130
131131
\PhpOffice\PhpWord\Settings::setOutputEscapingEnabled(true);
132132
133+
Default font
134+
~~~~~~~~~~~~
135+
136+
By default, every text appears in Arial 10 point. You can alter the
137+
default font by using the following two functions:
138+
139+
.. code-block:: php
140+
141+
$phpWord->setDefaultFontName('Times New Roman');
142+
$phpWord->setDefaultFontSize(12);
143+
144+
Document settings
145+
-----------------
146+
Settings for the generated document can be set using ``$phpWord->getSettings()``
147+
148+
Magnification Setting
149+
~~~~~~~~~~~~~~~~~~~~~
150+
The default zoom value is 100 percent. This can be changed either to another percentage
151+
152+
.. code-block:: php
153+
154+
$phpWord->getSettings()->setZoom(75);
155+
156+
Or to predefined values ``fullPage``, ``bestFit``, ``textFit``
157+
158+
.. code-block:: php
159+
160+
$phpWord->getSettings()->setZoom(Zoom::BEST_FIT);
161+
133162
Spelling and grammatical checks
134163
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
135164

@@ -138,19 +167,58 @@ For big documents this can slow down the opening of the document. You can hide t
138167

139168
.. code-block:: php
140169
141-
\PhpOffice\PhpWord\Settings::setSpellingErrorsHidden(true);
142-
\PhpOffice\PhpWord\Settings::setGrammaticalErrorsHidden(true);
170+
$phpWord->getSettings()->setHideGrammaticalErrors(true);
171+
$phpWord->getSettings()->setHideSpellingErrors(true);
143172
144-
Default font
145-
~~~~~~~~~~~~
173+
You can also specify the status of the spell and grammar checks, marking spelling or grammar as dirty will force a re-check when opening the document.
146174

147-
By default, every text appears in Arial 10 point. You can alter the
148-
default font by using the following two functions:
175+
.. code-block:: php
176+
177+
$proofState = new ProofState();
178+
$proofState->setGrammar(ProofState::CLEAN);
179+
$proofState->setSpelling(ProofState::DIRTY);
180+
181+
$phpWord->getSettings()->setProofState(proofState);
182+
183+
Track Revisions
184+
~~~~~~~~~~~~~~~
185+
Track changes can be activated using ``setTrackRevisions``, you can furture specify
186+
187+
- Not to use move syntax, instead moved items will be seen as deleted in one place and added in another
188+
- Not track formatting revisions
149189

150190
.. code-block:: php
151191
152-
$phpWord->setDefaultFontName('Times New Roman');
153-
$phpWord->setDefaultFontSize(12);
192+
$phpWord->getSettings()->setTrackRevisions(true);
193+
$phpWord->getSettings()->setDoNotTrackMoves(true);
194+
$phpWord->getSettings()->setDoNotTrackFormatting(true);
195+
196+
Decimal Symbol
197+
~~~~~~~~~~~~~~
198+
The default symbol to represent a decimal figure is the ``.`` in english. In french you might want to change it to ``,`` for instance.
199+
200+
.. code-block:: php
201+
202+
$phpWord->getSettings()->setDecimalSymbol(',');
203+
204+
Document Language
205+
~~~~~~~~~~~~~~~~~
206+
The default language of the document can be change with the following.
207+
208+
.. code-block:: php
209+
210+
$phpWord->getSettings()->setThemeFontLang(new Language(Language::FR_BE));
211+
212+
``Languge`` has 3 parameters, one for Latin languages, one for East Asian languages and one for Complex (Bi-Directional) languages.
213+
A couple of language codes are provided in the ``PhpOffice\PhpWord\ComplexType\Language`` class but any valid code/ID can be used.
214+
215+
In case you are generating an RTF document the Language need to be set differently.
216+
217+
.. code-block:: php
218+
219+
$lang = new Language();
220+
$lang->setLangId(Language::EN_GB_ID);
221+
$phpWord->getSettings()->setThemeFontLang($lang);
154222
155223
Document information
156224
--------------------
@@ -194,16 +262,3 @@ points to twips.
194262
$sectionStyle->setMarginLeft(\PhpOffice\PhpWord\Shared\Converter::inchToTwip(.5));
195263
// 2 cm right margin
196264
$sectionStyle->setMarginRight(\PhpOffice\PhpWord\Shared\Converter::cmToTwip(2));
197-
198-
Language
199-
--------
200-
201-
You can hide spelling errors:
202-
203-
.. code-block:: php
204-
\PhpOffice\PhpWord\Settings::setSpellingErrorsHidden(true);
205-
206-
And hide grammatical errors:
207-
208-
.. code-block:: php
209-
\PhpOffice\PhpWord\Settings::setGrammaticalErrorsHidden(true);

docs/styles.rst

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,8 @@ Available Font style options:
5555
- ``subScript``. Subscript, *true* or *false*.
5656
- ``superScript``. Superscript, *true* or *false*.
5757
- ``underline``. Underline, *dash*, *dotted*, etc.
58+
- ``lang``. Language, either a language code like *en-US*, *fr-BE*, etc. or an object (or as an array) if you need to set eastAsian or bidirectional languages
59+
See ``\PhpOffice\PhpWord\Style\Language`` class for some language codes.
5860

5961
.. _paragraph-style:
6062

@@ -64,7 +66,7 @@ Paragraph
6466
Available Paragraph style options:
6567

6668
- ``alignment``. Supports all alignment modes since 1st Edition of ECMA-376 standard up till ISO/IEC 29500:2012.
67-
See ``\PhpOffice\PhpWord\SimpleType\Jc`` class for the details.
69+
See ``\PhpOffice\PhpWord\SimpleType\Jc`` class for the details.
6870
- ``basedOn``. Parent style.
6971
- ``hanging``. Hanging by how much.
7072
- ``indent``. Indent by how much.
@@ -87,7 +89,7 @@ Table
8789
Available Table style options:
8890

8991
- ``alignment``. Supports all alignment modes since 1st Edition of ECMA-376 standard up till ISO/IEC 29500:2012.
90-
See ``\PhpOffice\PhpWord\SimpleType\JcTable`` and ``\PhpOffice\PhpWord\SimpleType\Jc`` classes for the details.
92+
See ``\PhpOffice\PhpWord\SimpleType\JcTable`` and ``\PhpOffice\PhpWord\SimpleType\Jc`` classes for the details.
9193
- ``bgColor``. Background color, e.g. '9966CC'.
9294
- ``border(Top|Right|Bottom|Left)Color``. Border color, e.g. '9966CC'.
9395
- ``border(Top|Right|Bottom|Left)Size``. Border size in twips.
@@ -106,7 +108,8 @@ Available Cell style options:
106108
- ``border(Top|Right|Bottom|Left)Color``. Border color, e.g. '9966CC'.
107109
- ``border(Top|Right|Bottom|Left)Size``. Border size in twips.
108110
- ``gridSpan``. Number of columns spanned.
109-
- ``textDirection(btLr|tbRl)``. Direction of text. You can use constants ``\PhpOffice\PhpWord\Style\Cell::TEXT_DIR_BTLR`` and ``\PhpOffice\PhpWord\Style\Cell::TEXT_DIR_TBRL``
111+
- ``textDirection(btLr|tbRl)``. Direction of text.
112+
You can use constants ``\PhpOffice\PhpWord\Style\Cell::TEXT_DIR_BTLR`` and ``\PhpOffice\PhpWord\Style\Cell::TEXT_DIR_TBRL``
110113
- ``valign``. Vertical alignment, *top*, *center*, *both*, *bottom*.
111114
- ``vMerge``. *restart* or *continue*.
112115
- ``width``. Cell width in twips.
@@ -133,7 +136,7 @@ Numbering level
133136
Available NumberingLevel style options:
134137

135138
- ``alignment``. Supports all alignment modes since 1st Edition of ECMA-376 standard up till ISO/IEC 29500:2012.
136-
See ``\PhpOffice\PhpWord\SimpleType\Jc`` class for the details.
139+
See ``\PhpOffice\PhpWord\SimpleType\Jc`` class for the details.
137140
- ``font``. Font name.
138141
- ``format``. Numbering format bullet\|decimal\|upperRoman\|lowerRoman\|upperLetter\|lowerLetter.
139142
- ``hanging``. See paragraph style.

samples/Sample_01_SimpleText.php

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,16 @@
11
<?php
2+
use PhpOffice\PhpWord\Style\Paragraph;
3+
use PhpOffice\PhpWord\Style\Font;
4+
25
include_once 'Sample_Header.php';
36

47
// New Word Document
58
echo date('H:i:s') , ' Create new PhpWord object' , EOL;
9+
10+
$languageEnGb = new \PhpOffice\PhpWord\Style\Language(\PhpOffice\PhpWord\Style\Language::EN_GB);
11+
612
$phpWord = new \PhpOffice\PhpWord\PhpWord();
13+
$phpWord->getSettings()->setThemeFontLang($languageEnGb);
714

815
$fontStyleName = 'rStyle';
916
$phpWord->addFontStyle($fontStyleName, array('bold' => true, 'italic' => true, 'size' => 16, 'allCaps' => true, 'doubleStrikethrough' => true));
@@ -20,6 +27,10 @@
2027
$section->addTitle('Welcome to PhpWord', 1);
2128
$section->addText('Hello World!');
2229

30+
// $pStyle = new Font();
31+
// $pStyle->setLang()
32+
$section->addText('Ce texte-ci est en français.', array('lang' => \PhpOffice\PhpWord\Style\Language::FR_BE));
33+
2334
// Two text break
2435
$section->addTextBreak(2);
2536

samples/Sample_10_EastAsianFontStyle.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
$section = $phpWord->addSection();
88
$header = array('size' => 16, 'bold' => true);
99
//1.Use EastAisa FontStyle
10-
$section->addText('中文楷体样式测试', array('name' => '楷体', 'size' => 16, 'color' => '1B2232'));
10+
$section->addText('中文楷体样式测试', array('name' => '楷体', 'size' => 16, 'color' => '1B2232', 'lang' => array('latin' => 'en-US', 'eastAsia' => 'zh-CN')));
1111

1212
// Save file
1313
echo write($phpWord, basename(__FILE__, '.php'), $writers);

0 commit comments

Comments
 (0)