To set the initial view of a PDF document, use the InitialViewProfile DDX element. Setting the initial view determines how the PDF output file is displayed on the screen when it is first opened in Adobe Acrobat Reader. You reference the InitialViewProfile by using the InitialView attribute of the PDF result element, as the following example shows:
<?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" initialView="firstView"> ... <InitialViewProfile name="firstView" show="BookmarksPanel" magnification="FitPage" openToPage="2"/> ... </DDX>
In this example, the first time the PDF document is displayed in Acrobat Reader, the document is opened to page two and the bookmark panel is displayed. The magnification of the document is adjusted to fit the page.
For more information on IntialViewProfile settings, see the Adobe LiveCycle Assembler Document Description XML Reference.
You use the processddx action with the Background or Watermark DDX elements to create a text-string watermark. Background elements appear in the background (behind the contents of the page); Watermark elements display in the foreground (over the contents of the page). The syntax for both the elements is the same.
The following example shows the DDX page for using the text string "DRAFT" as a watermark. The watermark appears on every page of the output file. By default, the watermark appears in the middle of the page. In this example, the watermark is rotated 30 degrees:
<?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"> <Watermark rotation="30" opacity="65%"> <StyledText><p font-size="50pt" font-weight="bold" color="lightgray" font="Arial">DRAFT</p></StyledText> </Watermark> ... </PDF> </DDX>
The following example shows how to add different backgrounds on alternating pages. The verticalAnchor attribute displays the background text at the top of the page:
<?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"> <Background alternation="EvenPages" verticalAnchor="Top"> <StyledText><p font-size="20pt" font-weight="bold" color="gray" font="Arial">DRAFT</p></StyledText> </Background> <Background alternation="OddPages" verticalAnchor="Top"> <StyledText><p font-size="20pt" font-weight="bold" color="gray" font="Arial"><i>Beta 1</i></p></StyledText> </Background> ... </PDF> </DDX>
Instead of applying watermarks to the entire output file, you can apply them to individual source files. The following example applies a different background to the first three chapters of a book. The fourth chapter has no background:
<?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="Doc1"> <Background> <StyledText><p font-size="20pt" font-weight="bold" color="lightgray" font="Arial">CHAPTER 1</p></StyledText> </Background> </PDF> <PDF source="Doc2"> <Background> <StyledText><p font-size="20pt" font-weight="bold" color="lightgray" font="Arial">CHAPTER 2</p></StyledText> </Background> </PDF> <PDF source="Doc3"> <Background> <StyledText><p font-size="20pt" font-weight="bold" color="lightgray" font="Arial">CHAPTER 3</p></StyledText> </Background> </PDF> <PDF source="Doc4"/> </PDF> </DDX>
For more information on using DDX instructions to create watermarks, see the Adobe LiveCycle Assembler Document Description XML Reference.
You can use the DocumentText DDX element to return an XML file that contains the text in one or more PDF documents. As with the PDF element, you specify a result attribute the DocumentText element and enclose one or more PDF source elements within the start and end tags, as the following example shows:
<?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"> <DocumentText result="Out1"> <PDF source="doc1"/> </DocumentText> </DDX>
The following code shows the CFM page that calls the DDX file. Instead of writing the output to a PDF file, you specify an XML file for the output:
<cfif IsDDX("documentText.ddx"> <cfset ddxfile = ExpandPath("documentText.ddx")> <cfset sourcefile1 = ExpandPath("book1.pdf")> <cfset destinationfile = ExpandPath("textDoc.xml")> <cffile action="read" variable="myVar" file="#ddxfile#"/> <cfset inputStruct=StructNew()> <cfset inputStruct.Doc1="#sourcefile1#"> <cfset outputStruct=StructNew()> <cfset outputStruct.Out1="#destinationfile#"> <cfpdf action="processddx" ddxfile="#myVar#" inputfiles="#inputStruct#" outputfiles="#outputStruct#" name="ddxVar"> <!--- Use the cfdump tag to verify that the PDF files processed successfully. ---> <cfdump var="#ddxVar#"> </cfif>
The XML file conforms to a schema specified in doctext.xsd. For more information, see http://ns.adobe.com/DDX/DocText/1.0
When you specify more than one source document, ColdFusion aggregates the pages into one file. The following example shows the DDX code for combining a subset of pages from two documents into one output file:
<?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"> <DocumentText result="Out1"> <PDF source="doc1" pages="1-10"/> <PDF source="doc2" pages="3-5"/> </DocumentText> </DDX>