Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to setup paper size with orientation #2027

Closed
lamkute opened this issue Feb 24, 2021 · 2 comments
Closed

How to setup paper size with orientation #2027

lamkute opened this issue Feb 24, 2021 · 2 comments

Comments

@lamkute
Copy link

lamkute commented Feb 24, 2021

Hello,
im trying to create a document in Letter paper size and Landscape orientation with this code.
but it still give A4 size.
Can anybody help?
Thank you!

<?php
require_once 'vendor/autoload.php';
$paper = new \PhpOffice\PhpWord\Style\Paper();
$paper->setSize('Letter');  

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

$section = $phpword->addSection(array('orientation' => 'landscape'));
$section->addText("Hello World!");

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

?>
@oleibman
Copy link
Contributor

This should work:

<?php
require_once 'vendor/autoload.php';

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

$section = $phpword->addSection();
$section->getStyle()
    ->setPaperSize('Letter')
    ->setLandscape()
;
$section->addText("Hello World!");

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

@SarahTrees
Copy link
Contributor

Support question successfully answered.
Sample code works.
Issue can be marked as closed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

No branches or pull requests

4 participants