Link to home
Avatar of dawes4000
dawes4000Flag for United States of America

asked on

How to make cfdocument load pdf faster?

The rendering of <cfdocument format="pdf"> takes FOREVER.
I have tried using a progressbar and <cfflush> but the document just doesn't render fast enough.
Any suggestions?
<!--- Code Begins --->
<cfquery name="qryClassDetail" datasource="#session.connString#">
SELECT     tblParts.PartID, tblParts.Description, tblParts.Price, tblParts.Unitofmeasure, tblParts.resale, tblParts.NetPricing, tblClass.class AS Class,
                      tblClass.Description AS classDescription
FROM         tblParts INNER JOIN
                      tblClass ON tblParts.class = tblClass.class
WHERE     (tblParts.resale = 'y')  AND (tblParts.Price <> '0') AND (tblParts.PartID NOT LIKE '%BLANK%')  AND (tblParts.class NOT LIKE '%2') AND (tblParts.class <> 'DBME') AND (tblParts.class <> 'ELE') AND
                      (tblParts.class <> 'RMB') AND (tblParts.class <> 'SCC') AND (tblParts.class <> 'TP') AND (tblParts.class <> 'MISC') AND (tblParts.class <> 'M&C')
GROUP BY tblClass.class, tblParts.PartID, tblParts.Description, tblParts.Price, tblParts.Unitofmeasure, tblParts.resale, tblParts.NetPricing,
                      tblClass.Description
ORDER BY tblClass.class
</cfquery>

<body bgcolor="#FFFFFF" leftmargin="65">
<h3>Please Wait</h3><br>
The pages are loading...<br>
<img name="meter" width="200" height="16" src="../images/progressbar/PercentBlank.gif" border="0" alt="">
<cfflush>
<cfloop from="0" to="100" step="25" index="i">
<cfdocument format="pdf">
<table cellpadding="1" cellspacing="0" border="0" width="620">
<cfoutput query="qryClassDetail" group="Class">
      <tr><td colspan="4">&nbsp;</td></tr>
      <tr bgcolor="##4E8FD1">
            <td colspan="4"><font color="##F2F2F2"><h3>&nbsp;&nbsp;#classDescription#</h3></font></td>
      </tr>
      <tr bgcolor="##CCCCCC">
            <td width="140"><strong> Image</strong></td>
            <td width="100"><strong>PartID</strong></td>
            <td width="328"><strong>Description</strong></td>
            <td align="center" width="52"><strong>Retail</strong></td>
      </tr>
      <cfoutput>
            <cfif qryClassDetail.resale NEQ "n">
                  <cfset PartID = trim(qryClassDetail.PartID)>
                  <cfset netPrice=qryClassDetail.netPricing>
                        <tr>
                              <td align="left">
                                    <img height="40" src="../images/parts/#trim(PartID)#.jpg" border="0">
                              </td>                        
                              <td>&nbsp;#PartID#</font></td>
                              <td>
                                    &nbsp;#qryClassDetail.Description# (#trim(qryClassDetail.UnitofMeasure)#)                        
                              </td>
                              <td align="right">
                                    #NumberFormat(qryClassDetail.price,'______.__')# &nbsp;
                                    <cfif netPrice EQ "n">
                                          <br />
                                          <font style="text-align:right">(net)</font>&nbsp;
                                    </cfif>
                              </td>
                        </tr>                                                            
            </cfif>
      </cfoutput>
</cfoutput>
</table>
</cfdocument>
<cfoutput>
<script language="javascript">
document.images["meter"].src = '../images/progressbar/Percent#i#.gif';
</script>
</cfoutput>
<cfflush>
</cfloop>
Avatar of gdemaria
gdemaria
Flag of United States of America image


Looks like you are generating the PDF file FOUR times..

<cfloop from="0" to="100" step="25" index="i">
<cfdocument format="pdf">

The generation of the PDF file is INSIDE a CFLOOP that runs from 0-100 in steps of 25.   That means you are creating the PDF four times.

I see that you are attempting to create a progress bar using this loop.  I don't think this is the way to do it.    CFFLUSH works by dumping to the screen every X number of bytes generated.  You are writing to a PDF file so you haven't generated anything to the page, so your progress bar won't show until the PDF is done, then the progress bar will go from 0 to 100 immediately and you're done.

Strip out the progress bar and see if it speeds up...




<body bgcolor="#FFFFFF" leftmargin="65">
<h3>Please Wait</h3><br>
The pages are loading...<br>
<cfdocument format="pdf">
<table cellpadding="1" cellspacing="0" border="0" width="620">
<cfoutput query="qryClassDetail" group="Class">
      <tr><td colspan="4">&nbsp;</td></tr>
      <tr bgcolor="##4E8FD1">
            <td colspan="4"><font color="##F2F2F2"><h3>&nbsp;&nbsp;#classDescription#</h3></font></td>
      </tr>
      <tr bgcolor="##CCCCCC">
            <td width="140"><strong> Image</strong></td>
            <td width="100"><strong>PartID</strong></td>
            <td width="328"><strong>Description</strong></td>
            <td align="center" width="52"><strong>Retail</strong></td>
      </tr>
      <cfoutput>
            <cfif qryClassDetail.resale NEQ "n">
                  <cfset PartID = trim(qryClassDetail.PartID)>
                  <cfset netPrice=qryClassDetail.netPricing>
                        <tr>
                              <td align="left">
                                    <img height="40" src="../images/parts/#trim(PartID)#.jpg" border="0">
                              </td>                        
                              <td>&nbsp;#PartID#</font></td>
                              <td>
                                    &nbsp;#qryClassDetail.Description# (#trim(qryClassDetail.UnitofMeasure)#)                        
                              </td>
                              <td align="right">
                                    #NumberFormat(qryClassDetail.price,'______.__')# &nbsp;
                                    <cfif netPrice EQ "n">
                                          <br />
                                          <font style="text-align:right">(net)</font>&nbsp;
                                    </cfif>
                              </td>
                        </tr>                                                            
            </cfif>
      </cfoutput>
</cfoutput>
</table>
</cfdocument>





Avatar of dawes4000

ASKER

gdemaria,
I stripped all of the progress bar caode out and the time to deliver the PDF is 10 minutes, at times never. This same data is presented in html within 30 sec. Basically working with only 1600 records. Each has a thumb nail img less than 6kb. I need to style the text and enter page breaks. So i'm wondering if the css has something to do with the cfdocument.
Tested again, code crashed the cf server. Not sure what is going on here. I have used cfdocument successfully before.
ASKER CERTIFIED SOLUTION
Avatar of gdemaria
gdemaria
Flag of United States of America image

Blurred text
THIS SOLUTION IS ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
See Pricing Options
Start Free Trial
Yes, commenting the imgs out had the pdf output in no time. I guess the issue then is to find a way that users can print this list. If they print the page through the browser then page breaks can not be made. I'm not familiar with flashpaper.
Can on print from flash paper? Otherwise, there may not be an effecient means to print the list.