Skip to content

Commit 2176232

Browse files
committed
Merge PR #441
2 parents 41983e0 + d330e57 commit 2176232

File tree

3 files changed

+127
-102
lines changed

3 files changed

+127
-102
lines changed

CHANGELOG.md

Lines changed: 2 additions & 58 deletions
Original file line numberDiff line numberDiff line change
@@ -2,64 +2,8 @@
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.12.0 - Not yet released
6-
7-
This release added form fields (textinput, checkbox, and dropdown), drawing shapes (arc, curve, line, polyline, rect, oval), and basic 2D chart (pie, doughnut, bar, line, area, scatter, radar) elements along with some new styles. Basic MsDoc reader is introduced.
8-
9-
### Features
10-
11-
- Element: Ability to add drawing shapes (arc, curve, line, polyline, rect, oval) using new `Shape` element - @ivanlanin GH-123
12-
- Font: New `scale`, `spacing`, and `kerning` property of font style - @ivanlanin
13-
- Paragraph: Added shading to the paragraph style for full width shading - @lrobert GH-264
14-
- RTF Writer: Support for sections, margins, and borders - @ivanlanin GH-249
15-
- Section: Ability to set paper size, e.g. A4, A3, and Legal - @ivanlanin GH-249
16-
- General: New `PhpWord::save()` method to encapsulate `IOFactory` - @ivanlanin
17-
- General: New `Shared\Converter` static class - @ivanlanin
18-
- Chart: Basic 2D chart (pie, doughnut, bar, line, area, scatter, radar) - @ivanlanin GH-278
19-
- Chart: 3D charts and ability to set width and height - @ivanlanin
20-
- FormField: Ability to add textinput, checkbox, and dropdown form elements - @ivanlanin GH-266
21-
- Setting: Ability to define document protection (readOnly, comments, trackedChanges, forms) - @ivanlanin
22-
- Setting: Ability to remove [Compatibility Mode] text in the MS Word title bar - @ivanlanin
23-
- SDT: Ability to add structured document tag elements (comboBox, dropDownList, date) - @ivanlanin
24-
- Paragraph: Support for paragraph with borders - @ivanlanin GH-294
25-
- Word2007 Writer : Support for RTL - @Progi1984 GH-331
26-
- MsDOC Reader: Basic MsDOC Reader - @Progi1984 GH-23 GH-287
27-
- "absolute" horizontal and vertical positioning of Frame - @basjan GH-302
28-
29-
### Bugfixes
30-
31-
- Fix rare PclZip/realpath/PHP version problem - @andrew-kzoo GH-261
32-
- `addHTML` encoding and ampersand fixes for PHP 5.3 - @bskrtich GH-270
33-
- Page breaks on titles and tables - @ivanlanin GH-274
34-
- Table inside vertical border does not rendered properly - @ivanlanin GH-280
35-
- `add<elementName>` of container should be case insensitive, e.g. `addToc` should be accepted, not only `addTOC` - @ivanlanin GH-294
36-
- Fix specific borders (and margins) were not written correctly in word2007 writer - @pscheit GH-327
37-
- "HTML is not a valid writer" exception while running "Sample_36_RTL.php" - @RomanSyroeshko GH-340
38-
- "addShape()" magic method in AbstractContainer is mistakenly named as "addObject()" - @GMTA GH-356
39-
- `Element\Section::setPageSizeW()` and `Element\Section::setPageSizeH()` were mentioned in the docs but not implemented.
40-
- Special Characters (ampersand) in Title break docx output - @RomanSyroeshko GH-401
41-
- `<th>` tag is closed with `</td>` tag: - @franzholz GH-438
42-
43-
### Deprecated
44-
45-
- `Element\Link::getTarget()` replaced by `Element\Link::getSource()`
46-
- `Element\Section::getSettings()` and `Element\Section::setSettings()` replaced by `Element\Section::getStyle()` and `Element\Section::setStyle()`
47-
- `Shared\Drawing` and `Shared\Font` merged into `Shared\Converter`
48-
- `DocumentProperties` replaced by `Metadata\DocInfo`
49-
- `Template` replaced by `TemplateProcessor`
50-
- `PhpWord->loadTemplate($filename)`
51-
52-
### Miscellaneous
53-
54-
- Docs: Add known issue on `README` about requirement for temporary folder to be writable and update `samples/index.php` for this requirement check - @ivanlanin GH-238
55-
- Docs: Correct elements.rst about Line - @chrissharkman GH-292
56-
- PclZip: Remove temporary file after used - @andrew-kzoo GH-265
57-
- Autoloader: Add the ability to set the autoloader options - @bskrtich GH-267
58-
- Element: Refactor elements to move set relation Id from container to element - @ivanlanin
59-
- Introduced CreateTemporaryFileException, CopyFileException - @RomanSyroeshko
60-
- Settings: added method to set user defined temporary directory - @RomanSyroeshko GH-310
61-
- Renamed `Template` into `TemplateProcessor` - @RomanSyroeshko GH-216
62-
- Reverted GH-51 - @RomanSyroeshko
5+
## 0.11.2 - 10 December 2014
6+
- Add new-page function for PDF generation. For multiple PDF-backends - @chc88 GH-426
637

