试图解决别人的不太好的代码。任何想法将不胜感激。它似乎在<cfif>
带来图像时爆炸:
<cfif LEN(qryCampers.std_image_filename[iRow + iCol]) GT 0>
如果我注释掉 if(并且只将与“no_image.gif”相关的部分保留在cfif
语句之外)我们很好。文档出现。
CF Server 8,SQL Server 2000,图像尺寸相对较小(全部小于 30kb,宽度不超过 300px),此代码有时会起作用,当它起作用时,加载 PDF 需要永远。此特定查询(仅 12 条记录)导致错误。
错误:
Invalid image format
The error occurred in D:\apps\Websites\Example\app\reports\dsp_camper_cards_preview.cfm: line 51
49 : <td width="40%" align="center" valign="middle">
50 : <cfif LEN(qryCampers.std_image_filename[iRow + iCol]) GT 0>
51 : <cfimage source="../photos/#qryCampers.std_image_filename[iRow + iCol]#" action="read" name="cardImage">
52 : <cfif cardImage.height GT cardImage.width>
53 : <img src="../photos/#qryCampers.std_image_filename[iRow + iCol]#" height="150">
cfdocument
代码:
<cfdocument filename="#fileName#" format="PDF" pagetype="letter"
margintop=".175" marginbottom=".125" marginright=".125" marginleft=".125"
orientation="portrait" unit="in" encryption="none" fontembed="Yes" backgroundvisible="No" overwrite="Yes">
<style type="text/css">
table, tr, td { font-size: 9px; font-family:Arial; }
</style>
<table width="100%" border="0" cellpadding="2" cellspacing="2" align="center" bordercolor="000000">
<cfloop from="1" to="#Ceiling(qryCampers.recordcount/2)#" index="iRow">
<tr valign="top">
<cfloop from="#iRow - 1#" to="#iRow#" index="iCol">
<cfif LEN(qryCampers.student_id[iRow + iCol]) GT 0>
<cfquery name="qryMedInfo" datasource="#session.datasource#">
SELECT * FROM tbl_medical_info_form WHERE mif_std_id = #qryCampers.student_id[iRow + iCol]# AND mif_trip_year = '#DateFormat(Now(), '01/01/yyyy')#'
</cfquery>
<td width="50%">
<table width="100%" border="0" cellpadding="2" cellspacing="2" align="center">
<tr valign="top">
<td height="25%">
<table width="100%" border="0" cellpadding="2" cellspacing="2" align="center">
<tr valign="top">
<td width="40%" align="center" valign="middle">
<cfif LEN(qryCampers.std_image_filename[iRow + iCol]) GT 0>
<cfimage source="../photos/#qryCampers.std_image_filename[iRow + iCol]#" action="read" name="cardImage">
<cfif cardImage.height GT cardImage.width>
<img src="../photos/#qryCampers.std_image_filename[iRow + iCol]#" height="150">
<cfelseif cardImage.height LTE cardImage.width>
<img src="../photos/#qryCampers.std_image_filename[iRow + iCol]#" height="150">
</cfif>
<cfelse>
<img src="../images/no_image.gif" alt="" width="" height="150" border="0">
</cfif>
</td>
<td width="60%">
<cfif qryMedInfo.mif_c_alleriges EQ "Yes" OR LEN(qryMedInfo.mif_severe_allerigies) GT 0>
<font color="FF0000" style="font-size:16px;">ALLERGIES</font><br>
</cfif>
<cfif qryMedInfo.mif_r_alcohol EQ "Yes">
<font color="FF0000" style="font-size:16px;">ALLOWED TO DRINK</font><br>
<cfelse>
<font color="FF0000" style="font-size:16px;">NOT ALLOWED TO DRINK</font><br>
</cfif>
<u>Parent Note</u> : <cfif qryMedInfo.mif_c_alleriges EQ "Yes">#qryMedInfo.mif_history_comments#</cfif><br>
<u><font color="FF0000">SEVERE ALLERGIES</font></u> : #qryMedInfo.mif_severe_allerigies#<br>
<br>
<u>Conditions</u> : #qryMedInfo.mif_med_conditions_1#<br>
<cfif Len(qryMedInfo.mif_med_conditions_2) GT 0>#qryMedInfo.mif_med_conditions_2#<br></cfif>
<u>Medications</u> : <font color="FF0000">#TRIM(qryMedInfo.mif_med_taken_1)#</font><br>#TRIM(qryMedInfo.mif_med_taken_2)#<br>
<font color="FF0000"><u>CANNOT TAKE</u> : </font>
<cfif qryMedInfo.mif_r_aspirin EQ "No"> Aspirin,</cfif>
<cfif qryMedInfo.mif_r_pepto EQ "No"> Pepto Bismol,</cfif>
<cfif qryMedInfo.mif_r_non_aspirin EQ "No"> Non-Apsirin (Acetaminophen/Tylenol),</cfif>
<cfif qryMedInfo.mif_r_maalox EQ "No"> Maalox,</cfif>
<cfif qryMedInfo.mif_r_nsaid EQ "No"> NSAID (Ibuprofen/Advil, Motrin or Naproxensodium/Aleve),</cfif>
<cfif qryMedInfo.mif_r_immodium EQ "No"> Immodium,</cfif>
<cfif qryMedInfo.mif_r_benadryl EQ "No"> Benadryl,</cfif>
<cfif qryMedInfo.mif_r_simethicone EQ "No"> Simethicone (GasX),</cfif>
<cfif qryMedInfo.mif_r_sudafed EQ "No"> Pseudoephedrine/Sudafed,</cfif>
<cfif qryMedInfo.mif_r_tagamet EQ "No"> Tagamet or similar,</cfif>
<cfif qryMedInfo.mif_r_cough EQ "No"> Cough Medicine,</cfif>
<cfif qryMedInfo.mif_r_bandages EQ "No"> Bendages,</cfif>
<cfif qryMedInfo.mif_r_throat EQ "No"> Throat Lozenges,</cfif>
<cfif qryMedInfo.mif_r_antibiotic EQ "No"> Antibiotic Ointment,</cfif>
<cfif qryMedInfo.mif_r_ex_anesthetic EQ "No">External Anesthetic (Calamine or the like),</cfif>
<cfif qryMedInfo.mif_r_cortisone EQ "No"> Topical Cortisone Cream,</cfif>
<cfif qryMedInfo.mif_r_tylenol_pm EQ "No"> Tylenol PM</cfif>
<br>
</td>
</tr>
<tr>
<td colspan="2">
<font style="font-size:16px;font-weight:bold;color:0000ff;">
#qryCampers.std_first_name[iRow + iCol]# #qryCampers.std_last_name[iRow + iCol]#
</font><br>
<br>
<u>Emergency Contact</u> : #qryMedInfo.mif_emerg_name# <cf_phoneoutput startstring="#GetNumbers(qryMedInfo.mif_emerg_phone)#"><br>
<br>
<u>Father/Gaurdian</u> : #qryCampers.ftr_first_name[iRow + iCol]# #qryCampers.ftr_last_name[iRow + iCol]#
<u>(H)</u> <cf_phoneoutput startstring="#GetNumbers(qryCampers.ftr_main_phone[iRow + iCol])#"> or <u>(C)</u> <cf_phoneoutput startstring="#GetNumbers(qryCampers.ftr_cell_phone[iRow + iCol])#"><br>
<u>Mother/Gaurdian</u> : #qryCampers.mtr_first_name[iRow + iCol]# #qryCampers.mtr_last_name[iRow + iCol]#
<u>(H)</u> <cf_phoneoutput startstring="#GetNumbers(qryCampers.mtr_main_phone[iRow + iCol])#"> or <u>(C)</u> <cf_phoneoutput startstring="#GetNumbers(qryCampers.mtr_cell_phone[iRow + iCol])#"><br>
</td>
</tr>
</table>
</td>
</tr>
</table>
</td>
<cfelse>
<td width="50%"> </td>
</cfif>
</cfloop>
</tr>
<cfif iRow MOD 4 IS 0>
<tr>
<td> </td>
</tr>
</cfif>
</cfloop>
</table>
</cfdocument>