编辑 - 有些客户帐户报告的在线帐户余额为0美元,但实际到期余额到期。只有这些帐户才能打开PDF。此时数据导入问题?
我有一组CF函数,其中从数据库记录生成新的PDF,并在用户帐户上提供下载或查看。代码在几周前一直运行良好,但现在新的或旧的(以前的每月账单)PDF将不会在用户帐户页面上打开(损坏)。记录数据尚未更改或修改。这可能是CF更新问题或者什么原因导致文件现在生成损坏?任何帮助表示赞赏。
PDF分析损坏的PDF文件给出:
PDF错误:
打开文件。 0x80410108 - E - 找不到文件结束标记。 - 文件:11118749.pdf 0x8041010A - E - 未找到“startxref”关键字或外部参照位置。 - 文件:11118749.pdf 0x80410108 - E - 找不到文件结束标记。 - 文件:11118749.pdf 关闭文件。
CF PDF生成代码:
<cfcomponent>
<!---***************************************************************************--->
<cffunction name="getBill" access="public" returntype="query">
<cfargument name="billID" required="yes" default="">
<cfquery name="getPayment" datasource="#application.dsnName#" username="****" password="****">
SELECT * FROM ccos_cust_bill
WHERE billID = <cfqueryparam cfsqltype="cf_sql_integer" maxlength="20" value="#arguments.billID#">
</cfquery>
<cfreturn getPayment>
</cffunction>
<!---***************************************************************************--->
<!---***************************************************************************--->
<cffunction name="getCustBills" access="public" returntype="query">
<cfargument name="accountNum" required="yes" default="">
<cfquery name="getCustBills" datasource="#application.dsnName#" username="****" password="****">
SELECT * FROM ccos_cust_bill
WHERE accountNum = <cfqueryparam cfsqltype="cf_sql_integer" maxlength="20" value="#arguments.accountNum#">
ORDER BY billDate DESC, billID DESC
</cfquery>
<cfreturn getCustBills>
</cffunction>
<!---***************************************************************************--->
<!---***************************************************************************--->
<cffunction name="addBill" access="public" returntype="string">
<cfargument name="formvalues" required="yes" default="">
<cfquery name="addBill" datasource="#application.dsnName#" username="****" password="****">
INSERT INTO ccos_cust_bill (billID, accountNum, billDate, dueDate, billTotal)
VALUES (
<cfqueryparam cfsqltype="cf_sql_integer" maxlength="20" value="#arguments.formvalues.billID#">,
<cfqueryparam cfsqltype="cf_sql_integer" maxlength="20" value="#arguments.formvalues.accountNum#">,
<cfqueryparam cfsqltype="cf_sql_date" maxlength="20" value="#DateFormat(arguments.formvalues.billDate, "yyyy-mm-dd")#">,
<cfqueryparam cfsqltype="cf_sql_date" maxlength="20" value="#DateFormat(arguments.formvalues.dueDate, "yyyy-mm-dd")#">,
<cfqueryparam cfsqltype="cf_sql_decimal" scale="2" maxlength="20" value="#arguments.formvalues.billTotal#">
)
</cfquery>
<cfset addOK = "Y">
<cfreturn addOK>
</cffunction>
<!---***************************************************************************--->
<!---***************************************************************************--->
<cffunction name="getBillPDF" access="public" returntype="query">
<cfargument name="billID" required="yes" default="">
<cfargument name="accountNum" required="yes" default="">
<cfquery name="getPayment" datasource="#application.billsDsnName#" username="****" password="****">
SELECT * FROM ccos_bills
WHERE billID = <cfqueryparam cfsqltype="cf_sql_integer" maxlength="20" value="#arguments.billID#">
AND accountNum = <cfqueryparam cfsqltype="cf_sql_integer" maxlength="20" value="#arguments.accountNum#">
</cfquery>
<cfreturn getPayment>
</cffunction>
<!---***************************************************************************--->
<!---***************************************************************************--->
<cffunction name="getNextDueDate" access="public" returntype="string">
<cfargument name="accountNum" required="yes" default="">
<cfquery name="getNextDueDate" datasource="#application.dsnName#" username="****" password="****" maxrows="1">
SELECT dueDate FROM ccos_cust_bill
WHERE accountNum = <cfqueryparam cfsqltype="cf_sql_integer" maxlength="20" value="#arguments.accountNum#">
AND dueDate >= <cfqueryparam cfsqltype="cf_sql_date" maxlength="20" value="#DateFormat(now(), "yyyy-mm-dd")#">
ORDER BY dueDate
</cfquery>
<cfreturn getNextDueDate.dueDate>
</cffunction>
<!---***************************************************************************--->
</cfcomponent>
CF查看PDF代码:
<cfparam name="URL.billID" default="">
<cfset getBillPDF = application.billCFC.getBillPDF('#URL.billID#','#session.accountNum#')>
<cfif getBillPDF.RecordCount GT 0>
<cfoutput query="getBillPDF">
<cfset fileData = "#BinaryDecode(billData, "Base64")#">
<cfheader name="content-disposition" value="inline; filename=#billID#.pdf" />
<cfcontent type="application/pdf" variable="#fileData#" />
</cfoutput>
<cfelse>
You are not authorized to view this bill.
</cfif>
PDF导入数据库
<!--- CCOS Bill PDF Data --->
<cfquery name="deleteData" datasource="#application.billsDsnName#" username="#application.billsDsnUser#" password="#application.billsDsnPass#">
DELETE FROM ccos_bills WHERE billDate < '#DateFormat(DateAdd("d", -180, now()), "yyyy-mm-dd")#'
</cfquery>
<!--- Check to see how many files Exist --->
<cfdirectory action="list" directory="#ExpandPath('.')#\files" name="filelist">
<cfset fileCount = 0>
<cfoutput query="filelist">
<cfif name CONTAINS "ccos_cust_bill_pdf"><cfset fileCount = fileCount + 1></cfif>
</cfoutput>
<!--- Loop over the files and Load the new data --->
<cfloop from="1" to="#fileCount#" index="i">
<cfquery name="insertData" datasource="#application.billsDsnName#" username="#application.billsDsnUser#" password="#application.billsDsnPass#">
LOAD DATA LOCAL INFILE '#Replace(ExpandPath('.'), "\", "\\", "ALL")#\\files\\ccos_cust_bill_pdf#i#.txt' IGNORE
INTO TABLE `ccos_bills`
FIELDS OPTIONALLY ENCLOSED BY '"'
TERMINATED BY '|'
<!---IGNORE 1 LINES--->
(`accountNum`, `billID`, `billDate`, `billData`);
</cfquery>
</cfloop>
<cfquery name="fixbillDate" datasource="#application.billsDsnName#" username="#application.billsDsnUser#" password="#application.billsDsnPass#">
UPDATE ccos_bills SET dateCreated = '#DateFormat(now(), "yyyy-mm-dd")#' WHERE dateCreated IS NULL
</cfquery>
<!---***********************************************************************************--->