Forum


Replies: 13   Views: 3839
Adding multi-line text
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 mdbollman  · 20-12-2010 - 22:49

In a template docx, I am trying to add a signature to a single template variable. For example,

"Regards,
--
Michael Bollman"

needs to be added in that format to the $SIGNATURE$ variable in the docx.

However, when I do this the resulting docx file is corrupt. Is this not possible?

Posted by jfboyer  · 11-04-2013 - 12:12

[code]$docx->addTemplateVariable(
array(
array(
'SIGNATURE' => 'Regards,',
),
array(
'SIGNATURE' => 'ā€“',
),
array(
'SIGNATURE' => 'Michael Bollman',
),
),
'list'
);[/code]

I think this will work.

Or [code]$docx->addTemplateVariable('SIGNATURE', "Regards,\\nā€“\\nMichael Bollman");[/code]

Posted by admin  · 11-04-2013 - 12:12

Hi,

Phpdocx is not able to add multiline texts as placeholders, the next version of phpdocx pro will add this feature.

Regards.

Posted by gp92300  · 11-04-2013 - 12:12

Hi,

Another trick would be to use a simple list without bullets.

Bye.

Posted by admin  · 11-04-2013 - 12:12

Hi,

Phpdocx pro 2.1 include this feature.

Regards.

Posted by MVa  · 11-04-2013 - 12:12

[quote][b]Quote from admin on January 11, 2011, 12:47[/b]
Hi,

Phpdocx pro 2.1 include this feature.

Regards.[/quote]

Hi,

Can't make it work and didn't find sample
I try the two solutions given below but i had no result

Posted by admin  · 11-04-2013 - 12:12

Hello,

Please check intermediate/Template_multitext.php example included on phpdocx pro.

A short example is:

-------------------------------------------------------
$text = array(
'David Hume',
'-----------',
'Bye'
);

$docx->addTemplateVariable('NAME', $text)
-------------------------------------------------------

Using this code the template placeholder will be replaced writing a new line for each array position.

Regards.

Posted by MVa  · 11-04-2013 - 12:12

Thx

It's work fine!!!

Posted by bstang  · 16-10-2013 - 06:40

Hi,

I am trying to add multi-line text to my table row 2 cell 2.



--------------------------------------------------------------------------

$tableSettings = array(

    'header' => true


);



$data = array(

    array( //row 1

       "cell_1_1"=>"foo",

       "cell_1_2"=>"bar"

    ),

    array( //row 2


       "cell_2_1"=>"hello",

       "cell_2_2"=>array(

                             'David Hume',

                             '--------------',

                             'bye'

                         )

    )

)

$docx->addTemplateVariable($data,'table',$tableSettings);

--------------------------------------------------------------------------



But it doesn't work.


Posted by jorgelj  · 16-10-2013 - 09:07

Hello,



I recommend you to use replaceTemplateVariableByHTML to do that.



Regards.


Posted by bstang  · 16-10-2013 - 10:45

Hi,

I am afraid I can't do that.



I am relying on array of data to generate table rows.

The number of my table rows is dynamic.


Posted by jorgelj  · 17-10-2013 - 09:38

Hi,



But you can create a dynamical HTML that sets a table. Please check examples/intermediate/EmbedHTMLinTable.php example.



Regards.


Posted by bstang  · 18-10-2013 - 05:06

I see. Thank you.