From f8389c5d3545032200cbe157efd97dfb2e0b77af Mon Sep 17 00:00:00 2001 From: chrissharkman Date: Tue, 24 Jun 2014 09:27:18 +0200 Subject: [PATCH 01/11] 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/11] 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/11] 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/11] 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/11] 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/11] 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/11] 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/11] 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/11] 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/11] 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 ""; } } From 9b58606696b85e438263a7e2fc4346c69ae7d40c Mon Sep 17 00:00:00 2001 From: Progi1984 Date: Wed, 10 Dec 2014 19:56:04 +0100 Subject: [PATCH 11/11] Merge PR #441 --- CHANGELOG.md | 59 +++++++++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 58 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 1419f60c..3a33ad86 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,9 +2,66 @@ 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 +## 0.12.0 - Not yet released + +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. + +### Features + +- Element: Ability to add drawing shapes (arc, curve, line, polyline, rect, oval) using new `Shape` element - @ivanlanin GH-123 +- Font: New `scale`, `spacing`, and `kerning` property of font style - @ivanlanin +- Paragraph: Added shading to the paragraph style for full width shading - @lrobert GH-264 +- RTF Writer: Support for sections, margins, and borders - @ivanlanin GH-249 +- Section: Ability to set paper size, e.g. A4, A3, and Legal - @ivanlanin GH-249 +- General: New `PhpWord::save()` method to encapsulate `IOFactory` - @ivanlanin +- General: New `Shared\Converter` static class - @ivanlanin +- Chart: Basic 2D chart (pie, doughnut, bar, line, area, scatter, radar) - @ivanlanin GH-278 +- Chart: 3D charts and ability to set width and height - @ivanlanin +- FormField: Ability to add textinput, checkbox, and dropdown form elements - @ivanlanin GH-266 +- Setting: Ability to define document protection (readOnly, comments, trackedChanges, forms) - @ivanlanin +- Setting: Ability to remove [Compatibility Mode] text in the MS Word title bar - @ivanlanin +- SDT: Ability to add structured document tag elements (comboBox, dropDownList, date) - @ivanlanin +- Paragraph: Support for paragraph with borders - @ivanlanin GH-294 +- 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 + +- Fix rare PclZip/realpath/PHP version problem - @andrew-kzoo GH-261 +- `addHTML` encoding and ampersand fixes for PHP 5.3 - @bskrtich GH-270 +- Page breaks on titles and tables - @ivanlanin GH-274 +- Table inside vertical border does not rendered properly - @ivanlanin GH-280 +- `add` of container should be case insensitive, e.g. `addToc` should be accepted, not only `addTOC` - @ivanlanin GH-294 +- Fix specific borders (and margins) were not written correctly in word2007 writer - @pscheit GH-327 +- "HTML is not a valid writer" exception while running "Sample_36_RTL.php" - @RomanSyroeshko GH-340 +- "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 +- `` tag is closed with `` tag: - @franzholz GH-438 + +### Deprecated + +- `Element\Link::getTarget()` replaced by `Element\Link::getSource()` +- `Element\Section::getSettings()` and `Element\Section::setSettings()` replaced by `Element\Section::getStyle()` and `Element\Section::setStyle()` +- `Shared\Drawing` and `Shared\Font` merged into `Shared\Converter` +- `DocumentProperties` replaced by `Metadata\DocInfo` +- `Template` replaced by `TemplateProcessor` +- `PhpWord->loadTemplate($filename)` + +### Miscellaneous + +- 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 +- Docs: Correct elements.rst about Line - @chrissharkman GH-292 +- PclZip: Remove temporary file after used - @andrew-kzoo GH-265 +- Autoloader: Add the ability to set the autoloader options - @bskrtich GH-267 +- Element: Refactor elements to move set relation Id from container to element - @ivanlanin +- Introduced CreateTemporaryFileException, CopyFileException - @RomanSyroeshko +- Settings: added method to set user defined temporary directory - @RomanSyroeshko GH-310 +- Renamed `Template` into `TemplateProcessor` - @RomanSyroeshko GH-216 +- Reverted GH-51 - @RomanSyroeshko + ## 0.11.1 - 2 June 2014 This is an immediate bugfix release for HTML reader.