title: Dynamically display page number in cfdocument
body: <p>I'm able to create a PDF no problem but need the page number of the PDF to begin on a certain page -- not 1. Normally I would use the cfdocument scope to show the page number but because I don't want the page number to start on 1 I can't get the code to work. Not sure how best to do this while incrementing each page. Here's the code that works fine:</p>
  
  <pre><code>&lt;cfset theStartPageNumber = 10 /&gt;
  &lt;cfdocument format="PDF&gt;
    &lt;cfoutput query="getPerson"&gt;
      &lt;cfdocumentsection&gt;
        &lt;cfdocumentitem type="header"&gt;
          &lt;table&gt;
            &lt;tr&gt;
              &lt;td&gt;My Header&lt;/td&gt;
            &lt;/tr&gt;
          &lt;/table&gt;
        &lt;/cfdocumentitem&gt;
        #getPerson.FirstName# #getPerson.LastName#
        &lt;cfdocumentitem type="footer" evalAtPrint="true" pageNumber="#theStartPageNumber#"&gt;
          &lt;table&gt;
            &lt;tr&gt;
              &lt;td align="center"&gt;&lt;cfoutput&gt;#attributes.pageNumber#&lt;/cfoutput&gt;&lt;/td&gt;
            &lt;/tr&gt;
          &lt;/table&gt;
        &lt;/cfdocumentitem&gt;
      &lt;/cfdocumentsection&gt;
      &lt;cfset thePageNumber ++ /&gt;
    &lt;/cfoutput&gt;
  &lt;/cfdocument&gt;
  </code></pre>
  
  <p>But when I introduce a page break the numbering doesn't increment each page. Here's code that doesn't increment each page number.</p>
  
  <pre><code>&lt;cfset theStartPageNumber = 10 /&gt;
  &lt;cfdocument format="PDF&gt;
    &lt;cfoutput query="getPerson"&gt;
      &lt;cfdocumentsection&gt;
        &lt;cfdocumentitem type="header"&gt;
          &lt;table&gt;
            &lt;tr&gt;
              &lt;td&gt;My Header&lt;/td&gt;
            &lt;/tr&gt;
          &lt;/table&gt;
        &lt;/cfdocumentitem&gt;
        #getPerson.FirstName# #getPerson.LastName#
        &lt;cfdocumentitem type="pagebreak" /&gt;
        #getPerson.Address#
        &lt;cfdocumentitem type="pagebreak" /&gt;
        &lt;cfdocumentitem type="footer" evalAtPrint="true" pageNumber="#theStartPageNumber#"&gt;
          &lt;table&gt;
            &lt;tr&gt;
              &lt;td align="center"&gt;&lt;cfoutput&gt;#attributes.pageNumber#&lt;/cfoutput&gt;&lt;/td&gt;
            &lt;/tr&gt;
          &lt;/table&gt;
        &lt;/cfdocumentitem&gt;
      &lt;/cfdocumentsection&gt;
      &lt;cfset thePageNumber ++ /&gt;
    &lt;/cfoutput&gt;
  &lt;/cfdocument&gt;
  </code></pre>
  
  <p>Using the code that doesn't work the page number will stay "10" for two pages then increment to "11".</p>
  
  <p>Any help is appreciated!</p>