Skip to content

CloneBlock, replaceBlock, and deleteBlock not working in template docx #2410

Open
@MuhammadSyahmi98

Description

@MuhammadSyahmi98

Describe the Bug

I am experiencing issues with the cloneBlock, replaceBlock, and deleteBlock methods in the PHPWord library. These methods are used to manipulate template DOCX files by cloning, replacing, or deleting specific blocks of content. However, they are not functioning as expected.

Steps to Reproduce

Prepare a template DOCX file with the following content:

Customer: ${customer_name}
Address: ${customer_address}
${/block_name}

In the controller or PHP script, use the following code:

$templateProcessor->cloneBlock('block_name', 3, true, true);

Expected Behavior

The cloneBlock method should clone the block_name block three times in the template DOCX file, resulting in multiple repetitions of the block.

Current Behavior

The cloneBlock method does not clone the block as expected. No changes are made to the template DOCX file. Still same like original template

Additional Information

  • The issue persists even when using the simple code provided in the PHPWord documentation.
  • The setValue and setValues methods work correctly, allowing the replacement of individual placeholders in the template.
  • This problem occurs specifically with the cloneBlock, replaceBlock, and deleteBlock methods.
  • The issue is present when using PHP 8.1.
  • I have verified that I am using the latest version of the PHPWord library.
  • No errors or exceptions are thrown during the execution of the code.

Context

Please fill in your environment information:

  • PHP Version: 8.1
  • PHPWord Version: 1.1.0
  • Laravel Version: 10

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