Skip to content

Incorrect paragraph spacing #1505

@gimler

Description

@gimler

This is:

Expected Behavior

The line spacing should be 8pt

Current Behavior

The line spacing is 20pt. I found vendor/phpoffice/phpword/src/PhpWord/Style/Paragraph.php:202 it adds the 240 twips that cause the different. But i don't understand why?

Workaround

'spacing' => \PhpOffice\Common\Font::pointSizeToTwips(8) - 240,

How to Reproduce

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

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

        $section = $phpWord->addSection();
        $section->addText(
            '"Learn from yesterday, live for today, hope for tomorrow. '
            . 'The important thing is not to stop questioning." '
            . '(Albert Einstein)',
            [],
            [
                'spacing' => \PhpOffice\Common\Font::pointSizeToTwips(8),
                'spacingLineRule' => \PhpOffice\PhpWord\SimpleType\LineSpacingRule::EXACT
            ]
        );
       $writer = IOFactory::createWriter($phpWord, 'Word2007');

Context

  • PHP version: 7.2.7
  • PHPWord version: 0.15

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions