Expand my Community achievements bar.

Don’t miss the AEM Skill Exchange in SF on Nov 14—hear from industry leaders, learn best practices, and enhance your AEM strategy with practical tips.

Using Adobe LiveCycle Designer with ASP.NET to populate PDF Forms from Server Database.

Avatar

Level 8

[Thread Edited By Adobe]

/*Don’t forget to meet and greet your fellow peers virtually by telling them about yourself here

Go ahead and to it now: https://adobe.ly/3eDnB4v */

 

Actual Question:

With Google, I did a very very long search on how to use Adobe LiveCycle Designer to design Interactive/Dynamic Forms, and publish them to the IIS Server and use ASP.NET to populate such forms with field values from back-end Database such as SQL Server.



We are designing and implementing Electronic Forms ASP.NET Application that must detect the user currently logged in to the Windows Intranet (under IIS), and should perform a Look-up to the Back-End Database to extract the User Related Data and Populate the Form Fields to start the Form Processing.



We have the following facts:

1. The forms will be designed using Adobe LiveCycle Designer 7.1.



2. We will NOT use Adobe LiveCycle Forms since it is not on our budget yet.



3. The users will have the required Adobe Acrobat version on the Client PC.



In a typical scenario, the user would go through these steps:



1. The user logs on to the Intranet using his Windows Login ID and Password. Then he starts the APS.NET Application for Forms Processing.



2. He will request a form to fill. The form may be populated with sensitive information such as Salary and only the requesting user must be able to see his Salary on any form.



3. On the server side, the system will use the User Windows ID to perform a query against the Back-End Database and generate the required XML Data.



4. The system must then link/merge the generated XML Data with the requested form and render (post) the form back to the user for further printing and/or submitting via email.



That's it !



I found an add-in product "Adobe LiveCycle® Designer add-in for Microsoft Visual Studio .NET" but it only wraps XPD forms in Visual Studio Component which is not of a great help to my requirements.



If any one could give me any hint on how to implement such requirements.



I truly appreciate any help.



Tarek.

275 Replies

Avatar

Level 1

Hi. I came across this thread from a search engine query and seems to have the best information in relation to the topic I was searching for. I am currently evaluating Acrobat Pro X and LiveCycle designer to see if it can replace some client-side reporting components. I created a dynamic form using LiveCycle Designer ES and would like to use it as a template for loading dynamic data from a database. I created an XDP file referencing the dynamic PDF with some of the field data defined. I can open the XDP file using Acrobat Reader and it renders correctly. I then tried to open the XDP file using Interapplication Communication through Visual C# and received the message "File does not begin with '%PDF-'". Would there be any other way to load an XDP file using Reader in an ActiveX control? Printing would be the only requirement after the form is rendered. Thanks.

Avatar

Former Community Member

Well, what I did is to create PDF files over the air. So every time when the user click a link on our website, the data got retrieved from the database and bind with the template created in the LiveCycle. And then the browser got fired up and open the PDF in it. After the user close the web page, the PDF does not exist anymore. To get there, we read the XDP file line by line and bind with the data whenever it need, after creating a PDF, we close the XDP file and return the PDF to the user.

Ray

Avatar

Level 8

In order to convert XDP whic is text to PDF which is binary so that you can open it from reader or acrobat directly you must:

1. submit the form from IE using javascrip from inside PDF to ASPX page, extract the chunk xml, covert it to binary using Base64 encoding, and save it as PDF.

or

2. Use Adobe LC ES services to convert XDP to PDF.

I have done it using step 1. Some one else done it using step 2.

You cannot open XDP from reader or acrobat.

I hope this helps.

Tarek.

Avatar

Level 1

I can open an XDP file using Reader currently. The file just holds the XML data and reference of my dynamic PDF designed in LiveCycle Designer. It just won't open when using Reader in an ActiveX control. I was told to use a browser control instead, but when I try that it will launch Reader externally instead of displaying the filled out PDF in the control. My goal is to load the dynamic PDF in a tab control for preview and print. Thanks.

Avatar

Former Community Member

Try merging the PDF with the XDP or XFDF first, and then populate the ActiveX control with the PDF binary byte array or the file name.

You can use FDFToolkit.net, a Microsoft .net PDF programming library that uses iTextSharp, to merge XFDF/XDP/FDF/XML data with an Acrobat Form or with a Static LiveCycle form in local or remote web servers or standalone Microsoft .net applications.

