Forum


Replies: 3   Views: 19
Replacevariable to link

Posted by Exorion  · 11-03-2026 - 12:20

foreach ($docx->getTemplateVariables()['document'] as $key => $value) {

$array = $this->getWordStyles($value);

Log::notice('getWordStyles', $array);

$link = new WordFragment($this->docx, 'document');

$style = array(

'fontSize' => $array['fontSize'],

'font' => $array['font'],

'color' => $array['color'],

'bold' => $array['bold'],

'italic' => ($array['italic'] == true) ? true : null,

'strikeThrough' => ($array['strike'] == true) ? true : null,

);

$this->docx->createCharacterStyle('leaderCrmStyle' . $key, $style);

$link->addLink($writestr, array(

'url' => (is_null($this->client) ? env('APP_URL', 'www.site.com') : htmlspecialchars(env('APP_URL', 'https://www.site.com') . '/guest/product_request/' . $this->client->api_token . '/' . $p->id . '/?user_id=' . $this->user_id . '&price_level_id=' . $price_level_id)),

'rStyle' => 'leaderCrmStyle' . $key,

));

$variables = array($value => $link);

$this->docx->replaceVariableByWordFragment($variables, array('type' => 'inline'));

}

In previos phpdocx all was same style like in document - but now - its blue color and underline - how i can set the same style like in document? Thanks