0
我想用django的表單數據填充生命週期創建表單。現在我想我已經正確地完成了代碼,但是我對生命週期表單的結構感到困難。目前我有能力使用Adobe Acrobat創建pdf,但不能生成循環。對於生命週期是否有某種文件結構?用Django填充生命週期表格
下面是函數調用我填補了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:在我的views.py
def fdf_val_str(field, val):
val = str(val).replace('&','&')
return '<field name="%s"><value>%s</value></field>\n' % (field, val)
我的客戶編輯功能:
@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)
任何幫助將不勝感激
感謝您的答覆。我會尋找關於基於XFA的表格的幫助 – TheLifeOfSteve
你能解釋一下這是怎麼完成的。它似乎不像Livecycle可以自動執行此操作.. – kefeizhou
如果您有權訪問LiveCycle服務器,它將起作用。這是另一種解決方案,與LiveCycle Designer不同。 – azathoth