648
## 0.11.1 - 2 June 2014
659

docs/elements.rst

Lines changed: 111 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -47,14 +47,6 @@ column shows the containers while the rows lists the elements.
4747
+-------+-----------------+-----------+----------+----------+---------+------------+------------+
4848
| 19 | Line | v | v | v | v | v | v |
4949
+-------+-----------------+-----------+----------+----------+---------+------------+------------+
50-
| 20 | Shape | v | v | v | v | v | v |
51-
+-------+-----------------+-----------+----------+----------+---------+------------+------------+
52-
| 21 | Chart | v | - | - | - | - | - |
53-
+-------+-----------------+-----------+----------+----------+---------+------------+------------+
54-
| 22 | Form fields | v | v | v | v | v | v |
55-
+-------+-----------------+-----------+----------+----------+---------+------------+------------+
56-
| 23 | Bookmarks | v | - | - | v | v | - |
57-
+-------+-----------------+-----------+----------+----------+---------+------------+------------+
5850

5951
Legend:
6052

@@ -79,6 +71,9 @@ as follow:
7971
$section->addText($text, [$fontStyle], [$paragraphStyle]);
8072
$textrun = $section->addTextRun([$paragraphStyle]);
8173
74+
Text styles
75+
~~~~~~~~~~~
76+
8277
You can use the ``$fontStyle`` and ``$paragraphStyle`` variable to
8378
define text formatting. There are 2 options to style the inserted text
8479
elements, i.e. inline style by using array or defined style by adding
@@ -109,6 +104,47 @@ Defined style examples:
109104
$phpWord->addParagraphStyle('pStyle', $paragraphStyle);
110105
$text = $section->addText('Hello world!', 'pStyle');
111106
107+
Font style
108+
^^^^^^^^^^
109+
110+
Available font styles:
111+
112+
- ``name`` Font name, e.g. *Arial*
113+
- ``size`` Font size, e.g. *20*, *22*,
114+
- ``hint`` Font content type, *default*, *eastAsia*, or *cs*
115+
- ``bold`` Bold, *true* or *false*
116+
- ``italic`` Italic, *true* or *false*
117+
- ``superScript`` Superscript, *true* or *false*
118+
- ``subScript`` Subscript, *true* or *false*
119+
- ``underline`` Underline, *dash*, *dotted*, etc.
120+
- ``strikethrough`` Strikethrough, *true* or *false*
121+
- ``doubleStrikethrough`` Double strikethrough, *true* or *false*
122+
- ``color`` Font color, e.g. *FF0000*
123+
- ``fgColor`` Font highlight color, e.g. *yellow*, *green*, *blue*
124+
- ``bgColor`` Font background color, e.g. *FF0000*
125+
- ``smallCaps`` Small caps, *true* or *false*
126+
- ``allCaps`` All caps, *true* or *false*
127+
128+
Paragraph style
129+
^^^^^^^^^^^^^^^
130+
131+
Available paragraph styles:
132+
133+
- ``align`` Paragraph alignment, *left*, *right* or *center*
134+
- ``spaceBefore`` Space before paragraph
135+
- ``spaceAfter`` Space after paragraph
136+
- ``indent`` Indent by how much
137+
- ``hanging`` Hanging by how much
138+
- ``basedOn`` Parent style
139+
- ``next`` Style for next paragraph
140+
- ``widowControl`` Allow first/last line to display on a separate page,
141+
*true* or *false*
142+
- ``keepNext`` Keep paragraph with next paragraph, *true* or *false*
143+
- ``keepLines`` Keep all lines on one page, *true* or *false*
144+
- ``pageBreakBefore`` Start paragraph on next page, *true* or *false*
145+
- ``lineHeight`` text line height, e.g. *1.0*, *1.5*, ect...
146+
- ``tabs`` Set of custom tab stops
147+
112148
Titles
113149
~~~~~~
114150

