From f8389c5d3545032200cbe157efd97dfb2e0b77af Mon Sep 17 00:00:00 2001 From: chrissharkman Date: Tue, 24 Jun 2014 09:27:18 +0200 Subject: [PATCH 01/10] Update elements.rst it's not perfect, but better than nothing. --- docs/elements.rst | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/docs/elements.rst b/docs/elements.rst index 7d076742..eb70f9ad 100644 --- a/docs/elements.rst +++ b/docs/elements.rst @@ -493,4 +493,20 @@ To be completed Line ------ -To be completed +Line elements can be added to sections by using ``addLine``. + +.. code-block:: php + + $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 +- ``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 From 0a8635ece80dbb6f2dcf94f808f0fa8769be4546 Mon Sep 17 00:00:00 2001 From: Spike Ilacqua Date: Mon, 22 Sep 2014 16:58:00 -0600 Subject: [PATCH 02/10] Add missing setters for pageSizeW and pageSizeH --- src/PhpWord/Style/Section.php | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/src/PhpWord/Style/Section.php b/src/PhpWord/Style/Section.php index fd59f1b4..ae02544b 100644 --- a/src/PhpWord/Style/Section.php +++ b/src/PhpWord/Style/Section.php @@ -239,6 +239,13 @@ class Section extends Border return $this->pageSizeW; } + public function setPageSizeW($value = null) + { + $this->pageSizeW = $this->setNumericVal($value, self::DEFAULT_WIDTH); + + return $this; + } + /** * Get Page Size Height * @@ -249,6 +256,13 @@ class Section extends Border return $this->pageSizeH; } + public function setPageSizeH($value = null) + { + $this->pageSizeH = $this->setNumericVal($value, self::DEFAULT_HEIGHT); + + return $this; + } + /** * Get Margin Top * From 786991234810eaa82fbb421188d97741ed94c33f Mon Sep 17 00:00:00 2001 From: Jaggy Gauran Date: Mon, 29 Sep 2014 03:07:54 +0800 Subject: [PATCH 03/10] Fix page break sample code block --- docs/elements.rst | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/docs/elements.rst b/docs/elements.rst index eb70f9ad..c2e1bfec 100644 --- a/docs/elements.rst +++ b/docs/elements.rst @@ -207,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 ----- From 57c323536580e7fbd9471d4744a79eeb9959bd3d Mon Sep 17 00:00:00 2001 From: Progi1984 Date: Mon, 29 Sep 2014 17:01:43 +0200 Subject: [PATCH 04/10] Revert "Fix page break sample code block" --- docs/elements.rst | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/docs/elements.rst b/docs/elements.rst index c2e1bfec..eb70f9ad 100644 --- a/docs/elements.rst +++ b/docs/elements.rst @@ -207,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 ----- From e5a3d01835cc28923ba92a47722ed037f56aa0c7 Mon Sep 17 00:00:00 2001 From: Spike Ilacqua Date: Thu, 2 Oct 2014 08:33:53 -0600 Subject: [PATCH 05/10] Width/Height set/get tests --- tests/PhpWord/Tests/Style/SectionTest.php | 28 +++++++++++++++++++++++ 1 file changed, 28 insertions(+) diff --git a/tests/PhpWord/Tests/Style/SectionTest.php b/tests/PhpWord/Tests/Style/SectionTest.php index dd7273cb..954494b2 100644 --- a/tests/PhpWord/Tests/Style/SectionTest.php +++ b/tests/PhpWord/Tests/Style/SectionTest.php @@ -96,6 +96,34 @@ class SettingsTest extends \PHPUnit_Framework_TestCase $this->assertEquals($iVal, $oSettings->getMarginRight()); } + /** + * Set/get page width + */ + public function testPageWidth() + { + // Section Settings + $oSettings = new Section(); + + $this->assertEquals(11906, $oSettings->getPageSizeW()); + $iVal = rand(1, 1000); + $oSettings->setSettingValue('pageSizeW', $iVal); + $this->assertEquals($iVal, $oSettings->getPageSizeW()); + } + + /** + * Set/get page height + */ + public function testPageHeight() + { + // Section Settings + $oSettings = new Section(); + + $this->assertEquals(16838, $oSettings->getPageSizeH()); + $iVal = rand(1, 1000); + $oSettings->setSettingValue('pageSizeH', $iVal); + $this->assertEquals($iVal, $oSettings->getPageSizeH()); + } + /** * Set/get landscape orientation */ From ecaeb96376d4e0ac5a924a6d3547c935d5fd87e1 Mon Sep 17 00:00:00 2001 From: Spike Ilacqua Date: Thu, 2 Oct 2014 09:04:45 -0600 Subject: [PATCH 06/10] Update pageSizeW and pageSizeH docs --- docs/containers.rst | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/docs/containers.rst b/docs/containers.rst index 30566df6..3cb48792 100644 --- a/docs/containers.rst +++ b/docs/containers.rst @@ -34,6 +34,8 @@ Section settings Below are the available settings for section: +- ``pageSizeW`` Page width in twips (the default is 11906/A4 size) +- ``pageSizeH`` Page height in twips (the default is 16838/A4 size) - ``orientation`` Page orientation, i.e. 'portrait' (default) or 'landscape' - ``marginTop`` Page margin top in twips @@ -56,12 +58,6 @@ Below are the available settings for section: - ``breakType`` Section break type (nextPage, nextColumn, continuous, evenPage, oddPage) -The following two settings are automatically set by the use of the -``orientation`` setting. You can alter them but that's not recommended. - -- ``pageSizeW`` Page width in twips -- ``pageSizeH`` Page height in twips - Page number ~~~~~~~~~~~ From 8ebe3b373848d2050faec9c7bc124af4b238ec18 Mon Sep 17 00:00:00 2001 From: Progi1984 Date: Thu, 2 Oct 2014 17:21:17 +0200 Subject: [PATCH 07/10] Revert "Add missing setters for pageSizeW and pageSizeH" --- docs/containers.rst | 8 +++++-- src/PhpWord/Style/Section.php | 14 ------------ tests/PhpWord/Tests/Style/SectionTest.php | 28 ----------------------- 3 files changed, 6 insertions(+), 44 deletions(-) diff --git a/docs/containers.rst b/docs/containers.rst index 3cb48792..30566df6 100644 --- a/docs/containers.rst +++ b/docs/containers.rst @@ -34,8 +34,6 @@ Section settings Below are the available settings for section: -- ``pageSizeW`` Page width in twips (the default is 11906/A4 size) -- ``pageSizeH`` Page height in twips (the default is 16838/A4 size) - ``orientation`` Page orientation, i.e. 'portrait' (default) or 'landscape' - ``marginTop`` Page margin top in twips @@ -58,6 +56,12 @@ Below are the available settings for section: - ``breakType`` Section break type (nextPage, nextColumn, continuous, evenPage, oddPage) +The following two settings are automatically set by the use of the +``orientation`` setting. You can alter them but that's not recommended. + +- ``pageSizeW`` Page width in twips +- ``pageSizeH`` Page height in twips + Page number ~~~~~~~~~~~ diff --git a/src/PhpWord/Style/Section.php b/src/PhpWord/Style/Section.php index ae02544b..fd59f1b4 100644 --- a/src/PhpWord/Style/Section.php +++ b/src/PhpWord/Style/Section.php @@ -239,13 +239,6 @@ class Section extends Border return $this->pageSizeW; } - public function setPageSizeW($value = null) - { - $this->pageSizeW = $this->setNumericVal($value, self::DEFAULT_WIDTH); - - return $this; - } - /** * Get Page Size Height * @@ -256,13 +249,6 @@ class Section extends Border return $this->pageSizeH; } - public function setPageSizeH($value = null) - { - $this->pageSizeH = $this->setNumericVal($value, self::DEFAULT_HEIGHT); - - return $this; - } - /** * Get Margin Top * diff --git a/tests/PhpWord/Tests/Style/SectionTest.php b/tests/PhpWord/Tests/Style/SectionTest.php index 954494b2..dd7273cb 100644 --- a/tests/PhpWord/Tests/Style/SectionTest.php +++ b/tests/PhpWord/Tests/Style/SectionTest.php @@ -96,34 +96,6 @@ class SettingsTest extends \PHPUnit_Framework_TestCase $this->assertEquals($iVal, $oSettings->getMarginRight()); } - /** - * Set/get page width - */ - public function testPageWidth() - { - // Section Settings - $oSettings = new Section(); - - $this->assertEquals(11906, $oSettings->getPageSizeW()); - $iVal = rand(1, 1000); - $oSettings->setSettingValue('pageSizeW', $iVal); - $this->assertEquals($iVal, $oSettings->getPageSizeW()); - } - - /** - * Set/get page height - */ - public function testPageHeight() - { - // Section Settings - $oSettings = new Section(); - - $this->assertEquals(16838, $oSettings->getPageSizeH()); - $iVal = rand(1, 1000); - $oSettings->setSettingValue('pageSizeH', $iVal); - $this->assertEquals($iVal, $oSettings->getPageSizeH()); - } - /** * Set/get landscape orientation */ From 37ca0097690b84578c32cb6a331aa53be642a43a Mon Sep 17 00:00:00 2001 From: chc88 Date: Fri, 14 Nov 2014 17:26:23 +0100 Subject: [PATCH 08/10] Extend HTML output for pagebreaks for PDF generation Make HTML output of pagebreak compatible for the different PDF writers by combining: http://mpdf1.com/manual/index.php?tid=110 (tested and working) and https://code.google.com/p/dompdf/wiki/FAQ (tested and working) and http://chandeshparekh.com/css-to-create-new-page-in-php-tcpdf-pdf/ --- src/PhpWord/Writer/HTML/Element/PageBreak.php | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/src/PhpWord/Writer/HTML/Element/PageBreak.php b/src/PhpWord/Writer/HTML/Element/PageBreak.php index a3fb1f3b..403ca129 100644 --- a/src/PhpWord/Writer/HTML/Element/PageBreak.php +++ b/src/PhpWord/Writer/HTML/Element/PageBreak.php @@ -24,4 +24,13 @@ namespace PhpOffice\PhpWord\Writer\HTML\Element; */ class PageBreak extends TextBreak { + /** + * Write page break + * + * @return string + */ + public function write() + { + return ''; + } } From 9e36c29a645458ef1c04e0cb2020aee1fc5a17e9 Mon Sep 17 00:00:00 2001 From: chc88 Date: Wed, 10 Dec 2014 15:47:12 +0100 Subject: [PATCH 09/10] Update pdf-generation Add new-page function for PDF generation. For multiple PDF-backends - @chc88 GH-426 --- CHANGELOG.md | 3 +++ 1 file changed, 3 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 59cbba6c..1419f60c 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,9 @@ 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. +## 0.11.2 - 10 December 2014 +- Add new-page function for PDF generation. For multiple PDF-backends - @chc88 GH-426 + ## 0.11.1 - 2 June 2014 This is an immediate bugfix release for HTML reader. From d330e57018ba69230b7704c6f2c0f638f5d6a8e0 Mon Sep 17 00:00:00 2001 From: chc88 Date: Wed, 10 Dec 2014 15:49:40 +0100 Subject: [PATCH 10/10] Update PageBreak.php Update pdf-generation; check if we're generating a pdf --- src/PhpWord/Writer/HTML/Element/PageBreak.php | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/PhpWord/Writer/HTML/Element/PageBreak.php b/src/PhpWord/Writer/HTML/Element/PageBreak.php index 403ca129..8cd5906e 100644 --- a/src/PhpWord/Writer/HTML/Element/PageBreak.php +++ b/src/PhpWord/Writer/HTML/Element/PageBreak.php @@ -31,6 +31,11 @@ class PageBreak extends TextBreak */ public function write() { - return ''; + /** @var \PhpOffice\PhpWord\Writer\HTML $parentWriter Type hint */ + $parentWriter = $this->parentWriter; + if ($parentWriter->isPdf()) { + return ''; + } + return ""; } }