importStyles

importStyles

BASIC / ADVANCED / PREMIUM

Imports Word styles from an external Word document.

Description
public importStyles ( string $path, string $type [, array $myStyles = array() [, string $styleIdentifier ] ] )

This method allows to import Word styles from an external Word document.

You may replace the whole stylesheet or just import a certain list of predefined styles.

If you need to know which styles are available for importation from an external Word document you may use the parseStyles method.

Parameters

path

The path to the Word document from which we want to import the styles.

type

The available options are:

  • ‘replace’ if you wish to overwrite the whole stylesheet or
  • ‘merge’ if you only want to import the styles listed in the $myStyles array.

myStyles

An array with all the names of the styles that you wish to import. You may use the parseStyles($path) method to discover which styles are available.

styleIdentifier

The possible values are:

  • ’styleName’ (default value) if you wish to identify the styles included in $myStyles array by their name or
  • ’styleID’ if you want to use their id.
Return values

Void.

Code samples

Example #1

The resulting Word document looks like:

Example #2

The resulting Word document looks like: