addProperties

addProperties

TRIAL / ADVANCED / PREMIUM

Modifies the document properties.

Description
public addProperties ( array $properties )

This method modifies the properties of the Word document.

With this method it is possible to modify/add the document:

  • title
  • subject
  • author (creator)
  • keywords
  • description
  • category
  • contentStatus (final, draft...)
  • created, modified
  • lastModifiedBy
  • revision
  • Manager
  • Company
  • custom properties (name, type and value)

To modify the layout properties you should use modifyPageLayout method instead.

Parameters

properties

The possible keys and values of this array are:

Key Type Description
title string The title of the document.
subject string The subject of the document.
creator string The document author or creator.
keywords string A list of keywords that may be separated by any character you wish.
description string The description of the document.
category string The category to which you want to associate the document.
Manager string The name of the associated Manager.
Company string The company name.
contentStatus string The current status of the document: final, draft...
created string The created date (W3CDTF without time zone).
modified string The modified date (W3CDTF without time zone).
lastModifiedBy string The username that modified the document.
revision string The revision number.
custom array An array of custom properties. Each entry is composed by the name of the property as key and a value that is itself an array with the type and actual value of the variable.
Code samples

Example #1

The resulting Word document looks like:

Release notes
  • phpdocx 15.0:
    • static variables changed to class attributes. The method can be called multiple times for the same document object.
  • phpdocx 12.0:
    • htmlspecialchars applied in values.
  • phpdocx 8.5:
    • revision option.
  • phpdocx 8.0:
    • lastModifiedBy option.
  • phpdocx 7.0:
    • created and modified options.