PhpOffice\PhpPresentation\DocumentLayout::setDocumentLayout PHP Method

setDocumentLayout() public method

Set Document Layout
public setDocumentLayout ( array | string $pValue = self::LAYOUT_SCREEN_4X3, boolean $isLandscape = true ) : DocumentLayout
$pValue array | string
$isLandscape boolean
return DocumentLayout
    public function setDocumentLayout($pValue = self::LAYOUT_SCREEN_4X3, $isLandscape = true)
    {
        switch ($pValue) {
            case self::LAYOUT_SCREEN_4X3:
            case self::LAYOUT_SCREEN_16X10:
            case self::LAYOUT_SCREEN_16X9:
            case self::LAYOUT_35MM:
            case self::LAYOUT_A3:
            case self::LAYOUT_A4:
            case self::LAYOUT_B4ISO:
            case self::LAYOUT_B5ISO:
            case self::LAYOUT_BANNER:
            case self::LAYOUT_LETTER:
            case self::LAYOUT_OVERHEAD:
                $this->layout = $pValue;
                $this->dimensionX = $this->dimension[$this->layout]['cx'];
                $this->dimensionY = $this->dimension[$this->layout]['cy'];
                break;
            case self::LAYOUT_CUSTOM:
            default:
                $this->layout = self::LAYOUT_CUSTOM;
                $this->dimensionX = $pValue['cx'];
                $this->dimensionY = $pValue['cy'];
                break;
        }
        if (!$isLandscape) {
            $tmp = $this->dimensionX;
            $this->dimensionX = $this->dimensionY;
            $this->dimensionY = $tmp;
        }
        return $this;
    }

Usage Example

 /**
  * Test set custom layout
  */
 public function testSetCustomLayout()
 {
     $object = new DocumentLayout();
     $object->setDocumentLayout(array('cx' => 6858000, 'cy' => 9144000), false);
     $this->assertEquals(DocumentLayout::LAYOUT_CUSTOM, $object->getDocumentLayout());
     $this->assertEquals(9144000, $object->getCX());
     $this->assertEquals(6858000, $object->getCY());
     $object->setDocumentLayout(array('cx' => 6858000, 'cy' => 9144000), true);
     $this->assertEquals(DocumentLayout::LAYOUT_CUSTOM, $object->getDocumentLayout());
     $this->assertEquals(6858000, $object->getCX());
     $this->assertEquals(9144000, $object->getCY());
 }
All Usage Examples Of PhpOffice\PhpPresentation\DocumentLayout::setDocumentLayout