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

Incorrect paragraph spacing #1505

Closed
1 of 3 tasks
gimler opened this issue Nov 12, 2018 · 1 comment
Closed
1 of 3 tasks

Incorrect paragraph spacing #1505

gimler opened this issue Nov 12, 2018 · 1 comment

Comments

@gimler
Copy link
Contributor

gimler commented Nov 12, 2018

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
@troosan
Copy link
Contributor

troosan commented Nov 17, 2018

I guess it's because the default line spacing rule is AUTO. When using EXACT or AT_LEAST, those 240 twips (which is the default height of one line) should not be added.

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

2 participants