ColdFusion 9.0 Resources |
Adding a table of contentsYou use DDX instructions to add a generated table of contents page to the PDF output file. Generating a table of contents is useful if you are assembling documents from multiple sources. You can generate a table of contents that contains active links to pages in the assembled PDF document. The following code shows how to create DDX instructions to merge two documents and add a table of contents: <?xml version="1.0" encoding="UTF-8"?> <DDX xmlns="http://ns.adobe.com/DDX/1.0/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://ns.adobe.com/DDX/1.0/ coldfusion_ddx.xsd"> <PDF result="Out1"> <PDF source="DocumentTitle"/> <TableOfContents/> <PDF source="Doc1"/> <PDF source="Doc2"/> </PDF> </DDX> The TableOfContents element generates a table of contents from the PDF source elements that follow it. Order is important: in the previous example, the table of contents appears on a separate page after the Title and before Doc 1 and Doc 2. The table of contents contains entries from Doc 1 and 2, but not from the title page, because the title page precedes the table of contents in the order of instructions. You do not reference the TableOfContents element on the corresponding ColdFusion page, as the following example shows: <!--- The following code verifies that the DDX file exists and the DDX instructions are valid. ---> <cfif IsDDX("makeBook.ddx")> <!--- This code creates a structure for the input files. ---> <cfset inputStruct=StructNew()> <cfset inputStruct.Title="Title.pdf"> <cfset inputStruct.Doc1="Chap1.pdf"> <cfset inputStruct.Doc2="Chap2.pdf"> <!--- This code creates a structure for the output file. ---> <cfset outputStruct=StructNew()> <cfset outputStruct.Out1="Book.pdf"> <!--- This code processes the DDX instructions and generates the book. ---> <cfpdf action="processddx" ddxfile="makeBook.ddx" inputfiles="#inputStruct#" outputfiles="#outputStruct#" name="myBook"> </cfif> ColdFusion generates a table of contents from the DDX instructions and inserts it in the PDF document in the location that you provided in the DDX file. By default, the table of contents contains active links to the top-level bookmarks in the merged PDF document. You can change the default TableOfContents settings in the DDX file, as the following example shows: <TableOfContents maxBookmarkLevel="infinite" bookmarkTitle="Table of Contents" includeInTOC="false"/> Use the maxBookmarkLevel attribute to specify the level of bookmarks included on the table of contents page. Valid values are infinite or an integer. Use the bookmarkTitle attribute to add a bookmark to the table of contents page in the output file. The includeInTOC attribute specifies whether the bookmark title is included on the table of contents page. Note: You cannot specify keywords as the source for DDX. For example,
if you specify <PDF source = “Title”/> and then add the <_BookmarkTitle/>
tag in the DDX file, ColdFusion throws an exception. This is because,
the _BookmarkTitle tag is converted to TITLE and DDX is case-sensititve.
For more information on the TableOfContents element, see the Adobe LiveCycle Assembler Document Description XML Reference. |