Extract Metadata

When a file format supports metadata, KeyView can extract and process that information. Metadata includes document information fields such as title, author, creation date, and file size. Depending on the file's format, metadata is referred to in a number of ways: for example, "summary information," "OLE summary information," "file information," and "document properties."

The metadata in mail formats (MSG and EML) and mail stores (PST, NSF, and MBX) is extracted differently than other formats. For information on extracting metadata from these formats, see Use the Metadata API.

NOTE: KeyView can extract metadata from a document only if metadata is defined in the document, and if the document reader can extract metadata for the file format. The section Document Readers lists the file formats for which metadata can be extracted. KeyView does not generate metadata automatically from the document contents.

Extract Metadata by Using the API

You can extract the metadata at the API level. The API extracts all valid metadata fields that exist in the file.

Use the C API

To extract metadata by using the C API

  1. Declare a pointer to the KVSummaryInfoEx structure. KVSummaryInfoEx.

  2. Call the fpGetSummaryInfo() function. See fpGetSummaryInfo().

Extract Metadata by Using a Template File

When using a template file, KeyView recognizes two types of metadata: standard and non-standard. Standard metadata includes fields, such as Title, Author, and Subject. The standard fields are enumerated from 1 to 41 in KVSumType in the header file kvtypes.h. Non-standard metadata includes any field not listed from 1 to 41 in KVSumType, such as user-defined fields (for example, custom property fields in Microsoft Word documents), or fields that are unique to a particular file type (for example, "Artist" or "Genre" fields in MP3 files). Enumerated types 42 and greater are reserved for non-standard metadata.

To extract metadata by using a template file

  1. Insert metadata tokens in a member of the KVHTMLTemplateEx structure in the template file. This defines the point at which the metadata appears in the HTML output.

  2. If you are using the $USERSUMMARY or $SUMMARY token, define the szUserSummary member of the KVHTMLTemplateEx structure in the template file. This determines the markup and tokens generated when these metadata tokens are processed.

  3. In your application, read the template file and write the data to the KVHTMLTemplateEx structure.

    See htmlini.

The following metadata tokens can be used in the template files:

Token Description
$SUMMARYNN

Inserts the data from a specified metadata field. NN is a number from 00 through 42 enumerated in KVSumType in kvtypes.h.

$SUMMARY

Inserts the data from valid metadata fields in the range of 0 to 33 using the markup provided in pszUserSummary.

$USERSUMMARY

Inserts the data from every valid non-standard metadata field using the markup provided in pszUserSummary.

$CONTENT

Inserts the content of the metadata field specified by the $NAME token.

$NAME

Inserts the name of a the metadata field, such as "Title," "Author," or "Subject."

Depending on the markup in szUserSummary, the extracted metadata might not appear in the browser when the HTML file is displayed, but might appear in the output file. Most of the KeyView-supplied template files extract standard metadata from a document, and include it in the output HTML. However, they do not display the metadata in a browser.

Examples

$SUMMARYNN

The following markup displays the contents of the "Title" field at the top of the main HTML file:

szMainTop=<em><strong>$SUMMARY01</strong></em>

In KVSumType, 01 is the enumerated value for the "Title" metadata field.

$SUMMARY

The following markup extracts all standard fields, and includes them in the first heading level 1 HTML block:

szFirstH1Start=$SUMMARY
szUserSummary=<meta name="$NAME" content="$CONTENT" />

This example extracts the field name ($NAME) and field content ($CONTENT) for standard metadata from a document, and includes it at the beginning of the first Heading level 1 HTML block. However, it does not display the metadata in the browser. The HTML output might look like this:

<meta name="CodePage" content="1252" />
<meta name="Title" content="My design document" />
<meta name="Subject" content="design specifications" />
<meta name="Author" content="John Doe" />
<meta name="Keywords" content="" />
<meta name="Comments" content="" />
<meta name="Template" content="Normal.dot" />
<meta name="LastAuthor" content="lchapman" />
<meta name="RevNumber" content="6" />
<meta name="EditTime" content="01/01/1601, 0:08" />
<meta name="LastPrinted" content="14/01/2002, 14:06" />
<meta name="Create_DTM" content="27/08/2003, 10:31" />
<meta name="LastSave_DTM" content="29/08/2003, 14:07" />
<meta name="PageCount" content="1" />
<meta name="WordCount" content="4062" />
<meta name="CharCount" content="23159" />
<meta name="AppName" content="Microsoft Word 9.0" />
<meta name="Security" content="0" />
<meta name="Category" content="software" />
<meta name="LineCount" content="192" />
<meta name="ParCount" content="46" />
<meta name="ScaleCrop" content="FALSE" />
<meta name="Manager" content="" />
<meta name="Company" content="Autonomy" />

To display the metadata in a browser, use the following markup in szUserSummary:

<hr>name="$NAME" content="$CONTENT" <br>/>

$USERSUMMARY

The following markup extracts non-standard fields, and includes them at the bottom of the main HTML file:

szMainBottom=$USERSUMMARY
szUserSummary=<meta name="$NAME" content="$CONTENT" />

This example extracts the field name ($NAME) and field content ($CONTENT) for non-standard metadata from a document, and includes it at the bottom of the main HTML file. However, it does not display the metadata in the browser. The HTML output might look like this:

meta name="Telephone number" content="444-111-2222" 
meta name="Recorded date" content="07/03/2003, 23:00" 
meta name="Source" content="TRUE" 
meta name="my property" content="reserved"

To display the metadata in a browser, use the following markup in szUserSummary:

<hr>name="$NAME" content="$CONTENT" <br>/>