@@ -131,13 +167,12 @@ You can add Hyperlinks to the document by using the function addLink:
131167

132168
.. code-block:: php
133169
134-
$section->addLink($linkSrc, [$linkName], [$fontStyle], [$paragraphStyle], [$isInternal]);
170+
$section->addLink($linkSrc, [$linkName], [$fontStyle], [$paragraphStyle]);
135171
136172
- ``$linkSrc`` The URL of the link.
137173
- ``$linkName`` Placeholder of the URL that appears in the document.
138174
- ``$fontStyle`` See "Font style" section.
139175
- ``$paragraphStyle`` See "Paragraph style" section.
140-
- ``$isInternal`` Set to true, if the link points to a bookmark inside the document
141176

142177
Preserve texts
143178
~~~~~~~~~~~~~~
@@ -172,9 +207,9 @@ Page breaks
172207
There are two ways to insert a page breaks, using the ``addPageBreak``
173208
method or using the ``pageBreakBefore`` style of paragraph.
174209

175-
.. code-block:: php
210+
:: code-block:: php
176211

177-
$section->addPageBreak();
212+
\\$section->addPageBreak();
178213

179214
Lists
180215
-----
@@ -217,6 +252,23 @@ You can also create your own numbering style by changing the
217252
$section->addListItem('List Item I.b', 1, null, 'multilevel');
218253
$section->addListItem('List Item II', 0, null, 'multilevel');
219254
255+
Level styles:
256+
257+
- ``start`` Starting value
258+
- ``format`` Numbering format
259+
bullet\|decimal\|upperRoman\|lowerRoman\|upperLetter\|lowerLetter
260+
- ``restart`` Restart numbering level symbol
261+
- ``suffix`` Content between numbering symbol and paragraph text
262+
tab\|space\|nothing
263+
- ``text`` Numbering level text e.g. %1 for nonbullet or bullet
264+
character
265+
- ``align`` Numbering symbol align left\|center\|right\|both
266+
- ``left`` See paragraph style
267+
- ``hanging`` See paragraph style
268+
- ``tabPos`` See paragraph style
269+
- ``font`` Font name
270+
- ``hint`` See font style
271+
220272
Tables
221273
------
222274

@@ -242,6 +294,34 @@ Table style can be defined with ``addTableStyle``:
242294
$phpWord->addTableStyle('myTable', $tableStyle, $firstRowStyle);
243295
$table = $section->addTable('myTable');
244296
297+
Table, row, and cell styles
298+
~~~~~~~~~~~~~~~~~~~~~~~~~~~
299+
300+
Table styles:
301+
302+
- ``width`` Table width in percent
303+
- ``bgColor`` Background color, e.g. '9966CC'
304+
- ``border(Top|Right|Bottom|Left)Size`` Border size in twips
305+
- ``border(Top|Right|Bottom|Left)Color`` Border color, e.g. '9966CC'
306+
- ``cellMargin(Top|Right|Bottom|Left)`` Cell margin in twips
307+
308+
Row styles:
309+
310+
- ``tblHeader`` Repeat table row on every new page, *true* or *false*
311+
- ``cantSplit`` Table row cannot break across pages, *true* or *false*
312+
- ``exactHeight`` Row height is exact or at least
313+
314+
Cell styles:
315+
316+
- ``width`` Cell width in twips
317+
- ``valign`` Vertical alignment, *top*, *center*, *both*, *bottom*
318+
- ``textDirection`` Direction of text
319+
- ``bgColor`` Background color, e.g. '9966CC'
320+
- ``border(Top|Right|Bottom|Left)Size`` Border size in twips
321+
- ``border(Top|Right|Bottom|Left)Color`` Border color, e.g. '9966CC'
322+
- ``gridSpan`` Number of columns spanned
323+
- ``vMerge`` *restart* or *continue*
324+
245325
Cell span
246326
~~~~~~~~~
247327

