Skip to content

Can't insert Title as complex block with Template Processor #2698

@yojolo

Description

@yojolo

Describe the bug and add attachments

Here is my code in which I'm trying to add a title using the setComplexBlock function

$templateProcessor = new TemplateProcessor($documentModelPath);
$title = new Title("Title 1", 1);
$title->setPhpWord(new PhpWord());
$templateProcessor->setComplexBlock("title", $title);
$templateProcessor->saveAs($outputFile);

With my word templace containing a simple page
image

Result is the text is replaced but as Normal text not title.
image

Also I needed to add the line $title->setPhpWord(new PhpWord()) to avoir the following error :
Call to a member function addBookmark() on null

If I missused the library or if there is any workaroung please let me know.
Thank you !

Expected behavior

I would expect the title to match the required depth and style and to be a real Word title that could be used is summary table, etc.

Steps to reproduce

$templateProcessor = new TemplateProcessor($documentModelPath);
$title = new Title("Title 1", 1);
$title->setPhpWord(new PhpWord());
$templateProcessor->setComplexBlock("title", $title);
$templateProcessor->saveAs($outputFile);

PHPWord version(s) where the bug happened

1.3.0

PHP version(s) where the bug happened

8.2

Priority

  • I want to crowdfund the bug fix (with @algora-io) and fund a community developer.
  • I want to pay the bug fix and fund a maintainer for that. (Contact @Progi1984)

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