Reputation: 123
I did follow this 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');
?>
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.
How to generate file with Letter size + Landscape layout?
Thank you!
Upvotes: 2
Views: 2888
Reputation: 878
Insert the orientation key in the array with width and height:
$section = $phpword->addSection(array(
'pageSizeW' => $paper->getWidth(),
'pageSizeH' => $paper->getHeight(),
'orientation' => 'landscape'
));
Upvotes: 4