首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >CF中多个PDF生成的错误

CF中多个PDF生成的错误
EN

Stack Overflow用户
提问于 2014-09-17 02:38:02
回答 2查看 785关注 0票数 1

我在生成多页PDF时出错了。

不为cfpdf标记.中的合并操作指定pages属性。

引起问题的行是:<cfpdf action="merge" source="#ArrayToList(variables.pdfList)#" destination="promega.pdf" overwrite="yes" />

我试着查看Adobe,找不到合并操作的属性pages。有什么想法?

代码语言:javascript
复制
        <!--- Append PDF to list for merge printing later --->
        <cfset ArrayAppend(variables.pdfList, "#expandPath('.')#\general.pdf") />

        <cfset variables.userAgenda = GetAttendeeSchedule(
            variables.event_key,
            variables.badgeNum
        ) />


        <!--- Field CFID is the id of the agenda item; use this for certificate selection --->
        <cfif variables.userAgenda.recordcount>
            <cfloop query="variables.userAgenda">
                <cfset variables.title = Trim(variables.userAgenda.CUSTOMFIELDNAMEONFORM) />

                <cfpdfform source="#expandPath('.')#\promega_certificate.pdf" destination="#cfid#.pdf" action="populate">

                        <cfset variables.startdate = replace(CUSTOMFIELDSTARTDATE, "T", " ") />

                        <cfpdfformparam name="WORKSHOP" value="#variables.title#">
                        <cfpdfformparam name="NAME" value="#variables.badgeInfo.FirstName# #variables.badgeInfo.LastName#">
                        <cfpdfformparam name="STARTDATE" value="#DateFormat(variables.startdate, "medium" )#">

                </cfpdfform>

                <!--- Append PDF to list for merge printing later --->
                <cfset ArrayAppend(variables.pdfList, "#expandPath('.')#\#cfid#.pdf") />
            </cfloop>
        </cfif>

        <cfif ArrayLen(variables.pdfList)>
            <cfpdf action="merge" source="#ArrayToList(variables.pdfList)#" destination="promega.pdf" overwrite="yes" />
            <!--- Delete individual files --->
            <cfloop list="#ArrayToList(variables.pdfList)#" index='i'>
                <cffile action="delete" file="#i#" />
            </cfloop>
            <cftry>
                <cffile action="delete" file="#expandPath('.')#\general.pdf" />
                <cfcatch></cfcatch>
            </cftry>
            <cfheader name="Content-Disposition" value="attachment;filename=promega.pdf">
            <cfcontent type="application/octet-stream" file="#expandPath('.')#\promega.pdf" deletefile="Yes">

            <cflocation url="index.cfm" addtoken="false" />
        </cfif>
EN

回答 2

Stack Overflow用户

回答已采纳

发布于 2014-09-19 09:47:34

我在我的coldfusion 9机器上尝试了以下操作,它运行得很好:

代码语言:javascript
复制
<cfset strPath = GetDirectoryFromPath(GetCurrentTemplatePath()) />
<Cfset pdflist = arrayNew(1)>
<Cfset pdflist[1] = "#strPath#page1.pdf">
<Cfset pdflist[2] = "#strPath#page2.pdf">

<cfpdf action="merge" source="#ArrayToList(pdflist)#" destination="#strPath#merged.pdf" overwrite="yes" />

您可以尝试像这样合并页面并检查是否仍然有错误:

代码语言:javascript
复制
<cfset strPath = GetDirectoryFromPath(GetCurrentTemplatePath()) />
<Cfset pdflist = arrayNew(1)>
<Cfset pdflist[1] = "#strPath#page1.pdf">
<Cfset pdflist[2] = "#strPath#page2.pdf">

<cfpdf action="merge" destination="#strPath#merged.pdf" overwrite="yes">
    <Cfloop from=1 to="#arraylen(pdflist)#" index="x">
    <cfpdfparam source="#pdfList[x]#">
    </cfloop>
</cfpdf>
票数 0
EN

Stack Overflow用户

发布于 2015-06-24 19:11:10

当源是单个文件而不是逗号分隔的文件列表时,就会发生这种情况。我猜想,如果它是一个文件,是希望提取一些页面,而不是添加。

票数 2
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/25881393

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档