Skip to content

TemplateProcessor cloneBlock Missing template Styles #2639

Open
@CISPDEVELOP

Description

@CISPDEVELOP

Describe the bug and add attachments

When we use cloneBlock in the template and assign values, the content of the document is formatted by default with different styles than when we save the block in the template.
For example, if in my template I have the following formatted in bold, font 12, colors or underlined and more with:

${block}
${title}
${content}
${/block}

When we execute $this->template->cloneBlock('block', 0, true, false, $replacements);

the font style and font size change by default (Calibri, and font size 10).
The strange thing is that the styles are maintained for the line breaks under ${title} or ${content}

Template definition (Museo Sans, Bold, Justify, Font Size 11):
imagen

Output (Removes bold; Change font size to 10):
imagen

and when the file is processed and you manually write below the elements (it retains some styles from the template):
imagen

PD: I am using the HTMLtoOpenXML\Parser to assign html data into the block variables (https://github.com/ffmad/HTMLtoOpenXML) with something like:

public function parse($content){
    $parser = new \HTMLtoOpenXML\Parser();
    return $parser->fromHTML($content);
}

 $replacements[] = [
   'title' =>  $this->parse($htmlContent),
   'content' => $this->parse($htmlContent)
 ];

Expected behavior

Output content within block variables formatted as the template was configured

Steps to reproduce

  1. Initialize template processor

  2. Process html content with HTMLtoOpenXML

  3. Clone block and assign variables with :
    $this->template->cloneBlock('block', 0, true, false, $replacements);

PHPWord version(s) where the bug happened

1.2

PHP version(s) where the bug happened

7.4

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions