removeChapter

removeChapter

ADVANCED / PREMIUM TRIAL

Removes a whole chapter from a Word document.

Description
public removeChapter (string $source, string $target, string $searchTerm)

This method allows to remove (sub)chapters which corresponding heading contains a certain string of text.

This method finds all headings with the required string of text and removes all contents until one hits a new heading of the same or lower level.

Parameters

source

The path to the source Word document.

target

The path to the resulting Word document.

searchTerm

The string of text that you want to search in the headings.

Exceptions

Error while trying to open the (base) template as a zip file.

Code samples

Example #1

The resulting Word document looks like: