[英]PHPOffice/PHPWord - How to setup paper size with landscape orientation
I did follow this post: How to change paper size in PHPWord我确实关注了这篇文章: 如何在 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');
?>
It will create file with Letter paper and Portrait layout它将使用信纸和纵向布局创建文件
I change to this:我改成这样:
$section = $phpword->addSection(array('orientation' => 'landscape'));
It generated file with Landscape layout but is A4 paper size.它生成的文件具有横向布局,但为A4纸大小。
How to generate file with Letter size + Landscape layout?如何生成具有 Letter 大小 + 横向布局的文件?
Thank you!谢谢!
Insert the orientation key in the array with width and height:在具有宽度和高度的数组中插入方向键:
$section = $phpword->addSection(array(
'pageSizeW' => $paper->getWidth(),
'pageSizeH' => $paper->getHeight(),
'orientation' => 'landscape'
));
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.