Skip to content

Commit 2cd4eeb

Browse files
committed
Merge branch 'chc88-master' into develop
2 parents 41983e0 + 9b58606 commit 2cd4eeb

File tree

3 files changed

+126
-44
lines changed

3 files changed

+126
-44
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ This release added form fields (textinput, checkbox, and dropdown), drawing shap
2525
- Word2007 Writer : Support for RTL - @Progi1984 GH-331
2626
- MsDOC Reader: Basic MsDOC Reader - @Progi1984 GH-23 GH-287
2727
- "absolute" horizontal and vertical positioning of Frame - @basjan GH-302
28+
- Add new-page function for PDF generation. For multiple PDF-backends - @chc88 GH-426
2829

2930
### Bugfixes
3031

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)