0

我可以创建 PDF 没问题,但需要 PDF 的页码从某个页面开始——而不是 1。通常我会使用 cfdocument 范围来显示页码,但因为我不想要页面从 1 开始的数字 我无法让代码工作。不确定如何在增加每一页时最好地做到这一点。这是运行良好的代码:

<cfset theStartPageNumber = 10 />
<cfdocument format="PDF>
  <cfoutput query="getPerson">
    <cfdocumentsection>
      <cfdocumentitem type="header">
        <table>
          <tr>
            <td>My Header</td>
          </tr>
        </table>
      </cfdocumentitem>
      #getPerson.FirstName# #getPerson.LastName#
      <cfdocumentitem type="footer" evalAtPrint="true" pageNumber="#theStartPageNumber#">
        <table>
          <tr>
            <td align="center"><cfoutput>#attributes.pageNumber#</cfoutput></td>
          </tr>
        </table>
      </cfdocumentitem>
    </cfdocumentsection>
    <cfset thePageNumber ++ />
  </cfoutput>
</cfdocument>

但是当我引入分页符时,编号不会增加每一页。这是不增加每个页码的代码。

<cfset theStartPageNumber = 10 />
<cfdocument format="PDF>
  <cfoutput query="getPerson">
    <cfdocumentsection>
      <cfdocumentitem type="header">
        <table>
          <tr>
            <td>My Header</td>
          </tr>
        </table>
      </cfdocumentitem>
      #getPerson.FirstName# #getPerson.LastName#
      <cfdocumentitem type="pagebreak" />
      #getPerson.Address#
      <cfdocumentitem type="pagebreak" />
      <cfdocumentitem type="footer" evalAtPrint="true" pageNumber="#theStartPageNumber#">
        <table>
          <tr>
            <td align="center"><cfoutput>#attributes.pageNumber#</cfoutput></td>
          </tr>
        </table>
      </cfdocumentitem>
    </cfdocumentsection>
    <cfset thePageNumber ++ />
  </cfoutput>
</cfdocument>

使用不起作用的代码,页码将保持“10”两页,然后增加到“11”。

任何帮助表示赞赏!

4

2 回答 2

0

这实际上最终起作用了。基本上将起始页表单变量添加到 cfdocument.currentpagenumber 变量。

<cfdocumentitem type="footer" evalAtPrint="true" no="#thePageNumber#">
  <span style="border-top:1px solid black;display:block;">&nbsp;</span>
    <table border="0" cellpadding="0" cellspacing="0" width="100%" style="margin-bottom:50px;">
      <tr>
        <td align="left"><font face="Tahoma" color="black"><strong>High Desert Corridor</strong><br/>Street address<br/>City, ST 55555</font></td>
        <td align="center"><cfoutput>#evaluate(attributes.no + cfdocument.currentpagenumber - 1)#</cfoutput></td>
        <td align="right"><font face="Tahoma" color="black">Phone: 555.555.5555<br/>Fax: 555.555.5555<br/>Email: info@domain.com</font></td>
      </tr>
    </table>
</cfdocumentitem>
于 2015-11-16T21:29:23.693 回答
0
<cfset theStartPageNumber = 10 />
<cfdocument format="PDF>
    <cfoutput query="getPerson">
        <cfdocumentsection>
        <cfdocumentitem type="header">
            <table>
            <tr>
            <td>My Header</td>
            </tr>
            </table>
            </cfdocumentitem>
            #getPerson.FirstName# #getPerson.LastName#
            <p style='page-break-after:always;'>&nbsp;</p>
            #getPerson.Address#
            <p style='page-break-after:always;'>&nbsp;</p>
            <cfdocumentitem type="footer" evalAtPrint="true" pageNumber="#theStartPageNumber#">
            <table>
            <tr>
            <td align="center"><cfoutput>#attributes.pageNumber#</cfoutput></td>
            </tr>
            </table>
        </cfdocumentitem>
        </cfdocumentsection>
    <cfset thePageNumber ++ />
    </cfoutput>
</cfdocument>

另外:用我的页脚和数字我做这样的事情:

<cfdocumentitem type="footer" evalatprint="true"> 
  <table width="100%" border="0" cellpadding="0" cellspacing="0"> 
  <tr><td align="center">
  <cfoutput>
    #cfdocument.currentpagenumber# of 
    #cfdocument.totalpagecount# | 
    #dateformat(now(),"mm-dd-yyyy")#
  </cfoutput>
  </td></tr> 
  </table> 
</cfdocumentitem>

我的完整工作示例:

<cfdocument localUrl="yes" 
  format="PDF" 
  mimetype="text/html" 
  marginbottom=".0925" 
  margintop="0" 
  marginright=".1" 
  marginleft=".1">
  <cfoutput>
      test 
      <p style='page-break-after:always;'>&nbsp;</p>
      test
      <p style='page-break-after:always;'>&nbsp;</p>
      test
      <p style='page-break-after:always;'>&nbsp;</p>
</cfoutput>
<cfdocumentitem type="footer" evalatprint="true"> 
  <table width="100%" border="0" cellpadding="0" cellspacing="0"> 
  <tr><td align="center">
  <cfoutput>
    #cfdocument.currentpagenumber# of 
    #cfdocument.totalpagecount# | 
    #dateformat(now(),"mm-dd-yyyy")#
  </cfoutput>
  </td></tr> 
  </table> 
</cfdocumentitem>
</cfdocument>
于 2015-11-13T19:04:38.787 回答