php - PHPOffice/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');
?>
它将使用信纸和纵向布局创建文件
我改成这样:
$section = $phpword->addSection(array('orientation' => 'landscape'));
它生成的文件具有横向布局,但为A4纸大小。
如何生成具有 Letter 大小 + 横向布局的文件?
谢谢!
解决方案
在具有宽度和高度的数组中插入方向键:
$section = $phpword->addSection(array(
'pageSizeW' => $paper->getWidth(),
'pageSizeH' => $paper->getHeight(),
'orientation' => 'landscape'
));
推荐阅读
- woocommerce - WooCommerce 产品导入元数据包
- javascript - 无法删除 Typeahead react-bootstrap 中的输入内容
- node.js - Jest 挂在 Supertest 的 POST 上并且不执行“posttest”脚本
- python - 计算两个列表的所有 IoU 的有效方法
- python - 程序一直说'str'对象不可调用
- ios - 如何让监听器在 Firebase 中工作以在离线时进行多位置更新
- speech-to-text - 语音服务 STT - 可以将请求链接到结果吗?
- python - 如何访问当前文件夹目录之外的代码?
- search - 在 Yii2(网格视图)getter 参数中对计算字段进行排序
- amazon-web-services - ecs 中的服务无法在同一网络中找到另一个服务