Question

I have a CFML page that allows a user to input quite a bit of info and save it (MS SQL). Then they can create a psuedo report page that's contained in a 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>

The submit button takes them to the action page that creates the 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>

The problem comes in when a little too much data is entered an automatic page break is created. Sometimes the user has to spend time abbreviating their notes to make it fit on the page. I was thinking I could allow them to change the font/size and save that info. Then they can re-create the PDF and see if it "fits". I can see where a global font/size might be a little tricky. I need some type of dialog box to allow the user to make a global font selection.

Was it helpful?

Solution

<cfdocument scale="xx">

zooms the whole pdf

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top