【问题标题】:Filling Livecycle form with Django使用 Django 填写 Livecycle 表单
【发布时间】:2011-11-14 14:44:57
【问题描述】:

我正在尝试使用来自 django 的表单数据填充一个 livecycle 创建的表单。现在我认为我已经正确完成了代码,但是我很难处理 livecycle 表单的结构。目前,我能够填充用 adobe acrobat 创建的 pdf,但不能填充 livecycle。 livecycle有一定的文件结构吗?

这是我用来填充 pdf 的函数:

def print_rdba(client=None, data=None, investment_form=None):
from django.http import HttpResponse
from clients.models import Client
from dateutil.parser import parse
from settings import URL
from datetime import date
file = ''
print data
fdf = '<?xml version="1.0" encoding="UTF-8"?>\n<xfdf xmlns="http://ns.adobe.com/xfdf/" xml:space="preserve">\n\t<fields>'
fdf += fdf_val_str("primary1_lastname", data.get('lastname'))
fdf += fdf_val_str("primary1_firstname", data.get('firstname'))

if investment_form:
    file = "%s%s" % (URL, investment_form.file.url)

fdf += '''</fields>
    <f href="%s" target="_blank"/>
    </xfdf>''' % file

fdf = fdf.replace('^M', '')

response = HttpResponse(fdf.encode("ISO-8859-1"), mimetype='application/pdf')
response['Content-Disposition'] = 'attachment; filename=form.xfdf'
return response

这里是 fdf_val_str:

def fdf_val_str(field, val):
val = str(val).replace('&','&amp;')
return '<field name="%s"><value>%s</value></field>\n' % (field, val)

我的客户在我的views.py中编辑功能:

@login_required
@user_passes_test(lambda u: u.is_staff or u.rep_set.get().add_clients, login_url='/')
def edit(request, client=None, *args, **kwargs):
from clients.forms import ClientForm
from entity.forms import LocationForm
from investments.models import InvestmentForm
from lib.tools import print_rdba
...
rdba_btn = InvestmentForm.objects.get(id=3)
context = {}
...
if request.POST.has_key('submit-%s' % rdba_btn.code):
            request.user.message_set.create(message='Generating PDF form')
            return print_rdba(client=client, data=form.data, investment_form=rdba_btn)

任何帮助将不胜感激

【问题讨论】:

    标签: python django pdf livecycle pisa


    【解决方案1】:

    您是否安装了 LiveCycle Forms?然后,您可以使用 DJango 生成 XML 数据并将其发送到 LiveCycle 以呈现 PDF 表单

    编辑: 您应该注意到 LiveCycle Designer 生成基于 XFA 的表单,这与 XFDF 不同

    【讨论】:

    • 感谢您的回复。我将寻求有关基于 XFA 的表单的帮助
    • 你能解释一下这是怎么做到的吗?似乎 livecycle 不能自动执行此操作..
    • 如果您可以访问 LiveCycle 服务器,它将起作用。这是另一种解决方案,不同于 LiveCycle Designer。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2015-08-10
    • 2020-12-31
    • 2018-10-12
    • 2016-03-24
    • 2018-10-26
    • 2011-10-15
    • 2013-01-08
    相关资源
    最近更新 更多