Phpword: Line height (line spacing) is setted to 1.5 even defining lineHeight to 1.00

Created on 16 Dec 2016  ·  3Comments  ·  Source: PHPOffice/PHPWord

Creating a Word document, even defining lineHeight to 1.0, the generated document dont respect that definition in lists, paragraphs, headers, footers... the lineHeight is setted to 1.5.

The lineHeight 1.00 specification is only respected in Word 15.29 for macOS 15.29, not in Windows version neither Word online.

Also, in Word online (Office 365), the document can be only opened in “view mode”.

Any help or advice?
Thank you.

Screenshot:
captura 2016-12-16 a las 9 43 24

Most helpful comment

$phpWord = new PhpWord();
$phpWord->setDefaultParagraphStyle(
array(
//'alignment' => \PhpOffice\PhpWord\SimpleType\Jc::LEFT,
'spaceAfter' => \PhpOffice\PhpWord\Shared\Converter::pointToTwip(0),
'spacing' => 120,
'lineHeight' => 1,
)
);

All 3 comments

Reset all the PHP code, the lineHeight stays in 1.00.
The problem opening document is related with tables in document.

$phpWord = new PhpWord();
$phpWord->setDefaultParagraphStyle(
array(
//'alignment' => \PhpOffice\PhpWord\SimpleType\Jc::LEFT,
'spaceAfter' => \PhpOffice\PhpWord\Shared\Converter::pointToTwip(0),
'spacing' => 120,
'lineHeight' => 1,
)
);

I had the same problem with text spacing in a table and this helped me to fix it: 'spaceAfter' => \PhpOffice\PhpWord\Shared\Converter::pointToTwip(0),

Thanks.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

Ryuzakix3 picture Ryuzakix3  ·  6Comments

cedrictailly picture cedrictailly  ·  5Comments

cyrillkalita picture cyrillkalita  ·  6Comments

taophp picture taophp  ·  3Comments

carlosvr90 picture carlosvr90  ·  4Comments