Frage

I am trying to fill a livecycle created form with form data from django. Now I think I have the code done correctly but I am having a hard time with the structure of the livecycle form. Currently I have the ability to populate pdf's created with adobe acrobat but not livecycle. Is there a certain file structure for livecycle?

Here is the function I call to fill the 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

Here is 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)

My clients edit function in my 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)

Any help would be much appreciated

War es hilfreich?

Lösung

Do you have LiveCycle Forms installed? You could then generate the XML data with DJango and sending it to LiveCycle to render the PDF Form

edit: And you should notice LiveCycle Designer generates XFA-based forms, which differ from XFDF

Lizenziert unter: CC-BY-SA mit Zuschreibung
Nicht verbunden mit StackOverflow
scroll top