Creating a Word document in Coldfusion - how to have pagenumbering?

Saul picture Saul · Aug 11, 2010 · Viewed 9.3k times · Source

I am creating a Word format .doc using the following code, then cfheader and cfcontent to serve. All is good but I need to be able to place dynamic information in the header (or footer), or automatic pagenumbering would be a second best option.

How should I modify the code?

<cfsavecontent variable="myDocument">
<html xmlns:w="urn:schemas-microsoft-com:office:word">
<!--- Head tag instructs Word to start up a certain way, specifically in
print view. --->
    <head>
        <xml>
         <w:WordDocument>
            <w:View>Print</w:View>
            <w:SpellingState>Clean</w:SpellingState>
            <w:GrammarState>Clean</w:GrammarState>
            <w:Compatibility>
             <w:BreakWrappedTables/>
             <w:SnapToGridInCell/>
             <w:WrapTextWithPunct/>
             <w:UseAsianBreakRules/>
            </w:Compatibility>
            <w:DoNotOptimizeForBrowser/>
         </w:WordDocument>
        </xml>
    </head>
<body>
    Regular HTML document goes here
    <!--- Create a page break microsoft style (took hours to find this) 
--->
    <br clear="all"
style="page-break-before:always;mso-break-type:page-break" />
    Next page goes here
</body>
</html>
</cfsavecontent> 

Answer

Selcuk Sasoglu picture Selcuk Sasoglu · Aug 17, 2010

Please have a look at this: Header & Footer I have successfully created custom header and footer with only one html file using this article. (Word 2003)

Hope this helps!