Skip to content

Commit e35838f

Browse files
committed
Merge pull request #218 from PHPOffice/develop
PR Version 0.10
2 parents b937786 + 475d948 commit e35838f

File tree

371 files changed

+28321
-14193
lines changed

Some content is hidden

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

371 files changed

+28321
-14193
lines changed

.gitignore

+6-7
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,12 @@
44
.Trashes
55
Thumbs.db
66
Desktop.ini
7-
.idea
8-
_build
9-
phpunit.xml
107
composer.lock
118
composer.phar
12-
vendor
13-
/report
14-
/.settings
9+
phpunit.xml
1510
/.buildpath
16-
/.project
11+
/.idea
12+
/.project
13+
/.settings
14+
/build
15+
/vendor

.travis.yml

+3-2
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
@@ -37,7 +38,7 @@ before_script:
3738

3839
script:
3940
## PHP_CodeSniffer
40-
- phpcs --standard=PSR2 -n src/
41+
- phpcs --standard=PSR2 -n src/ --ignore=src/PhpWord/Shared/PCLZip
4142
- phpcs --standard=PSR2 -n tests/
4243
## PHP Copy/Paste Detector
4344
#- php phpcpd.phar --verbose src/

CHANGELOG.md

100755100644
+86
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,92 @@
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.10.0 - Not yet released
6+
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. Basic ODText reader is introduced.
8+
9+
### Features
10+
11+
- Image: Get image dimensions without EXIF extension - @andrew-kzoo GH-184
12+
- Table: Add `tblGrid` element for Libre/Open Office table sizing - @gianis6 GH-183
13+
- Footnote: Ability to insert textbreak in footnote `$footnote->addTextBreak()` - @ivanlanin
14+
- Footnote: Ability to style footnote reference mark by using `FootnoteReference` style - @ivanlanin
15+
- Font: Add `bgColor` to font style to define background using HEX color - @jcarignan GH-168
16+
- Table: Add `exactHeight` to row style to define whether row height should be exact or atLeast - @jcarignan GH-168
17+
- Element: New `CheckBox` element for sections and table cells - @ozilion GH-156
18+
- Settings: Ability to use PCLZip as alternative to ZipArchive - @bskrtich @ivanlanin GH-106 GH-140 GH-185
19+
- Template: Ability to find & replace variables in headers & footers - @dgudgeon GH-190
20+
- Template: Ability to clone & delete block of text using `cloneBlock` and `deleteBlock` - @diego-vieira GH-191
21+
- TOC: Ability to have two or more TOC in one document and to set min and max depth for TOC - @Pyreweb GH-189
22+
- Table: Ability to add footnote in table cell - @ivanlanin GH-187
23+
- Footnote: Ability to add image in footnote - @ivanlanin GH-187
24+
- ListItem: Ability to add list item in header/footer - @ivanlanin GH-187
25+
- CheckBox: Ability to add checkbox in header/footer - @ivanlanin GH-187
26+
- Link: Ability to add link in header/footer - @ivanlanin GH-187
27+
- Object: Ability to add object in header, footer, textrun, and footnote - @ivanlanin GH-187
28+
- Media: Add `Media::resetElements()` to reset all media data - @juzi GH-19
29+
- General: Add `Style::resetStyles()`, `Footnote::resetElements()`, and `TOC::resetTitles()` - @ivanlanin GH-187
30+
- DOCX Reader: Ability to read header, footer, footnotes, link, preservetext, textbreak, pagebreak, table, list, image, and title - @ivanlanin
31+
- 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
37+
- DOCX Writer: Change `docProps/app.xml` `Application` to `PHPWord` - @ivanlanin
38+
- DOCX Writer: Create `word/settings.xml` and `word/webSettings.xml` dynamically - @ivanlanin
39+
- ODT Writer: Basic image writing - @ivanlanin
40+
- ODT Writer: Link writing - @ivanlanin
41+
- ODT Reader: Basic ODText Reader - @ivanlanin GH-71
42+
- Section: Ability to define gutter and line numbering - @ivanlanin
43+
- Font: Small caps, all caps, and double strikethrough - @ivanlanin GH-151
44+
- Settings: Ability to use measurement unit other than twips with `setMeasurementUnit` - @ivanlanin GH-199
45+
- Style: Remove `bgColor` from `Font`, `Table`, and `Cell` and put it into the new `Shading` style - @ivanlanin
46+
- Style: New `Indentation` and `Spacing` style - @ivanlanin
47+
- Paragraph: Ability to define first line and right indentation - @ivanlanin
48+
49+
### Bugfixes
50+
51+
- Footnote: Footnote content doesn't show footnote reference number - @ivanlanin GH-170
52+
- Documentation: Error in a function - @theBeerNut GH-195
53+
54+
### Deprecated
55+
56+
- `createTextRun` replaced by `addTextRun`
57+
- `createFootnote` replaced by `addFootnote`
58+
- `createHeader` replaced by `addHeader`
59+
- `createFooter` replaced by `addFooter`
60+
- `createSection` replaced by `addSection`
61+
- `Element\Footnote::getReferenceId` replaced by `Element\AbstractElement::getRelationId`
62+
- `Element\Footnote::setReferenceId` replaced by `Element\AbstractElement::setRelationId`
63+
- `Footnote::addFootnoteLinkElement` replaced by `Media::addElement`
64+
- `Footnote::getFootnoteLinkElements` replaced by `Media::getElements`
65+
- All current methods on `Media`
66+
- `Element\Link::getLinkSrc` replaced by `Element\Link::getTarget`
67+
- `Element\Link::getLinkName` replaced by `Element\Link::getText`
68+
- `Style\Cell::getDefaultBorderColor`
69+
70+
### Miscellaneous
71+
72+
- Documentation: Simplify page level docblock - @ivanlanin GH-179
73+
- Writer: Refactor writer classes and create a new `Write\AbstractWriter` abstract class - @ivanlanin GH-160
74+
- General: Refactor folders: `Element` and `Exception` - @ivanlanin GH-187
75+
- General: Remove legacy `HashTable` and `Shared\ZipStreamWrapper` and all related properties/methods - @ivanlanin GH-187
76+
- Element: New `AbstractElement` abstract class - @ivanlanin GH-187
77+
- Media: Refactor media class to use one method for all docPart (section, header, footer, footnote) - @ivanlanin GH-187
78+
- General: Remove underscore prefix from all private properties name - @ivanlanin GH-187
79+
- General: Move Section `Settings` to `Style\Section` - @ivanlanin GH-187
80+
- General: Give `Abstract` prefix and `Interface` suffix for all abstract classes and interfaces as per [PHP-FIG recommendation](https://github.com/php-fig/fig-standards/blob/master/bylaws/002-psr-naming-conventions.md) - @ivanlanin GH-187
81+
- Style: New `Style\AbstractStyle` abstract class - @ivanlanin GH-187
82+
- Writer: New 'ODText\Base` class - @ivanlanin GH-187
83+
- General: Rename `Footnote` to `Footnotes` to reflect the nature of collection - @ivanlanin
84+
- General: Add some unit tests for Shared & Element (100%!) - @Progi1984
85+
- Test: Add some samples and tests for image wrapping style - @brunocasado GH-59
86+
- Refactor: Remove Style\Tabs - @ivanlanin
87+
- Refactor: Apply composite pattern for writers - @ivanlanin
88+
- Refactor: Split `AbstractContainer` from `AbstractElement` - @ivanlanin
89+
- Refactor: Apply composite pattern for Word2007 reader - @ivanlanin
90+
591
## 0.9.1 - 27 Mar 2014
692

793
This is a bugfix release for PSR-4 compatibility.

license.md renamed to LICENSE.md

File renamed without changes.

README.md

100755100644
+112-111
Original file line numberDiff line numberDiff line change
@@ -1,111 +1,112 @@
1-
# ![PHPWord](https://rawgit.com/PHPOffice/PHPWord/develop/docs/images/phpword.svg "PHPWord")
2-
3-
[![Build Status](https://travis-ci.org/PHPOffice/PHPWord.svg?branch=master)](https://travis-ci.org/PHPOffice/PHPWord)
4-
[![Latest Stable Version](https://poser.pugx.org/phpoffice/phpword/v/stable.png)](https://packagist.org/packages/phpoffice/phpword)
5-
[![Total Downloads](https://poser.pugx.org/phpoffice/phpword/downloads.png)](https://packagist.org/packages/phpoffice/phpword)
6-
[![Latest Unstable Version](https://poser.pugx.org/phpoffice/phpword/v/unstable.png)](https://packagist.org/packages/phpoffice/phpword)
7-
[![License](https://poser.pugx.org/phpoffice/phpword/license.png)](https://packagist.org/packages/phpoffice/phpword)
8-
9-
10-
PHPWord is a library written in pure PHP that provides a set of classes to write to and read from different document file formats. The current version of PHPWord supports Microsoft [Office Open XML](http://en.wikipedia.org/wiki/Office_Open_XML) (OOXML or OpenXML), OASIS [Open Document Format for Office Applications](http://en.wikipedia.org/wiki/OpenDocument) (OpenDocument or ODF), and [Rich Text Format](http://en.wikipedia.org/wiki/Rich_Text_Format) (RTF).
11-
12-
With PHPWord, you can create DOCX, ODT, or RTF documents dynamically using your PHP 5.3+ scripts. Below are some of the things that you can do with PHPWord library:
13-
14-
* Set document properties, e.g. title, subject, and creator.
15-
* Create document sections with different settings, e.g. portrait/landscape, page size, and page numbering
16-
* Create header and footer for each sections
17-
* Set default font type, font size, and paragraph style
18-
* Use UTF-8 and East Asia fonts/characters
19-
* Define custom font styles (e.g. bold, italic, color) and paragraph styles (e.g. centered, multicolumns, spacing) either as named style or inline in text
20-
* Insert paragraphs, either as a simple text or complex one (a text run) that contains other elements
21-
* Insert titles (headers) and table of contents
22-
* Insert text breaks and page breaks
23-
* Insert and format images, either local, remote, or as page watermarks
24-
* Insert binary OLE Objects such as Excel or Visio
25-
* Insert and format table with customized properties for each rows (e.g. repeat as header row) and cells (e.g. background color, rowspan, colspan)
26-
* Insert list items as bulleted, numbered, or multilevel
27-
* Insert hyperlinks
28-
* Create document from templates
29-
* Use XSL 1.0 style sheets to transform main document part of OOXML template
30-
* ... and many more features on progress
31-
32-
__Want to contribute?__ [Fork us](https://github.com/PHPOffice/PHPWord/fork) or [submit](https://github.com/PHPOffice/PHPWord/issues) your bug reports or feature requests to us.
33-
34-
## Requirements
35-
* PHP 5.3+
36-
* PHP [Zip](http://php.net/manual/en/book.zip.php) extension
37-
* PHP [XML Parser](http://www.php.net/manual/en/xml.installation.php) extension
38-
39-
### Optional PHP extensions
40-
* PHP [GD](http://php.net/manual/en/book.image.php) extension
41-
* PHP [XMLWriter](http://php.net/manual/en/book.xmlwriter.php) extension
42-
* PHP [XSL](http://php.net/manual/en/book.xsl.php) extension
43-
44-
## Installation
45-
46-
It is recommended that you install the PHPWord library [through composer](http://getcomposer.org/). To do so, add
47-
the following lines to your ``composer.json``.
48-
49-
```json
50-
{
51-
"require": {
52-
"phpoffice/phpword": "dev-master"
53-
}
54-
}
55-
```
56-
57-
Alternatively, you can download the latest release from the [releases page](https://github.com/PHPOffice/PHPWord/releases).
58-
In this case, you will have to register the autoloader.
59-
60-
```php
61-
require_once 'path/to/PhpWord/src/PhpWord/Autoloader.php';
62-
PhpOffice\PhpWord\Autoloader::register();
63-
```
64-
65-
## Basic usage
66-
67-
The following is a basic example of the PHPWord library. More examples are provided in the [samples folder](samples/).
68-
69-
```php
70-
$phpWord = new \PhpOffice\PhpWord\PhpWord();
71-
72-
// Every element you want to append to the word document is placed in a section.
73-
// To create a basic section:
74-
$section = $phpWord->createSection();
75-
76-
// After creating a section, you can append elements:
77-
$section->addText('Hello world!');
78-
79-
// You can directly style your text by giving the addText function an array:
80-
$section->addText('Hello world! I am formatted.',
81-
array('name'=>'Tahoma', 'size'=>16, 'bold'=>true));
82-
83-
// If you often need the same style again you can create a user defined style
84-
// to the word document and give the addText function the name of the style:
85-
$phpWord->addFontStyle('myOwnStyle',
86-
array('name'=>'Verdana', 'size'=>14, 'color'=>'1B2232'));
87-
$section->addText('Hello world! I am formatted by a user defined style',
88-
'myOwnStyle');
89-
90-
// You can also put the appended element to local object like this:
91-
$fontStyle = new \PhpOffice\PhpWord\Style\Font();
92-
$fontStyle->setBold(true);
93-
$fontStyle->setName('Verdana');
94-
$fontStyle->setSize(22);
95-
$myTextElement = $section->addText('Hello World!');
96-
$myTextElement->setFontStyle($fontStyle);
97-
98-
// Finally, write the document:
99-
$objWriter = \PhpOffice\PhpWord\IOFactory::createWriter($phpWord, 'Word2007');
100-
$objWriter->save('helloWorld.docx');
101-
102-
$objWriter = \PhpOffice\PhpWord\IOFactory::createWriter($phpWord, 'ODText');
103-
$objWriter->save('helloWorld.odt');
104-
105-
$objWriter = \PhpOffice\PhpWord\IOFactory::createWriter($phpWord, 'RTF');
106-
$objWriter->save('helloWorld.rtf');
107-
```
108-
109-
## Documentation
110-
111-
__Want to know more?__ Read the full documentation of PHPWord on [Read The Docs](http://phpword.readthedocs.org/).
1+
# ![PHPWord](https://rawgit.com/PHPOffice/PHPWord/develop/docs/images/phpword.svg "PHPWord")
2+
3+
[![Build Status](https://travis-ci.org/PHPOffice/PHPWord.svg?branch=master)](https://travis-ci.org/PHPOffice/PHPWord)
4+
[![Latest Stable Version](https://poser.pugx.org/phpoffice/phpword/v/stable.png)](https://packagist.org/packages/phpoffice/phpword)
5+
[![Total Downloads](https://poser.pugx.org/phpoffice/phpword/downloads.png)](https://packagist.org/packages/phpoffice/phpword)
6+
[![Latest Unstable Version](https://poser.pugx.org/phpoffice/phpword/v/unstable.png)](https://packagist.org/packages/phpoffice/phpword)
7+
[![License](https://poser.pugx.org/phpoffice/phpword/license.png)](https://packagist.org/packages/phpoffice/phpword)
8+
9+
10+
PHPWord is a library written in pure PHP that provides a set of classes to write to and read from different document file formats. The current version of PHPWord supports Microsoft [Office Open XML](http://en.wikipedia.org/wiki/Office_Open_XML) (OOXML or OpenXML), OASIS [Open Document Format for Office Applications](http://en.wikipedia.org/wiki/OpenDocument) (OpenDocument or ODF), and [Rich Text Format](http://en.wikipedia.org/wiki/Rich_Text_Format) (RTF).
11+
12+
With PHPWord, you can create DOCX, ODT, or RTF documents dynamically using your PHP 5.3+ scripts. Below are some of the things that you can do with PHPWord library:
13+
14+
* Set document properties, e.g. title, subject, and creator.
15+
* Create document sections with different settings, e.g. portrait/landscape, page size, and page numbering
16+
* Create header and footer for each sections
17+
* Set default font type, font size, and paragraph style
18+
* Use UTF-8 and East Asia fonts/characters
19+
* Define custom font styles (e.g. bold, italic, color) and paragraph styles (e.g. centered, multicolumns, spacing) either as named style or inline in text
20+
* Insert paragraphs, either as a simple text or complex one (a text run) that contains other elements
21+
* Insert titles (headers) and table of contents
22+
* Insert text breaks and page breaks
23+
* Insert and format images, either local, remote, or as page watermarks
24+
* Insert binary OLE Objects such as Excel or Visio
25+
* Insert and format table with customized properties for each rows (e.g. repeat as header row) and cells (e.g. background color, rowspan, colspan)
26+
* Insert list items as bulleted, numbered, or multilevel
27+
* Insert hyperlinks
28+
* Insert footnotes and endnotes
29+
* Create document from templates
30+
* Use XSL 1.0 style sheets to transform main document part of OOXML template
31+
* ... and many more features on progress
32+
33+
__Want to contribute?__ [Fork us](https://github.com/PHPOffice/PHPWord/fork) or [submit](https://github.com/PHPOffice/PHPWord/issues) your bug reports or feature requests to us.
34+
35+
## Requirements
36+
* PHP 5.3+
37+
* PHP [Zip](http://php.net/manual/en/book.zip.php) extension
38+
* PHP [XML Parser](http://www.php.net/manual/en/xml.installation.php) extension
39+
40+
### Optional PHP extensions
41+
* PHP [GD](http://php.net/manual/en/book.image.php) extension
42+
* PHP [XMLWriter](http://php.net/manual/en/book.xmlwriter.php) extension
43+
* PHP [XSL](http://php.net/manual/en/book.xsl.php) extension
44+
45+
## Installation
46+
47+
It is recommended that you install the PHPWord library [through composer](http://getcomposer.org/). To do so, add
48+
the following lines to your ``composer.json``.
49+
50+
```json
51+
{
52+
"require": {
53+
"phpoffice/phpword": "dev-master"
54+
}
55+
}
56+
```
57+
58+
Alternatively, you can download the latest release from the [releases page](https://github.com/PHPOffice/PHPWord/releases).
59+
In this case, you will have to register the autoloader.
60+
61+
```php
62+
require_once 'path/to/PhpWord/src/PhpWord/Autoloader.php';
63+
\PhpOffice\PhpWord\Autoloader::register();
64+
```
65+
66+
## Basic usage
67+
68+
The following is a basic example of the PHPWord library. More examples are provided in the [samples folder](samples/).
69+
70+
```php
71+
$phpWord = new \PhpOffice\PhpWord\PhpWord();
72+
73+
// Every element you want to append to the word document is placed in a section.
74+
// To create a basic section:
75+
$section = $phpWord->addSection();
76+
77+
// After creating a section, you can append elements:
78+
$section->addText('Hello world!');
79+
80+
// You can directly style your text by giving the addText function an array:
81+
$section->addText('Hello world! I am formatted.',
82+
array('name'=>'Tahoma', 'size'=>16, 'bold'=>true));
83+
84+
// If you often need the same style again you can create a user defined style
85+
// to the word document and give the addText function the name of the style:
86+
$phpWord->addFontStyle('myOwnStyle',
87+
array('name'=>'Verdana', 'size'=>14, 'color'=>'1B2232'));
88+
$section->addText('Hello world! I am formatted by a user defined style',
89+
'myOwnStyle');
90+
91+
// You can also put the appended element to local object like this:
92+
$fontStyle = new \PhpOffice\PhpWord\Style\Font();
93+
$fontStyle->setBold(true);
94+
$fontStyle->setName('Verdana');
95+
$fontStyle->setSize(22);
96+
$myTextElement = $section->addText('Hello World!');
97+
$myTextElement->setFontStyle($fontStyle);
98+
99+
// Finally, write the document:
100+
$objWriter = \PhpOffice\PhpWord\IOFactory::createWriter($phpWord, 'Word2007');
101+
$objWriter->save('helloWorld.docx');
102+
103+
$objWriter = \PhpOffice\PhpWord\IOFactory::createWriter($phpWord, 'ODText');
104+
$objWriter->save('helloWorld.odt');
105+
106+
$objWriter = \PhpOffice\PhpWord\IOFactory::createWriter($phpWord, 'RTF');
107+
$objWriter->save('helloWorld.rtf');
108+
```
109+
110+
## Documentation
111+
112+
__Want to know more?__ Read the full documentation of PHPWord on [Read The Docs](http://phpword.readthedocs.org/).

composer.json

+9-4
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
],
99
"homepage": "http://phpoffice.github.io",
1010
"type": "library",
11-
"license": "LGPL-3.0+",
11+
"license": "LGPL-2.1+",
1212
"authors": [
1313
{
1414
"name": "Mark Baker"
@@ -25,6 +25,10 @@
2525
{
2626
"name": "Ivan Lanin",
2727
"homepage": "http://ivan.lanin.org"
28+
},
29+
{
30+
"name": "Roman Syroeshko",
31+
"homepage": "http://ru.linkedin.com/pub/roman-syroeshko/34/a53/994/"
2832
}
2933
],
3034
"require": {
@@ -36,9 +40,10 @@
3640
"phpunit/phpunit": "3.7.*"
3741
},
3842
"suggest": {
39-
"ext-gd2": "*",
40-
"ext-xmlwriter": "*",
41-
"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"
4247
},
4348
"autoload": {
4449
"psr-4": {

0 commit comments

Comments
 (0)