diff --git a/CHANGELOG.md b/CHANGELOG.md index 9808f02a..3a33ad86 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -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 diff --git a/docs/elements.rst b/docs/elements.rst index eae23c9d..eb70f9ad 100644 --- a/docs/elements.rst +++ b/docs/elements.rst @@ -47,14 +47,6 @@ column shows the containers while the rows lists the elements. +-------+-----------------+-----------+----------+----------+---------+------------+------------+ | 19 | Line | v | v | v | v | v | v | +-------+-----------------+-----------+----------+----------+---------+------------+------------+ -| 20 | Shape | v | v | v | v | v | v | -+-------+-----------------+-----------+----------+----------+---------+------------+------------+ -| 21 | Chart | v | - | - | - | - | - | -+-------+-----------------+-----------+----------+----------+---------+------------+------------+ -| 22 | Form fields | v | v | v | v | v | v | -+-------+-----------------+-----------+----------+----------+---------+------------+------------+ -| 23 | Bookmarks | v | - | - | v | v | - | -+-------+-----------------+-----------+----------+----------+---------+------------+------------+ Legend: @@ -79,6 +71,9 @@ as follow: $section->addText($text, [$fontStyle], [$paragraphStyle]); $textrun = $section->addTextRun([$paragraphStyle]); +Text styles +~~~~~~~~~~~ + You can use the ``$fontStyle`` and ``$paragraphStyle`` variable to define text formatting. There are 2 options to style the inserted text elements, i.e. inline style by using array or defined style by adding @@ -109,6 +104,47 @@ Defined style examples: $phpWord->addParagraphStyle('pStyle', $paragraphStyle); $text = $section->addText('Hello world!', 'pStyle'); +Font style +^^^^^^^^^^ + +Available font styles: + +- ``name`` Font name, e.g. *Arial* +- ``size`` Font size, e.g. *20*, *22*, +- ``hint`` Font content type, *default*, *eastAsia*, or *cs* +- ``bold`` Bold, *true* or *false* +- ``italic`` Italic, *true* or *false* +- ``superScript`` Superscript, *true* or *false* +- ``subScript`` Subscript, *true* or *false* +- ``underline`` Underline, *dash*, *dotted*, etc. +- ``strikethrough`` Strikethrough, *true* or *false* +- ``doubleStrikethrough`` Double strikethrough, *true* or *false* +- ``color`` Font color, e.g. *FF0000* +- ``fgColor`` Font highlight color, e.g. *yellow*, *green*, *blue* +- ``bgColor`` Font background color, e.g. *FF0000* +- ``smallCaps`` Small caps, *true* or *false* +- ``allCaps`` All caps, *true* or *false* + +Paragraph style +^^^^^^^^^^^^^^^ + +Available paragraph styles: + +- ``align`` Paragraph alignment, *left*, *right* or *center* +- ``spaceBefore`` Space before paragraph +- ``spaceAfter`` Space after paragraph +- ``indent`` Indent by how much +- ``hanging`` Hanging by how much +- ``basedOn`` Parent style +- ``next`` Style for next paragraph +- ``widowControl`` Allow first/last line to display on a separate page, + *true* or *false* +- ``keepNext`` Keep paragraph with next paragraph, *true* or *false* +- ``keepLines`` Keep all lines on one page, *true* or *false* +- ``pageBreakBefore`` Start paragraph on next page, *true* or *false* +- ``lineHeight`` text line height, e.g. *1.0*, *1.5*, ect... +- ``tabs`` Set of custom tab stops + Titles ~~~~~~ @@ -131,13 +167,12 @@ You can add Hyperlinks to the document by using the function addLink: .. code-block:: php - $section->addLink($linkSrc, [$linkName], [$fontStyle], [$paragraphStyle], [$isInternal]); + $section->addLink($linkSrc, [$linkName], [$fontStyle], [$paragraphStyle]); - ``$linkSrc`` The URL of the link. - ``$linkName`` Placeholder of the URL that appears in the document. - ``$fontStyle`` See "Font style" section. - ``$paragraphStyle`` See "Paragraph style" section. -- ``$isInternal`` Set to true, if the link points to a bookmark inside the document Preserve texts ~~~~~~~~~~~~~~ @@ -172,9 +207,9 @@ Page breaks There are two ways to insert a page breaks, using the ``addPageBreak`` method or using the ``pageBreakBefore`` style of paragraph. -.. code-block:: php +:: code-block:: php - $section->addPageBreak(); + \\$section->addPageBreak(); Lists ----- @@ -217,6 +252,23 @@ You can also create your own numbering style by changing the $section->addListItem('List Item I.b', 1, null, 'multilevel'); $section->addListItem('List Item II', 0, null, 'multilevel'); +Level styles: + +- ``start`` Starting value +- ``format`` Numbering format + bullet\|decimal\|upperRoman\|lowerRoman\|upperLetter\|lowerLetter +- ``restart`` Restart numbering level symbol +- ``suffix`` Content between numbering symbol and paragraph text + tab\|space\|nothing +- ``text`` Numbering level text e.g. %1 for nonbullet or bullet + character +- ``align`` Numbering symbol align left\|center\|right\|both +- ``left`` See paragraph style +- ``hanging`` See paragraph style +- ``tabPos`` See paragraph style +- ``font`` Font name +- ``hint`` See font style + Tables ------ @@ -242,6 +294,34 @@ Table style can be defined with ``addTableStyle``: $phpWord->addTableStyle('myTable', $tableStyle, $firstRowStyle); $table = $section->addTable('myTable'); +Table, row, and cell styles +~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +Table styles: + +- ``width`` Table width in percent +- ``bgColor`` Background color, e.g. '9966CC' +- ``border(Top|Right|Bottom|Left)Size`` Border size in twips +- ``border(Top|Right|Bottom|Left)Color`` Border color, e.g. '9966CC' +- ``cellMargin(Top|Right|Bottom|Left)`` Cell margin in twips + +Row styles: + +- ``tblHeader`` Repeat table row on every new page, *true* or *false* +- ``cantSplit`` Table row cannot break across pages, *true* or *false* +- ``exactHeight`` Row height is exact or at least + +Cell styles: + +- ``width`` Cell width in twips +- ``valign`` Vertical alignment, *top*, *center*, *both*, *bottom* +- ``textDirection`` Direction of text +- ``bgColor`` Background color, e.g. '9966CC' +- ``border(Top|Right|Bottom|Left)Size`` Border size in twips +- ``border(Top|Right|Bottom|Left)Color`` Border color, e.g. '9966CC' +- ``gridSpan`` Number of columns spanned +- ``vMerge`` *restart* or *continue* + Cell span ~~~~~~~~~ @@ -288,6 +368,19 @@ Examples: $textrun = $section->addTextRun(); $textrun->addImage('http://php.net/logo.jpg'); +Image styles +~~~~~~~~~~~~ + +Available image styles: + +- ``width`` Width in pixels +- ``height`` Height in pixels +- ``align`` Image alignment, *left*, *right*, or *center* +- ``marginTop`` Top margin in inches, can be negative +- ``marginLeft`` Left margin in inches, can be negative +- ``wrappingStyle`` Wrapping style, *inline*, *square*, *tight*, + *behind*, or *infront* + Watermarks ~~~~~~~~~~ @@ -390,56 +483,30 @@ Checkbox elements can be added to sections or table cells by using Textboxes --------- -To be completed. +To be completed Fields ------ -To be completed. +To be completed -Lines ------ +Line +------ Line elements can be added to sections by using ``addLine``. .. code-block:: php - $linestyle = array('weight' => 1, 'width' => 100, 'height' => 0, 'color' => '#b2a68b'); + $linestyle = array('weight' => 1, 'width' => 100, 'height' => 0, 'color' => 635552); $section->addLine($lineStyle) Available line style attributes: - ``weight`` Line width in twips -- ``color`` Defines the color of stroke. The hex value must be introduced with #. +- ``color`` Defines the color of stroke - ``dash`` Line types: dash, rounddot, squaredot, dashdot, longdash, longdashdot, longdashdotdot - ``beginArrow`` Start type of arrow: block, open, classic, diamond, oval - ``endArrow`` End type of arrow: block, open, classic, diamond, ovel - ``width`` Line-object width in pt - ``height`` Line-object height in pt - ``flip`` Flip the line element: true, false - -Shapes ------- - -To be completed. - -Charts ------- - -To be completed. - -Form fields ------------ - -To be completed. - -Bookmarks -~~~~~ - -You can add Bookmarks to the document by using the function addBookmark: - -.. code-block:: php - - $section->addBookmark($name); - -- ``$name`` The name of the bookmark which can be referenced in the addLink-Function as target. Should obviously be unique throughout the document. \ No newline at end of file diff --git a/src/PhpWord/Writer/HTML/Element/PageBreak.php b/src/PhpWord/Writer/HTML/Element/PageBreak.php index a3fb1f3b..8cd5906e 100644 --- a/src/PhpWord/Writer/HTML/Element/PageBreak.php +++ b/src/PhpWord/Writer/HTML/Element/PageBreak.php @@ -24,4 +24,18 @@ namespace PhpOffice\PhpWord\Writer\HTML\Element; */ class PageBreak extends TextBreak { + /** + * Write page break + * + * @return string + */ + public function write() + { + /** @var \PhpOffice\PhpWord\Writer\HTML $parentWriter Type hint */ + $parentWriter = $this->parentWriter; + if ($parentWriter->isPdf()) { + return ''; + } + return ""; + } }