Forum


Replies: 1   Views: 679
Clone block to end of document
Topic closed:
Please note this is an old forum thread. Information in this post may be out-to-date and/or erroneous.
Every phpdocx version includes new features and improvements. Previously unsupported features may have been added to newer releases, or past issues may have been corrected.
We encourage you to download the current phpdocx version and check the Documentation available.

Posted by cheesestring  · 22-12-2022 - 03:34

Hi all,

Question is mostly in the title. I'm working with blocks and need to clone a block and append it to the end of the document, not just where it is currently located. Can this be done with blocks and if not, what is the best way to accomplish similar behavior?

On another side question, is it possible to use the deleteBlock method to delete the Nth clone of a block?

Any help appreciated!

Posted by admin  · 22-12-2022 - 06:17

Hello,

What version and license of phpdocx are you using? Please send to contact[at]phpdocx.com the username or email of the user that purchased the license you are using.

You need to use DOCXPath (https://www.phpdocx.com/documentation/introduction/docxpath) for both tasks.

I'm working with blocks and need to clone a block and append it to the end of the document, not just where it is currently located

You need to use cloneBlock to clone the block and then moveWordContent to move the cloned block to the end of the document.

is it possible to use the deleteBlock method to delete the Nth clone of a block

The deleteBlock method doesn't include a method to delete specific positions of a block, but you can use removeWordContent to accomplish this task.

Regards.