PTC ALD in Arbortext Styler > Components of Documents and Templates > Creating New Content from the Main Content Stream > Footnotes > Creating a Footnote Reference
  
Creating a Footnote Reference
The footnote reference is the inline part of a footnote. The fFootnoteReference object represents it in the Formatting Object Model. The footnote reference provides the footnote process that is active during formatting with information it can use to place some text into an area on the page.
The properties of the fFootnoteReference object are:
fFootnoteReference.group — specifies the group to which the footnote belongs
The footnote control streams applied to the frame use this information to determine which set of rules to use to display the footnote.
fFootnoteReference.preferEarlyPlacement (boolean) — instructs PTC Advanced Print Publisher to place the footnotes as the rest of the page is being formatted.
This property is usually set to false.
fFootnoteReference.type — specifies the type of footnote to create
You can use one of the following methods. Values are listed on the fFootnoteReference.FootnoteType constant.
The footnote content comes from a specific PTC Advanced Print Publisher content stream
This is set using the type fFootnoteReference.TYPE_NORMAL and requires a single content stream for the individual footnote.
The stream is specified using the fFootnoteReference.streamName property.
The footnote content is provided inline and added to a named PTC Advanced Print Publisher content stream
This is set using the type fFootnoteReference.TYPE_INLINE_NAME.
PTC Advanced Print Publisher extracts content up to a terminator, which is set using a different type of footnote reference, or a specified string.
The footnote content is provided inline and added to an automatically generated content stream
This is set using the type fFootnoteReference.TYPE_INLINE_AUTO.
PTC Advanced Print Publisher extracts content up to a terminator, which is set using a different type of footnote reference, or a specified string.
The footnote content is provided in a list type content stream and extracted to a named content stream
This is set using the type fFootnoteReference.TYPE_LIST_NAME.
The footnote content is provided in a list type content stream and extracted to an automatically generated content stream.
This is set using the type fFootnoteReference.TYPE_LIST_AUTO.
Two other types are provided. The fFootnoteReference.TYPE_MANUAL type acts as a command to output any outstanding footnotes which have not been placed using the footnote rules. fFootnoteReference.TYPE_END acts as a terminator command if the fFootnoteReference.terminatorString property does not specify one.
fFootnoteReference.streamName — identifies the name of the stream to be used for the new footnote, if required by the footnote type
fFootnoteReference.setXML — sets the XML status of the footnote stream
The property can specify whether to force the XML status on or off, or automatically determine it from the stream’s content.
The values for this property are listed on the fFootnoteReference.XMLState constant.
fFootnoteReference.showString — provides an PTC Advanced Print Publisher showstring to create the text for the footnote reference
A generated identifier is more commonly used as the reference.
fFootnoteReference.terminatorString — the string in content that indicates the end of the footnote content
The inline footnote reference types require a terminator that instructs PTC Advanced Print Publisher to stop gathering content for the footnote. This property is useful if you want to extract all content up to a specific point.
If no terminator string is provided with this property, the footnote ends if a footnote reference of type fFootnoteReference.TYPE_END is found.
fFootnoteReference.streamHierarchy — specifies an alternative location in the tag hierarchy from which to gather the footnote content
For the inline footnote reference types, by default PTC Advanced Print Publisher gathers the content from the main content stream. It is possible to use other content in the tag hierarchy. The location in that hierarchy is specified using this property.
fFootnoteReference.listStreamName — specifies the stream name which holds the paragraphs to be extracted
The property can be set when using one of the list types of footnote reference.
fFootnoteReference.firstShowString, fFootnoteReference.lastShowString — provide an PTC Advanced Print Publisher showstring to generate the sequence numbers of the first and last paragraphs to extract
The property can be set when using one of the list types of footnote reference.
When the footnote reference has been created, use the formatting.addReference() method to add it to the formatting process.
This example code creates and inserts a footnote reference:
formatting.counters[1]++;

var streamName = "footnote_" + formatting.counters[1];

var footnoteStream;
footnoteStream = template.content.getStream(streamName);
if (!footnoteStream) {
footnoteStream = template.content.createStream(streamName, fTag.TYPE_XML);
}
footnoteStream.mapReturns = fStream.MAP_RETURNS;
footnoteStream.ignoreSpaces = fStream.IGNORE_START + fStream.IGNORE_MULTIPLE + fStream.IGNORE_END;

footnoteStream.clear();
footnoteStream.write('\<FNOTE>');
footnoteStream.write(formatting.evaluateXPath('x3b2:content-markup(.)'));
footnoteStream.write("\<\/FNOTE>");

var ref = new fFootnoteReference();

ref.type = fFootnoteReference.TYPE_NORMAL;
ref.streamName = streamName;
ref.group = 1;

formatting.addReference(ref);
This summary describes the steps detailed in this code block:
1. Increments a counter
This counter is used to provide a unique tag name to hold the footnote content.
2. Declares a variable for the footnote content stream name, using the counter value
3. Creates the stream, testing to see whether it exists first or not
4. Sets some whitespace avoidance preferences to ensure whitespace is normalized in the new stream
5. Clears the content of the created stream and writes the XML declaration, a wrapper tag, and the contents of the current footnote element
6. Creates the footnote reference.
The example creates a normal type reference in group 1 and specifies that the new content stream is the content for the footnote.
7. Adds the footnote reference to the formatting process