Useful links:

http://www.fdftoolkit.net

http://www.nk-inc.com/software/fdftoolkit.net/examples/

http://www.nk-inc.com/blog/

If you have any questions, please use the contact form on our site.

http://www.nk-inc.com/support/sales/

Avatar

Level 2

Hello

Is this thread still live?

I hope so because I'm tearing my hair out here.

Kind regards,

Andy

Avatar

Level 2

Hello Tarek.  Thank you for taking the time out to reply.


I'm having trouble loading data back into a PDF created by LiveCycle designer (from Acrobat X pro).  I've got no trouble pulling data out.  The server is IIS and the code is classic ASP.  I've read every post and followed all the examples thus far in this great thread.


Here's what I've done.  I've included my code too just in case someone else stumbles this way.


1) In LC create a blank PDF. Create a simple XML file then create a data connection to the XML file.  Create text box elements for each field in the XML.  Include an HTTP submit button pointing to an ASP page we'll call

page1.  Save the PDF.  I've done it this way to ensure that I didn't mess up the naming of the form fields.


2) Page1.asp uses the ASP request object to read the form collection coming in from the PDF.  It creates an HTML form with input boxes for each element so I can change the values before I pass them onto the next page.  This

works just fine.
<%
response.write "<form name='mainForm' id='mainForm' method='post' action='createXDP.asp'><code><table><thead><tr><th>Field</th><th>Value</th></tr></thead><tbody>"

for each oObject in request.Form
response.write "<tr><td>" & oObject & "</td><td><input type='text' name='" & oObject & "' value='" & request.form(oObject) & "' /></td></tr>"
next
set oObject=nothing

response.write "</tbody></table></code><br/><input type='submit' value='Show PDF again' /></form>"
%>


3) Page1.asp is submitted to the next ASP page, 'createXDP.asp'.  This generates the XDP string as per examples in this thread.
<%
txtName = trim(request.form("txtName"))
txtCCV = trim(request.form("txtCCV"))
txtCardNumber = trim(request.form("txtCardNumber"))
txtExpires = trim(request.form("txtExpires"))


xdp = "<?xml version=""1.0"" encoding=""UTF-8""?>"

'COMMENTxdp = xdp & "<?xfa generator=""XFA2_0"" APIVersion=""2.2.5028.0""?>"
'COMMENTxdp = xdp & "<?xfa generator=""AdobeDesigner_V7.0"" APIVersion=""2.2.4333.0""?>"
'COMMENTxdp = xdp & "<?xfa generator=""AdobeLiveCycleDesignerES_V9.0.0.2.20101008.1.734229"" APIVersion=""3.1.20001.0""?>"
xdp = xdp & "<?xfa generator=""XFA2_4"" APIVersion=""3.3.10270.0""?>"


xdp = xdp & "<xdp:xdp xmlns:xdp=""http://ns.adobe.com/xdp/"">"
xdp = xdp & "<xfa:datasets xmlns:xfa=""http://www.xfa.org/schema/xfa-data/1.0/"">"
xdp = xdp & "<xfa:data>"


xdp = xdp & "<main><txtName>" & txtName & "</txtName><txtCCV>" & txtCCV & "</txtCCV><txtCardNumber>" & txtCardNumber & "</txtCardNumber><txtExpires>" & txtExpires & "</txtExpires></main>"


xdp = xdp & "</xfa:data>"
xdp = xdp & "</xfa:datasets>"
xdp = xdp & "<pdf href=""http://localhost/_andy/pdf/xdp/testXDP.pdf"" xmlns=""http://ns.adobe.com/xdp/pdf/"" />"
xdp = xdp & "</xdp:xdp>"


response.contentType = "application/vnd.adobe.xdp+xml"
response.write xdp

Response.Flush
Response.End
%>

Avatar

Level 2

... continuation of message ...


The PDF loads but doesn't show any data.  Incidentally I get the 'open'/'save' dialog which I just can't shift either.


You'll see I been experimenting with different 'generators' in the vein hope something would happen.  I've added the MIME type .xdp to my IIS server and attempted to change the PDF once created with LC to have 'reader extensions' added by amending the PDF with Acrobat X.  This didn't work either.


Can you see anything I'm missing?  Would you be able to provide me with a simple test PDF file that is known to work so I can test my code?  If so, can you let me know what you did to the PDF after it left LiveCycle Forms designer?


