Forum


Replies: 1   Views: 1207
Addtext to shape?
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 netsolution  · 18-05-2021 - 14:33

Hi,

I tried to use addText to a shape (just as a string to a rounded rectangle), but there is no text visible in the shape.

Has anyone a working example here?

Thanks!

 

 

 

Posted by admin  · 18-05-2021 - 17:58

Hello,

Please check the following sample included in phpdocx 9.5 and newer releases: examples/Core/addShape/sample_2.php. In this sample you can find how to add text contents into a shape. The following code adds a roundrect shape with a text content:

$txtboxContent = new WordFragment($docx);

$runs = array();

$runs[] = array('text' => 'This text is normal.');
$runs[] = array('text' => ' And this text is red.', 'color' => 'FF0000');

$txtboxContent->addText($runs);

$options = array(
        'width' => 60,
        'height' => 60,
        'strokecolor' => '#ff00ff',
        'strokeweight' => '3',
        'fillcolor' => '#ffff00',
        'position' => 'absolute',
        'marginLeft' => 10,
        'marginTop' => -5,
        'arcsize' => 0.2,
        'textContent' => $txtboxContent,
);

$docx->addShape('roundrect', $options);

Regards.