我正在尝试使用来自django的表单数据填充生态周期创建的表单。现在我认为我已经正确完成了代码,但是我对生命周期表单的结构很难。目前我有能力填充用adobe acrobat创建的pdf,但不能生成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('&','&')
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)
非常感谢任何帮助
答案 0 :(得分:-1)
您是否安装了LiveCycle Forms?然后,您可以使用DJango生成XML数据并将其发送到LiveCycle以呈现PDF表单
编辑: 您应该注意到LiveCycle Designer生成基于XFA的表单,这与XFDF不同