Many thanks for any input or advice.


With kind regards,
Andy

Avatar

Level 2

... additional

I've also opened the PDF created with LC Designer in Acrobat X, filled in the form and exported the data to XML to check I have the correct tags.  Aside from carriage returns it's correct.

I can't see what I'm doing wrong.

Kind regards,

Andy

Avatar

Level 8

Hi Andy,

I will try to help by asking you to try several steps:

1. Make sure you have clean installation of Adobe Acorbat X and remove all previous versions of Acorbat / Reader. Restart your PC.

2. Acrobat has new security feature which by default prevents you from using XDP (merge XFA with XML Data on the client). Goto Preferences/security/advanced and search for this option as I cannot remember it 100%. You have to disable this option.

3. While you are generating the XDP String from ASP Code, try to capture the XMLstring during a debug session only for the <main> tag and all its inner xml. Create XML file using Notepad.exe and make sure to put the first line for XML Declaration (which you will see when you export the form data from Acrobat). Then using Acrobat, open the blank PDF Form and using Import Data to import the XML and see the result. If you can see that the form is populated properly, then your code is generating the XML properly. Also, you can fill the form manually from Acrobat, and use Export Form Data to XML, and then you can examine the XML result which then you have to use as a guide to generate the required XML from ASP Code.


For now, let me know how it goes.

Tarek.

Avatar

Level 2

Hi Tarek

Thanks for your reply.  Thanks indeed.

I tried option 3 earlier this morning (UK time) and it does import data into the PDF using the import option in Acrobat.

I'll have a look at option 2 later.  It's actually an avenue I was thinking of exploring whilst on the way home tonight - that perhaps it has something to do with my machine having LC Forms Designer installed and some confusion with what to do with an XDP file.

Thanks again and I'll let you know how I get on.  Have a great weekend.

Best regards,

Andy

Avatar

Level 2

Ha ha.

I've just copied my files to my server at home and guess what ... it's working.  I'm overjoyed :O)

T H A N K   Y O U

If only you had a dollar for everone you helped eh?

Cheers!  I really appreciate your time.

Best regards,

Andy

Avatar

Level 8

I am really happy you solved your problem, Andy !

For all who are interested, I have finalized the development of a generic .NET 2.0 (VS 2005) Class which you can use to work woth Adobe LiveCycle ES Form. All the generic code is encapsulated in the main class which can inherit to define more custom functions. I built the class based on CSLA .NET Framework.

I have included email notification and simple workflow (not based on .NET Workflow).

I also developed a Generic Workflow process on PDF (client side) using Javascript which works very well for 2 approval steps, and can be extended easily for more steps.

If anyone is interested, I will post the details.

Tarek.

Avatar

Level 1

Tarek: Yes, I am interested too, please share it, if You can.

I am just in the middle of suicide because of form template (PDF v1.6) made in Adobe LiveCycle Designer ES 8.2...

I haven't been able to adress any dynamic field using iTextSharp and I spent the rest of my day by searching (and then reading Your helpful posts)

Thanks.

Avatar

Level 8

Hi to all...

I will start with this:

https://docs.google.com/leaf?id=0B97clwYte2SHYWE1M2QyMzYtYTM0ZC00NTNlLWE0ZTMtMjAzNmRkNDYwODk3&hl=en_...

Hope it will be a good start !

Let us work together to create a great Final Product.

Tarek.

Avatar

Former Community Member

Hi Tarek,

Your posts are very helpful. I would say it is one of the best posts I've seen after 2 days going through this forum.

Anyhow, I have a question for you regarding to populating a dropdownlist in the PDF using C sharp. It seems straight forward with the regular text field but I am still puzzling about the dropdownlist. Any tips would be very much appreciated.

Banh

Avatar

Level 1

Hi Tarek

I have another question for you - I see this is the thread where all the good stuff is

I have a pdf form where users fill in their information. When the form is finished the user click a button and the form is send to a webservice, as base64, that archives the pdf.

This all works very well, but the problem is that even if I hide all the buttons before i convert it to base64, the buttons are visible again, when the document is transformed back to a pdf. I tried using both "hidden" and "invisible"

Is there any way to make sure that the buttons does not reapear ?

I also tried using a liveCycle webservice to accept the base64 and transform it to flattened pdf, but the buttons still reapear.... 

Hope it makes sense - thanks