PHPOffice/PHPWord - 如何设置横向纸张尺寸

PHPOffice/PHPWord - How to setup paper size with landscape orientation

我确实遵循了这个 post:How to change paper size in PHPWord

<?php

require_once 'vendor/autoload.php';

$phpword = new \PhpOffice\PhpWord\PhpWord();

$paper = new \PhpOffice\PhpWord\Style\Paper();
$paper->setSize('Letter'); 

$section = $phpword->addSection(array('pageSizeW' => $paper->getWidth(), 'pageSizeH' => $paper->getHeight()));

$section->addText("Hello World!");

$phpword->save('./test.docx', 'Word2007');

?>

它将使用 Letter 纸和纵向布局创建文件

我改成这样:

$section = $phpword->addSection(array('orientation' => 'landscape'));

它生成了横向布局的文件,但是是 A4 纸张大小。

如何生成 Letter 大小 + 横向布局的文件?

谢谢!

在宽高数组中插入方向键:

$section = $phpword->addSection(array(
    'pageSizeW' => $paper->getWidth(), 
    'pageSizeH' => $paper->getHeight(), 
    'orientation' => 'landscape'
));