Forum


Replies: 2   Views: 176
Make checkbox only take up as much space as it needs
Topic closed:
Please note this is an old forum thread. Information in this post may be out-to-date and/or erroneous.
Every phpdocx version includes new features and improvements. Previously unsupported features may have been added to newer releases, or past issues may have been corrected.
We encourage you to download the current phpdocx version and check the Documentation available.

Posted by admin  · 30-11-2024 - 10:46

Hello,

Please note that in this case the spacing is generated by the paragraph.

If each checkbox and text are added in a paragraph, you can use spacing styles to get a smaller spacing:

$docx->addText(
    [
        $checkboxFragment1,
        [
            'text' => ' alternative 1',
            'fontSize' => 10
        ],
    ],
    [
        'spacingBottom' => 0,
        'spacingTop' => 0,
    ]
);

$docx->addText(
    [
        $checkboxFragment2,
        [
            'text' => ' alternative 2',
            'fontSize' => 10
        ],
    ],
    [
        'spacingBottom' => 0,
        'spacingTop' => 0,
    ]
);

Or add line breaks in the same paragraph:

$docx->addText(
    [
        $checkboxFragment1,
        [
            'text' => ' alternative 1' . "\n",
            'fontSize' => 10,
        ],
        $checkboxFragment2,
        [
            'text' => ' alternative 2' . "\n",
            'fontSize' => 10,
        ],
    ],
    [
        'parseLineBreaks' => true,
    ]
);

Regards.