Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

TemplateProcessor cloneBlock Missing template Styles #2639

Open
CISPDEVELOP opened this issue Aug 1, 2024 · 0 comments
Open

TemplateProcessor cloneBlock Missing template Styles #2639

CISPDEVELOP opened this issue Aug 1, 2024 · 0 comments

Comments

@CISPDEVELOP
Copy link

CISPDEVELOP commented Aug 1, 2024

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:/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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Development

No branches or pull requests

2 participants