生成动态cfdocument - 需要可变的字体大小

时间:2013-11-13 05:43:53

标签: pdf coldfusion font-size cfml

我有一个CFML页面,允许用户输入相当多的信息并保存(MS SQL)。然后他们可以创建一个包含在textarea中的伪造报告页面。

<cfform action="index.cfm?fa=customReportAction" method="post">
    <cfif benchInfo.custom_report EQ "" or attributes.submit eq "Generate New Reports">
    <cfif attributes.submit eq "Generate New Reports">
    This is a new version of the report<br>
    </cfif>
    <cftextarea name="custom_report" richtext="true" value="#body_temp#" width="1000" height="600">
        <cfoutput>

            <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
            <div align="center" >
                <br />
                <br />
                <div>
                    <img src="#replace(request.controlurl,'https','http')#images/Logo.png" />
                </div>
                <br />
                <br />
                <div style="font-size:20px; font-weight:bold; padding-top:25px;">Benchmark Comparative Study 
                    <br />
                    Summary</div>
                <div style="padding-top:10px; "><h2>
                        #benchInfo.name# 
                    </h2></div>

lots of code...............

        </cfoutput>
    </cftextarea>
    <br />
    <br />
    <cfelse>
        <cftextarea name="custom_report" richtext="true" value="#benchInfo.custom_report#" width="1000" height="600"></cftextarea><br /><br />
        </cfif>
    <cfinput type="hidden" name="benchid" value="#attributes.benchid#" />
    <cfinput type="submit" value="Submit" name="Submit" />
</cfform>

提交按钮将它们带到创建cfdocument的操作页面;

<cfparam name="doc_title" default = "#replace(benchInfo.title, " ", "_", "all")#" />
<cfset doc_title = #replace(benchInfo.title, " ", "_", "all")# />
<cfset custom_report2 = "#replace(form.custom_report, "&lt;--- This is a page break ---&gt;", "|", "all")#"> 
<cfinvoke component="cfc.updates" method="updSalBenchCustomReport" sb_id="#attributes.benchID#" custom_report="#custom_report2#" />

<cfset infoReplaceBegin = "<!-- Info -->">
<cfset infoReplaceEnd = "<!-- End Info -->">

<cfdocument format="pdf" filename="#request.Controlpath#salarybenchmarking\reports\#benchid#\#doc_title#_client.pdf" overwrite="yes" 
            marginbottom=".5">
     <cfdocumentitem 
      type = "footer">
        <cfoutput>
        <div style="float:left; text-align:left; border-top:1px solid ##910062; width:100%; padding-top:5px; horizontal-align:top;">
                <img src="#request.controlurl#images/Logo_small.jpg"  />
                <span style="padding-left:215px; line-height:12px;"><a href="http://www.tt.com" style="font-size:12px; ">www.Tt.com</a></span>
                <span style="padding-left:225px; font-size:12px;">Page #cfdocument.currentpagenumber# of #cfdocument.totalpagecount#</span>
        </div>
        </cfoutput>
    </cfdocumentitem> 

        <cfoutput>
            <cfset counter = 0>
            <cfloop list="#custom_report2#" delimiters="|" index="x">

            <cfset counter = counter + 1>   
            <cfif counter eq 1>
                <cfset infoBegin = findnocase(infoReplaceBegin,x)>
                <cfset infoEnd = findnocase(infoReplaceEnd,x)>
                <cfif val(infoBegin) and val(infoEnd) and (val(infoEnd) gt val(infoBegin))>
                    <cfset stringCount = evaluate((infoend - infobegin)+len(infoReplaceEnd))>
                    <cfset tempString = mid(x,infoBegin,stringCount)>
                    <cfset x = replacenocase(x, tempString, '')>
                </cfif>
            </cfif>     
            #x#

            <!--- Check to see if it's not the last delimiter --->
            <cfif counter lt evaluate(listlen(custom_report2,"|")-1)>
                <cfdocumentitem type="pagebreak"></cfdocumentitem>
            </cfif>
            </cfloop>

        </cfoutput>


</cfdocument>

<cfset compReplaceBegin = "<!-- Companyname -->">
<cfset compReplaceEnd = "<!-- End Companyname -->">
<cfdocument format="pdf" filename="#request.Controlpath#salarybenchmarking\reports\#benchid#\#doc_title#_participant.pdf" overwrite="yes" marginbottom="0">

        <cfoutput>
            <cfloop list="#custom_report2#" delimiters="|" index="x">

            <cfset compBegin = findnocase(compReplaceBegin,x)>
            <cfset compEnd = findnocase(compReplaceEnd,x)>
            <cfif val(compBegin) and val(compEnd) and (val(compEnd) gt val(compBegin))>
                <cfset stringCount = evaluate((compend - compbegin)+len(compReplaceEnd))>
                <cfset tempString = mid(x,compBegin,stringCount)>
                <cfset x = replacenocase(x, tempString, '')>
            </cfif>
            #x#
            <div style="float:left; position:absolute; top:925px; text-align:center; border-top:1px solid ##910062; width:100%; padding-top:5px;">
                <div style="float:left; "><img src="#request.controlurl#images/Logo_small.jpg" /></div>
                <div style="text-align:center; float:left; width:80%;"><a href="http://www.tt.com" style="font-size:12px; ">www.Tt.com</a></div>
                <div style="float:right; position:absolute; width:100%; text-align:right; font-size:10px; padding-top:10px;">Page 1 of 1</div>
            </div>
            <cfbreak>
            </cfloop>

        </cfoutput>


</cfdocument>

<cfoutput>
<br />
<a href="#request.controlURL#salarybenchmarking/reports/#benchid#/#doc_title#_client.pdf" target="_blank">View Client PDF</a><br />
<br />
<a href="#request.controlURL#salarybenchmarking/reports/#benchid#/#doc_title#_participant.pdf" target="_blank">View Participant PDF</a><br />
<br />
<a href="#request.controlURL#salarybenchmarking/index.cfm?fa=view&benchID=#attributes.benchID#" >Return to Benchmark Details</a><br />
<br />
<a href="#request.controlURL#salarybenchmarking/">Salary Benchmarking Home</a><br />
<br />
</cfoutput>

当输入太多数据时会出现问题,即会创建自动分页符。有时用户必须花时间缩写他们的笔记以使其适合页面。我以为我可以允许他们更改字体/大小并保存该信息。然后他们可以重新创建PDF并查看它是否“适合”。我可以看到全局字体/大小可能有点棘手。我需要某种类型的对话框来允许用户进行全局字体选择。

1 个答案:

答案 0 :(得分:1)

<cfdocument scale="xx">

放大整个pdf