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

Permit book-fold printing #2225

Closed
wants to merge 5 commits into from

Conversation

potofcoffee
Copy link
Contributor

Description

Microsoft Word permits printing documents folded as booklets or books. (See Create a booklet or book in Word).

Creating a booklet or book in Word

Internally, this is accomplished by simply adding <w:bookFoldPrinting/> to settings.xml.

This patch adds this functionality to PHPWord.

Note: In order for this to properly work in Microsoft Word, both paperSize/orientation and page dimensions need to be set for the section. For example, to print a document on A4 paper (landscape) and fold it into A5 pages (portrait), use this section style:

$phpWord->getSettings()->setMirrorMargins(true);
$phpWord->addSection(array(
    'paperSize' => 'A4',
    'orientation' => 'landscape',
    'pageSizeW' => \PhpOffice\PhpWord\Shared\Converter::cmToTwip(14.85),
    'pageSizeH' => \PhpOffice\PhpWord\Shared\Converter::cmToTwip(21),
));

Checklist:

  • I have run composer run-script check --timeout=0 and no errors were reported
  • The new code is covered by unit tests (check build/coverage for coverage report)
  • I have updated the documentation to describe the changes

@github-actions github-actions bot added the Stale label Sep 24, 2022
@PowerKiKi PowerKiKi changed the base branch from develop to master November 16, 2022 21:08
@Progi1984 Progi1984 removed the Stale label Nov 18, 2022
*/
public function setBookFoldPrinting($bookFoldPrinting)
{
$this->bookFoldPrinting = $bookFoldPrinting;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
$this->bookFoldPrinting = $bookFoldPrinting;
$this->bookFoldPrinting = $bookFoldPrinting;
return $this;

@Progi1984
Copy link
Member

@potofcoffee Thank you for your contribution. Could you rebase your PR, please ?

(It's a good job).

@potofcoffee potofcoffee force-pushed the book-fold-printing branch 2 times, most recently from 8deac5d to 1c5ed36 Compare December 2, 2022 07:44
Copy link
Member

@Progi1984 Progi1984 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Some type hintings

src/PhpWord/Metadata/Settings.php Outdated Show resolved Hide resolved
src/PhpWord/Metadata/Settings.php Outdated Show resolved Hide resolved
src/PhpWord/Metadata/Settings.php Outdated Show resolved Hide resolved
src/PhpWord/Metadata/Settings.php Outdated Show resolved Hide resolved
@Progi1984 Progi1984 added this to the v1.1.0 milestone Dec 27, 2022
@Progi1984
Copy link
Member

@potofcoffee Thank for your contribution. Could you fix the CI ?

@PHPOffice PHPOffice deleted a comment from github-actions bot Jan 8, 2023
@Progi1984 Progi1984 force-pushed the master branch 3 times, most recently from 2d9f999 to e458249 Compare August 30, 2023 11:56
@Progi1984
Copy link
Member

Superseeded by #2470.

@Progi1984 Progi1984 closed this Sep 14, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

2 participants