@@ -288,6 +368,19 @@ Examples:
288368
$textrun = $section->addTextRun();
289369
$textrun->addImage('http://php.net/logo.jpg');
290370
371+
Image styles
372+
~~~~~~~~~~~~
373+
374+
Available image styles:
375+
376+
- ``width`` Width in pixels
377+
- ``height`` Height in pixels
378+
- ``align`` Image alignment, *left*, *right*, or *center*
379+
- ``marginTop`` Top margin in inches, can be negative
380+
- ``marginLeft`` Left margin in inches, can be negative
381+
- ``wrappingStyle`` Wrapping style, *inline*, *square*, *tight*,
382+
*behind*, or *infront*
383+
291384
Watermarks
292385
~~~~~~~~~~
293386

@@ -390,56 +483,30 @@ Checkbox elements can be added to sections or table cells by using
390483
Textboxes
391484
---------
392485

393-
To be completed.
486+
To be completed
394487

395488
Fields
396489
------
397490

398-
To be completed.
491+
To be completed
399492

400-
Lines
401-
-----
493+
Line
494+
------
402495

403496
Line elements can be added to sections by using ``addLine``.
404497

405498
.. code-block:: php
406499
407-
$linestyle = array('weight' => 1, 'width' => 100, 'height' => 0, 'color' => '#b2a68b');
500+
$linestyle = array('weight' => 1, 'width' => 100, 'height' => 0, 'color' => 635552);
408501
$section->addLine($lineStyle)
409502
410503
Available line style attributes:
411504

412505
- ``weight`` Line width in twips
413-
- ``color`` Defines the color of stroke. The hex value must be introduced with #.
506+
- ``color`` Defines the color of stroke
414507
- ``dash`` Line types: dash, rounddot, squaredot, dashdot, longdash, longdashdot, longdashdotdot
415508
- ``beginArrow`` Start type of arrow: block, open, classic, diamond, oval
416509
- ``endArrow`` End type of arrow: block, open, classic, diamond, ovel
417510
- ``width`` Line-object width in pt
418511
- ``height`` Line-object height in pt
419512
- ``flip`` Flip the line element: true, false
420-
421-
Shapes
422-
------
423-
424-
To be completed.
425-
426-
Charts
427-
------
428-
429-
To be completed.
430-
431-
Form fields
432-
-----------
433-
434-
To be completed.
435-
436-
Bookmarks
437-
~~~~~
438-
439-
You can add Bookmarks to the document by using the function addBookmark:
440-
441-
.. code-block:: php
442-
443-
$section->addBookmark($name);
444-
445-
- ``$name`` The name of the bookmark which can be referenced in the addLink-Function as target. Should obviously be unique throughout the document.

src/PhpWord/Writer/HTML/Element/PageBreak.php

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,4 +24,18 @@
2424
*/
2525
class PageBreak extends TextBreak
2626
{
27+
/**
28+
* Write page break
29+
*
30+
* @return string
31+
*/
32+
public function write()
33+
{
34+
/** @var \PhpOffice\PhpWord\Writer\HTML $parentWriter Type hint */
35+
$parentWriter = $this->parentWriter;
36+
if ($parentWriter->isPdf()) {
37+
return '<pagebreak style="page-break-before: always;" pagebreak="true"></pagebreak>';
38+
}
39+
return "";
40+
}
2741
}

0 commit comments

Comments
 (0)