Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
43 commits
Select commit Hold shift + click to select a range
f8389c5
Update elements.rst
chrissharkman Jun 24, 2014
d8fbac6
Merge pull request #289 from chrissharkman/patch-1
Progi1984 Jun 24, 2014
0a8635e
Add missing setters for pageSizeW and pageSizeH
spikex Sep 22, 2014
7869912
Fix page break sample code block
jaggy Sep 28, 2014
d39ba21
Merge pull request #385 from jaggyspaghetti/patch-1
Progi1984 Sep 29, 2014
57c3235
Revert "Fix page break sample code block"
Progi1984 Sep 29, 2014
439f013
Merge pull request #386 from PHPOffice/revert-385-patch-1
Progi1984 Sep 29, 2014
e5a3d01
Width/Height set/get tests
spikex Oct 2, 2014
ecaeb96
Update pageSizeW and pageSizeH docs
spikex Oct 2, 2014
1a783d1
Merge pull request #379 from spikex/master
Progi1984 Oct 2, 2014
8ebe3b3
Revert "Add missing setters for pageSizeW and pageSizeH"
Progi1984 Oct 2, 2014
5e68fd9
Merge pull request #389 from PHPOffice/revert-379-master
Progi1984 Oct 2, 2014
37ca009
Extend HTML output for pagebreaks for PDF generation
chc88 Nov 14, 2014
7b11002
[CHANGED] "README.md".
Nov 23, 2014
34e6f50
[CHANGED] "README.md". Added notice required about input escaping.
Nov 23, 2014
beeaf89
[CHANGED] "README.md". Added notice required about input escaping.
Nov 23, 2014
4a0da83
[CHANGED] "README.md". Added notice required about input escaping.
Nov 23, 2014
41f6aec
[CHANGED] "README.md". Added notice required about input escaping.
Nov 23, 2014
9a6c224
[CHANGED] "README.md". Added notice required about input escaping.
Nov 23, 2014
b8ee099
[CHANGED] "README.md". Added notice required about input escaping.
Nov 23, 2014
07cec9c
[CHANGED] "intro.rst".
Nov 23, 2014
d1993a4
[CHANGED] "README.md". Added notice required about input escaping.
Nov 23, 2014
b4d31ca
[CHANGED] "README.md". Added notice required about input escaping.
Nov 23, 2014
8dcbc92
[CHANGED] "README.md". Added notice required about input escaping.
Nov 23, 2014
ca664a5
Update Table.php
Dec 3, 2014
a15573b
Merge pull request #438 from franzholz/patch-2
Progi1984 Dec 3, 2014
455a4c4
#438
Dec 4, 2014
f8ee230
[FIXED] Typo.
Dec 4, 2014
2cb124f
https://github.com/PHPOffice/PHPWord/issues/51
Dec 9, 2014
fa7f2cd
https://github.com/PHPOffice/PHPWord/issues/51
Dec 9, 2014
41983e0
Merge pull request #356 from GMTA/develop
Dec 9, 2014
9e36c29
Update pdf-generation
chc88 Dec 10, 2014
d330e57
Update PageBreak.php
chc88 Dec 10, 2014
2176232
Merge PR #441
Progi1984 Dec 10, 2014
9b58606
Merge PR #441
Progi1984 Dec 10, 2014
2cd4eeb
Merge branch 'chc88-master' into develop
Progi1984 Dec 10, 2014
6490b7e
UPDATED : composer.lock
Progi1984 Dec 11, 2014
56cd784
UPDATED : travis.yml for support of PHP 5.3
Progi1984 Dec 11, 2014
fbfde2e
#441 (added @since annotation).
Dec 17, 2014
42c0b70
Replaced "phpversion()" function call with "PHP_VERSION" constant usage.
Dec 17, 2014
20c4232
[CHANGED] "Sample_Header.php" (added @return annotations where missed).
Dec 17, 2014
42b878e
[CHANGED] "Sample_Header.php" (changed date default timezone to UTC).
Dec 17, 2014
c44bd37
Minor refactoring.
Dec 17, 2014
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
language: php

php:
- 5.3.3
- 5.3
- 5.4
- 5.5
Expand All @@ -10,6 +9,7 @@ php:

matrix:
allow_failures:
- php: 5.2
- php: hhvm

env:
Expand Down
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ This release added form fields (textinput, checkbox, and dropdown), drawing shap
- Word2007 Writer : Support for RTL - @Progi1984 GH-331
- MsDOC Reader: Basic MsDOC Reader - @Progi1984 GH-23 GH-287
- "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

Expand All @@ -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
- `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
- `<th>` tag is closed with `</td>` tag: - @franzholz GH-438

### Deprecated

Expand Down
103 changes: 72 additions & 31 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -85,51 +85,92 @@ require_once 'path/to/PhpWord/src/PhpWord/Autoloader.php';
The following is a basic usage example of the PHPWord library.

```php
<?php
require_once 'src/PhpWord/Autoloader.php';
\PhpOffice\PhpWord\Autoloader::register();

// Creating the new document...
$phpWord = new \PhpOffice\PhpWord\PhpWord();

// Every element you want to append to the word document is placed in a section.
// To create a basic section:
/* Note: any element you append to a document must reside inside of a Section. */

// Adding an empty Section to the document...
$section = $phpWord->addSection();
// Adding Text element to the Section having font styled by default...
$section->addText(
htmlspecialchars(
'"Learn from yesterday, live for today, hope for tomorrow. '
. 'The important thing is not to stop questioning." '
. '(Albert Einstein)'
)
);

/*
* Note: it's possible to customize font style of the Text element you add in three ways:
* - inline;
* - using named font style (new font style object will be implicitly created);
* - using explicitly created font style object.
*/

// Adding Text element with font customized inline...
$section->addText(
htmlspecialchars(
'"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
);

// After creating a section, you can append elements:
$section->addText('Hello world!');

// You can directly style your text by giving the addText function an array:
$section->addText('Hello world! I am formatted.',
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',
array('name'=>'Verdana', 'size'=>14, 'color'=>'1B2232'));
$section->addText('Hello world! I am formatted by a user defined style',
'myOwnStyle');

// You can also put the appended element to local object like this:
$fontStyle = array(
'name' => 'Verdana',
'size' => 22,
'bold' => true,
// 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);

// Finally, save the document:
$phpWord->save('helloWorld.docx');
$phpWord->save('helloWorld.odt', 'ODText');
$phpWord->save('helloWorld.rtf', 'RTF');
// Saving the document as OOXML file...
$objWriter = \PhpOffice\PhpWord\IOFactory::createWriter($phpWord, 'Word2007');
$objWriter->save('helloWorld.docx');

// 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.

## 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)
- [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
- Follow [@PHPWord](https://twitter.com/PHPWord) and [@PHPOffice](https://twitter.com/PHPOffice) on Twitter
- 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.
- 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.
Loading