The metadata method of Docxpresso lets you to include some useful metadata in your document that may be useful just to declare authorship or to allow/simplify future searches in your documents repository.

You may customize:

  • Author information and date of creation.
  • General documenta metadata like title, subject and keywords.

You may also start with a document template with all the required metadata set to the desired values (see Custom templates).

The public API of the metadata method can be summarized as follows:

Signature

public metadata ($options)

Parameters

  • $options (type: array).
    This array has the following available keys and values:

    • author (type: string). The document author name.
    • date (type: string). The document creation date in the format: yyyy-mm-ddTHH:mm:ssZ, for example, 2014-06-20T09:37:12Z.
    • keywords (type: string). A list of keywords with no predefined format (although it is standard to separate them by commas).
    • subject (type: string). The document subject.
    • title (type: string). The document title.

If not set via the metadata method the resulting document will inherit the metadata from the default Docxpresso template or the custom template that you use.

A simple example exemplifying all the above may read:

<?php
/**
 * This sample script customizes the document metadata
 */
require_once 'pathToDOCXPRESSO/CreateDocument.inc';
$doc = new DocxpressocreateDocument();
$format = '.pdf';//.pdf, .doc, .docx, .odt, .rtf
//set the required options
$options = array('author' => 'Billy Paul',
                 'date' => '1972-06-03T19:12:43Z',   
                 'keywords' => 'Billy Paul, Amy Winehouse, record', 
                 'subject' => 'Song Lyrics.',
                 'title' => 'Me and Mr.Jones',                 
                );
$doc->metadata($options);
$doc->paragraph()
    ->text(array('text' => 'This document includes some custom metadata:'));
$doc->unorderedList()->listItem(array('text' => 'author'))
                     ->listItem(array('text' => 'date'))
                     ->listItem(array('text' => 'keywords'))
                     ->listItem(array('text' => 'subject'))
                     ->listItem(array('text' => 'title'));
$doc->render('metadata' . $format);   
//echo a link to the generated document
echo 'You may download the generated document from the link below:<br/>';
echo '<a href="' . 'metadata' . $format . '">Download document</a>';

DOWNLOAD:download pdfdownload docdownload docxdownload odtdownload rtf

Depending on the Operating System and the PDF viewer the document date may be read from the file system and not from the metadata included by this method.