Forum


Replies: 5   Views: 2768
Issue with addtext(..) in addlist() item
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  · 03-04-2017 - 14:44

Hello,

You need to use a custom paragraph style or a custom style list imported from an existing DOCX , use an existing style in a template or create a custom paragraph style using createParagraphStyle.

This is a simple sample of a custom paragraph style created dynamically to set custom spacings:

// style options
$style = array(
    'lineSpacing' => 480,
    'spacingTop' => 360,
    'spacingBottom' => 360,
);
$docx->createParagraphStyle('myStyle', $style);

$item1 = new WordFragment($docx);
$item1->addText('Line 1', array('pStyle' => 'myStyle'));
$item2 = new WordFragment($docx);
$item2->addText('Line 2', array('pStyle' => 'myStyle'));
$item3 = new WordFragment($docx);
$item3->addText('Line 3', array('pStyle' => 'myStyle'));

$itemList = array(
    $item1,
    $item2,
    $item3,
);

$docx->addList($itemList, 1, array('useWordFragmentStyles' => true));

Regards.