PHPWord icon indicating copy to clipboard operation
PHPWord copied to clipboard

paperSize and margins are broken in ODT

Open skylarmt opened this issue 7 years ago • 1 comments

This is:

  • [x] a bug report

Expected Behavior

$phpWord->addSection(["paperSize" => "Letter", 'marginLeft' => 600, 'marginRight' => 600, 'marginTop' => 600, 'marginBottom' => 600]); should produce a file with Letter-sized paper and "skinny" margins.

Current Behavior

Saving files in Word format has the expected result; however, the paper size and margin settings are ignored when saving in ODT format. The resulting document is A4 sized with 0.98 inch margins (0.79 inch bottom margin).

How to Reproduce

<?php
require __DIR__ . '/vendor/autoload.php';

$phpWord = new \PhpOffice\PhpWord\PhpWord();
$section = $phpWord->addSection(["paperSize" => "Letter"]);
$section->addText("Hello world");
$objWriter = \PhpOffice\PhpWord\IOFactory::createWriter($phpWord, 'ODText');
$objWriter->save('file.odt'); // Will have A4 page size

$objWriter = \PhpOffice\PhpWord\IOFactory::createWriter($phpWord, 'Word2007');
$objWriter->save('file.docx'); // Will have Letter page size

Context

  • PHP version: 7.2.10
  • PHPWord version: 0.14

skylarmt avatar Dec 09 '18 07:12 skylarmt

If someone fixes this before January, I'll send them $10 (US). This has the potential to delay a project I'm developing for a client.

skylarmt avatar Dec 10 '18 01:12 skylarmt