Forum


Replies: 7   Views: 4562
Set line height and justify text in addlist
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 larrytech  · 07-03-2015 - 13:32

I have a list (kind of like a table of contents) in which I want to increase the line height and justify the text. Each list element is a word fragment, and each word fragment has a link via AddLink and text via AddText. I'm then adding the array of word fragments (one for each list element) via AddList. I'm setting the textAlign and lineSpacing options in the AddLink and AddText methods, but this doesn't work. How can I achieve the above?

Posted by admin  · 09-03-2015 - 07:35

Hello, The simplest approach is that you create a new DOCX with that list style and then use the importListStyle method, Regards.

Posted by larrytech  · 09-03-2015 - 14:27

Thanks for your reply! However - I'm having trouble making this work. I have the style I want: http://i.imgur.com/QgCujnr.png And then I do: $this->document->importListStyle(path('storage').'documents/phpdocx/styles.docx', 'PredictionsListStyle', 'PredictionsListStyle'); But I get the error message: The requested list style could not be found. On a similar note: I think there might be a bug in the importListStyle function: PHP Notice: Undefined variable: zipStyles in CreateDocx.inc on line 3965 https://www.diffchecker.com/244pd6cy

Posted by admin  · 09-03-2015 - 14:57

Hello, With both importStyles and importListStyle methods you can use the method parseStyles to get the associated Id of each style. Please use importStyles and parseStyles methods to you what you need, the importListStyle is being deprecated. Regards.

Posted by larrytech  · 09-03-2015 - 16:20

Thank you. When I tried this earlier I had the following output from parseStyles: NAME: Predictions List Style Type: paragraph ID: PredictionsListStyle Default: false Custom: false When I call $this->fragments['excerpts']->addList($excerpts, 'PredictionsListStyle'); I get a PHP Notice: Undefined index: PredictionsListStyle in CreateDocx.inc on line 2323

Posted by admin  · 09-03-2015 - 16:45

Hello, Please send to contact[at]phpdocx.com the DOCX with the list style and we'll check it. Regards.

Posted by larrytech  · 09-03-2015 - 19:36

Just to update this thread for the benefit of anyone with a similar issue: Due to some combination and how phpdocx and Word works, the only approach you have for now is to do something such as: $docx = new CreateDocx(); $docx->importStyles('styles.docx', 'merge', array('List Style Char')); $docx->addText('Line 1', array('pStyle' => 'PredictionsListStyle')); $docx->addText('Line 2', array('pStyle' => 'PredictionsListStyle')); $docx->addText('Line 3', array('pStyle' => 'PredictionsListStyle')); $docx->addText('Line 4', array('pStyle' => 'PredictionsListStyle')); $docx->addText('Line 5', array('pStyle' => 'PredictionsListStyle')); This will create a list with your styles. For Word, the lists are paragraphs with a special style.

Posted by admin  · 10-03-2015 - 07:26

Hello, Just to complement the information. In OOXML, lists are paragraphs with a style. So needed the steps are: 1. Create with createListStyle or import with importStyles a style. 2. Use this style with texts through the option pStyle. Regards. Regards.