2009-10-19 34 views
2

我們有包含標準PDF格式的PDF文件。我們想合併它們並同時將數據填入字段中。在ColdFusion中,我可以使用CFPDF重命名PDF Form Field嗎?

問題是,有時我們可能會將多個文檔合併到最終文檔中。

有沒有辦法重新命名PDF中的字段(Attach __#),以便重複的文檔不衝突?

我可以用iText代碼做到這一點,我正在測試CFPDF/CFPDFFORM代碼來擺脫iText。

回答

1

您無法使用cfpdf或cfpdfform重命名字段。在合併之前,您可以通過填充和展平每個表單來解決問題。

這裏有一個簡單的例子:

<!--- populate each form ---> 
<cfloop from="1" to="#arrayLen(files)#" index="i"> 
    <cfset destination = "#i#.pdf" /> 
    <!--- fill in form fields ---> 
    <cfpdfform 
     action  = "populate" 
     source  = "#pdf_source_file#" 
     destination = "#destination#" 
    > 
     <!--- form params here ---> 
    </cfpdfform> 

    <!--- flatten file ---> 
    <cfpdf 
     action  = "write" 
     source  = "#destination#" 
     destination = "#destination#" 
     flatten  = "yes" 
    /> 
</cfloop> 

<!--- merge flattened files ---> 
<cfpdf action="merge" name="output"> 
    <cfloop from="1" to="#arrayLen(files)#" index="i"> 
     <cfpdfparam source="#i#.pdf"> 
    </cfloop> 
</cfpdf> 

<!--- return the full pdf ---> 
<cfcontent type="application/pdf" reset="true" variable="#toBinary(output)#"> 
+0

感謝。不幸的是,我們不想將它們弄平,以便用戶可以在下載後編輯它們。 – 2009-11-25 11:48:25

相關問題