Skip to content

Commit 1a783d1

Browse files
committed
Merge pull request #379 from spikex/master
Add missing setters for pageSizeW and pageSizeH
2 parents 439f013 + ecaeb96 commit 1a783d1

File tree

3 files changed

+44
-6
lines changed

3 files changed

+44
-6
lines changed

docs/containers.rst

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,8 @@ Section settings
3434

3535
Below are the available settings for section:
3636

37+
- ``pageSizeW`` Page width in twips (the default is 11906/A4 size)
38+
- ``pageSizeH`` Page height in twips (the default is 16838/A4 size)
3739
- ``orientation`` Page orientation, i.e. 'portrait' (default) or
3840
'landscape'
3941
- ``marginTop`` Page margin top in twips
@@ -56,12 +58,6 @@ Below are the available settings for section:
5658
- ``breakType`` Section break type (nextPage, nextColumn, continuous,
5759
evenPage, oddPage)
5860

59-
The following two settings are automatically set by the use of the
60-
``orientation`` setting. You can alter them but that's not recommended.
61-
62-
- ``pageSizeW`` Page width in twips
63-
- ``pageSizeH`` Page height in twips
64-
6561
Page number
6662
~~~~~~~~~~~
6763

src/PhpWord/Style/Section.php

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -239,6 +239,13 @@ public function getPageSizeW()
239239
return $this->pageSizeW;
240240
}
241241

242+
public function setPageSizeW($value = null)
243+
{
244+
$this->pageSizeW = $this->setNumericVal($value, self::DEFAULT_WIDTH);
245+
246+
return $this;
247+
}
248+
242249
/**
243250
* Get Page Size Height
244251
*
@@ -249,6 +256,13 @@ public function getPageSizeH()
249256
return $this->pageSizeH;
250257
}
251258

259+
public function setPageSizeH($value = null)
260+
{
261+
$this->pageSizeH = $this->setNumericVal($value, self::DEFAULT_HEIGHT);
262+
263+
return $this;
264+
}
265+
252266
/**
253267
* Get Margin Top
254268
*

tests/PhpWord/Tests/Style/SectionTest.php

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -96,6 +96,34 @@ public function testMargin()
9696
$this->assertEquals($iVal, $oSettings->getMarginRight());
9797
}
9898

99+
/**
100+
* Set/get page width
101+
*/
102+
public function testPageWidth()
103+
{
104+
// Section Settings
105+
$oSettings = new Section();
106+
107+
$this->assertEquals(11906, $oSettings->getPageSizeW());
108+
$iVal = rand(1, 1000);
109+
$oSettings->setSettingValue('pageSizeW', $iVal);
110+
$this->assertEquals($iVal, $oSettings->getPageSizeW());
111+
}
112+
113+
/**
114+
* Set/get page height
115+
*/
116+
public function testPageHeight()
117+
{
118+
// Section Settings
119+
$oSettings = new Section();
120+
121+
$this->assertEquals(16838, $oSettings->getPageSizeH());
122+
$iVal = rand(1, 1000);
123+
$oSettings->setSettingValue('pageSizeH', $iVal);
124+
$this->assertEquals($iVal, $oSettings->getPageSizeH());
125+
}
126+
99127
/**
100128
* Set/get landscape orientation
101129
*/

0 commit comments

Comments
 (0)