【问题标题】:In ColdFusion, can I rename a PDF Form Field with CFPDF?在 ColdFusion 中,我可以使用 CFPDF 重命名 PDF 表单域吗?
【发布时间】:2009-11-25 05:28:05
【问题描述】:

我们有包含标准 PDF 表单的 PDF。我们想合并它们并同时将数据填充到字段中。

问题是有时我们可能会将同一个文档合并到最终文档中。

有没有办法重命名 PDF 中的字段(附加 __#),这样重复的文档就不会冲突?

我可以用 iText 代码做到这一点,我正在测试 CFPDF/CFPDFFORM 代码以摆脱 iText。

【问题讨论】:

    标签: coldfusion


    【解决方案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)#">
    

    【讨论】:

    • 谢谢。不幸的是,我们不想将它们展平,以便用户在下载后可以对其进行编辑。
    猜你喜欢
    • 2014-08-06
    • 1970-01-01
    • 1970-01-01
    • 2014-09-15
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2022-12-19
    相关资源
    最近更新 更多