Expand my Community achievements bar.

Dive into Adobe Summit 2024! Explore curated list of AEM sessions & labs, register, connect with experts, ask questions, engage, and share insights. Don't miss the excitement.

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

Former Community Member
Thanks alot Tarek, you have been really helpfull...I only expect my clients to fill out the pdf(with reader) and hit submit...so all the work is done by ASP.....



Also thanks for confirming my logic....I can now google around for some sample code, and when I get it to work...I will post it here for others to view...



Many thanks again



Charlie

Avatar

Former Community Member
Hi Tarek,



I am hoping you can help me out, I am trying to create a javascript language in Adobe Livecycle 8 that will populate the body of the form based on the user selections made at the beginning of the form.



These "weeder" or deciding selections will be based on department, value, and code. I then want there to be a "submit data" button that will populate the body of the form based on the user's responses.



The body options will be pre-created as a .pdf file and will be "Option1", "Option 2", "Option 3", etc.



So, for example, if the user selects:



Dept 1, value A, Code 1 = Option 1

Dept 1, value B, Code 1 = Option 2

Dept 2, Value A, Code 2 = Option 3



there are other variables, but that is the jist of it. Can you help me with what language I would put into that "submit data" button that would accomplish this goal? ANY help you can provide woudl be GREATLY appreciated!!!!!



Thanks,



Kelli

Avatar

Level 8
Dear Kellster,



I a now on my vaction and posting form internet cafe. I will try to help you now by giving you quick hints, and as soon as I am ready, I will post more details for you (I will be back to the office in 2 weeks).



Keep in mind that I am familiar with LiveCycle Desinger 7.1, and not yet used version 8.x.



What you are asking for can be done by some "not so easy" client javascript under PDF. But, I can give you the following guidelines:



1. Place the complex processing (Business Logic) and programming in a back-end Web Service using .NET for example (Use .NET or Java NetWeaver for Business Logic). This way, your code will be extreemly re-usable in the current recent client-side technologies such as Adobe Forms. In this Business Logic Layer, do not place UI related code.



Also, you must desing your program to be at least on 2 tiers. If you follow 3-tiers, then the 3rd layer is the Database.



.NET Development Platform is very productive, very easy and very powerful and the same can be applied to Java-Based Development Platofrms (I am familiar with .NET Technologies).



2. From PDF Form (as the Presentation Layer), use the Web Service Connection and call the web service to perform the required processing, and get the results in the form variables.



3. Once you get the required results, on the client side, use JavaScript to perform some simple Layout related processing (as this is the Presentation Layer). As per my understanding, all you need to do is to show/hide some UI Elements, and perform some kind of population for some Drop-Down or List Elements. Keep UI as simple and as small as possible.



4. Decompose the PDF Form into logical UI Parts, and place each part in a Subform Element. This will make it easier to show/hide group of elements.



It is very easy to use Web Service from PDF form, I have tested it with a .NET Web Service, and it worked from the first time. Also, keep in mind that you can use Free Development Tools from Microsoft for .NET Development.



For my Leave Form Application (which is documented earlier in this post) I have some complex Date Processing requirements (with Hijri/Gregorian Calendar), and I am planning to use .NET Web Service for such pricessing in the next version.



I hope this will be helpful.



Tarek.

Avatar

Former Community Member
Charlie Taminian, did you find a VBScript/ASP solution to users submitting a PDF from Acrobat Reader to your IIS server and then sending the PDF as an email attachment? This is exactly what I want to do. Code examples or links to the solution would be greatly appreciated. Thanks.

Avatar

Former Community Member
hi i have exported the PDF filled forms as XML through email option. And i used that XML to populate into a Database. But i want to save the XML directly into my system asking for a location without having a Email option. If anyone could help me please let me know. Also in previous message TAREK has sent a script. I dont know how to use that. I have created a web application and its in my local system. How do i get the XML copied to that location or to web server...

Avatar

Level 8
>Also in previous message TAREK has sent a script. I dont know how to use that. I have created a web application and its in my local system.



I will try to help !



First option you can do that is to using Client Based Process with Acrobat SDK under VB.NET. Check this link for complete detail:



http://www.adobeforums.com/webx?128@@.59b4be28



Another option is to create a Submit Button from the LiveCycle PDF Form, to submit the form with the Data Set and PDF as XDP to an ASP.NET Web Page, and in the web page, you can extract the XML Data Set and the PDF as Base 64 Binary Format from the Request Input Stream. You can convert the XML String to XML Document and then to .NET Dataset Object, and then it is purely a .NET Program. It is then much easier to post the Data from a Dataset Object to the Database Tables. Also, you do not need to convert to Dataset Object, and you can use XML Document Object APIs to extract Data Fields directly.



From you post, is seems you want to save the XML to a File, and then post it to the Database. You could do that, and the .NET XML Doc Object APIs has a method to do that also.



If you review the code I posted earlier (JavaScript and ASP.NET) you should be able to find the parts related to you. The only part which is not there is to save the XML to the disk.



Please let me know if this is OK for you.



Tarek.

Avatar

Level 8
>hi i have exported the PDF filled forms as XML through email option. And i used that XML to populate into a Database.



Saravanan_P,



I would like to know what method you used to post the XML to Database. Please give as much details as you could.



Tarek.

Avatar

Former Community Member
Hi Tarek,



I have a requirement to display contracts in PDF.

I am using Adobe 8 professional version on my server.I designed the PDF forms in livecycle designer.

I am trying to send the contract id from .net application to PDF and to display the contract for this Id with the information from Sql server.



I am new to livecycle and a little bit confused. How do I pass this ID parameter from .net to pdf form ? Can I do that ?

I am presently using Scripts to populate the fields in PDF forms in Livecycle,since I have to display dynamic table of data in contracts.



What i am trying to do is keep the whole processing like accessing procedures, tables etc in pdf script .I don't know how to pass the id parameter and capture this ID paramter in Livecycle javascript to display the data. Can you help me .IS there a better way of doing this ?

Avatar

Level 8
vidya radhakrishnan,

If I understand you correctly, you want to design a process to lookup contract data using Contract ID, and display the contract details in PDF for the purpose of printing it or viewing via web access. Correct ?

Follow these steps:

1. Design an ASP.NET form to accept the Contract ID which the users requires to print/view its details.

2. Design a button, and on Click Event in UI Code, open a connection to the SQL Database and retrieve the require details and place them in program variables and/or arrays/lists/dataset depending on the data structure of the contract info and related details. This is a extra step, but it is good for debugging purposes.

3. Use a String Variable to build the XML Data Package (XDP) which has the Header, Data and Footer in the same way I described earlier in this thread. The Header is always fixed, the Data part is variable, and is the XML representation of the Contract Details in a structured format, and the footer, has a pointer to the LiveCycle PDF Form in URL format.

3. The data has to be composed in XML String following a certain format. For example, flat details (non-repeating elements), must follow the formate below:


value
...

where:
'variable name' is the name of the LiveCycle Field.
'subform-name' is the name of the subform which has the field 'varaible-name'

For repeating elements (or arrays/lists/datasets in ASP.NET), must follow this format:



value 1
value 2
value 3
...


value 1
value 2
value 3
...


value 1
value 2
value 3
...



where:
'row' is the name of the repeating subform in LiveCycle,
'variable-n' is the field inside the repeating subform.

IMPORTANT:

I was thinking that you could use DataSets in ASP.NET to populate the required data elements in the same structure of the PDF Form, and build the relationships among the DataTables inside the DataSets, and then use "getXML()" api to convert DataSet to XML and using nested structure property of the DataSet or something like that, you will get a properly formatted XML output without the need to compose the string one element at a time. I have not tried this myself, and you could give it a try and let me know.

4. Make sure to design the object hierarchy in LiveCycle Designer to match the same XML Structure you are using in ASP.NET and make sure to use same field names. This way, you will not need to do manual binding inside LiveCycle. The binding in this case will be automatic.

5. Using "Response.ContentTye" at the beginning and "Response.Write(XDP_String)/response.end" to push the final XML Result to the client so that Adobe Reader/Acrobat on the client will be able to display the PDF and merge the data with the fields.

I hope this is clear.

Tarek.

Avatar

Former Community Member
Thanks Tarek,



You have given me a detailed explanation of solving my issue.This is really helpful for me. I don't have much experience with XML,I will work on it.Just out of curiosity,I came to know i can use scripting in livecycle forms when designing,



* Instead of collecting data from sql database in .net and passing

the XDP to pdf. Can I pass the contractId from .net and based

on this id using scripting objects in livecycle forms can i display

the data?I could do this to some extent like getting the contract

id through url string in pdf livecycle forms and displaying

data in form using dataconnection to sql server.

I am using Acrobat 8.0 professional on my server and making use of

livecycle designer to design the forms.

can this form still work if client uses just adobe reader

(any version?)on his machine.Is there any kind of restriction in using this method instead of creating XDP as you have mentioned. Does this one require Adobe LiveCycle Forms on server?Please let me know.



Thanks,

Vidya

Avatar

Level 8
vidya radhakrishnan,



Sure, using JavaScipt, you can creat a direct connection from LiveCycle Form to SQL Server. I tried this method to test it in the past, but, I faced several prolems, and decided not to use this method in the future, becuase:



1. You have to connect to Database directly, which is based on 2-tier method, which is not the proper way in general to build secured applications,



2. You have to use complicated scripting techniques (very un-usual APIs) in LiveCycle to navigate and process the records from/to SQL Server (move next, move previous, update ...etc), which is very difficult to debug and work with. Using XML, you have one root record, and all other records/fields are either elements or repeating subforms (nodes) with child elements ..etc,



3. There will be security restrictions and you have to make a trusted connection and this will force you, I think, to create an ODBC on each client or configure a driver, and you need to do client configuration to make it work, and what every you do, you will still face problem with some users, and in the end, it will be very expensive.



4. Using JavaScript to connect directly to a Database, will make your form dependant on the Database, and if there is any problem, it will not work. With XML, the form is disconnected from the server, and it is a truely stand-alone smart form, and you have the choice to SUBMIT the form to a URL or via Email Attachment, and in the worst case, you can use Acrobat to Export the Form Data to XML format.



The other method, is to use Web Service, and this is the state of the art. I did one example, it it worked without any problem. But this case (web services) you form will not work properly if the web service is down or not accessable for any reason. Using XML Data Embeded in the form, will give you te ultimate flexibility.



But, try to avoid using JavaScript to connect to Database and process the data for processing and displaying info ... it is very expensive and difficult to implement.



Always try to build an Intermediate Layer (Business Logic in ASP.NET or Java Server Pages) between you Presentation Layer (LiveCycle PDF) and the Back-End Database (SQL Server).



I hope this helps.

Avatar

Former Community Member
Thanks Tarek ,



This was really helpful for me in deciding which method to use. Seeing all these security issues and flexibility I will try working with XML Thanks for your input I really appreciate for your quick response.



Thanks,

Vidya

Avatar

Former Community Member
Hi Tarek,



I used your suggestion of using datasets for creating the XML file in .net and sending it to PDF forms as input to display the filled form.



Instead of using datasets and getXML()I used the .net sqlXMLCommand object and passed in the sql query for XML and using the SQlXMLReader function I could retrieve the sql data in XML format. I then appened this string to generate xdp.



It works very well for generating even dynamic table data. Thanks for your input.



This is code i used in .net for generating data in XML format,



Public Sub test2()



Dim ms As MemoryStream

Dim cmd As SqlXmlCommand

Dim p As SqlXmlParameter

pid = 2700

Dim fname As String

Dim xr As XmlReader

Dim xmlCatalog As XmlDocument



fname = "testxml.xml"

ms = New MemoryStream()

cmd = New SqlXmlCommand("PROVIDER=SQLOLEDB;SERVER=test;DATABASE=test;INTEGRATED SECURITY=sspi;")



cmd.RootTag = "form1"

cmd.ClientSideXml = True



**** This is function with parameters i am using to get data from sql I couldn't use the Xpath command type since this is a function *****



cmd.CommandText = "execute getdata ? for XML NESTED,elements"

cmd.SchemaPath = "testschema.xml"

p = cmd.CreateParameter()

p.Value = 2709



**** use can you Xpath if it is a direct query to sql table and u can also specify the parameters in this command text****************

'cmd.CommandType = SqlXmlCommandType.XPath

'cmd.CommandText = "myform"



xr = cmd.ExecuteXmlReader()

xr.MoveToContent()

xmlCatalog = New XmlDocument()

xmlCatalog.Load(xr)

xr.Close()



********** I store this xml outpput to a file to be read later on for generating xdp*******



xmlCatalog.Save("xmlcat1.xml")

xmlCatalog = Nothing



End Sub



I am facing an issue after the display. I used your code for pushing the xml data on to Pdf .Everytime i generate the PDf the response ends, so i have to open up the application again. Is there another way for displaying the pdf without affecting the application window?



Thanks

Vidya

Avatar

Former Community Member
Hi Tarek,

I have the exact same scenario as yours where the user would submit a pre populated form to sever and we have to extract the data form the xml and work with that.

can you please tell me how do we submit the xdp package to the server.

and what techinique you have used to extract the pdf and the xml separately.

any help would be appreciated.

My envioenment is life cylce designer 8.1, java.



Thanks,

Vikram

Avatar

Level 8
vidya radhakrishnan,



Very smart of you to find out another way. Thank you for the input and I will keep it in my mind for future use. However, I once tried to look at SQL XML, but I find it very hard to digest. I would prefer using Datasets, Tables, Relationships, and GetXML(). It is much easier to digest and work with especially if the final XML Strucutre is simple.



With regards to the problem you are facing, I dont understand exactly what is wrong ? Is the PDF begin displayed correctly after "respnse.write xmlString" and "response.end" ? If not, then there is a problem with the XML Strucutre and/or Mapping of the XML Elements to the Form/Subform/Fields in the PDF. Or, the XML may have invalid characters such as "&" or "<". Use Server.HTMLEncode or something like that to convert the special characters to proper XML format.



Or, if you are trying to display the PDF withing the window of another browser window, then you have to develop the .aspx page same like what you did, and in the main application window, use "iframe" HTML Tag with src = to the path of the .aspx page.



Please clarify what is worng ?



Tarek.

Avatar

Level 8
vikram medishetty,



Actually this thread should have all the details you are looking for. May I kindly ask you to go through this thread from the beginning as you may have to click on "Show All Messages" to see all posts.



I recommed you to work on a very simple Hello World Example and just pass some very simple data fields from the .aspx page to the PDF, and back from PDF to .aspx page.



If you have any error in this example, then I will be very happy to try and help you.



Tarek.

Avatar

Former Community Member
Hi Tarek,



I figured out I have do this manipulation in .net front end.



The Solution you have with XML works like a Charm . I have successfully used SQL to create XML files. I have a PDf file which has data from multiple datasets . So i created one XMl file for each dataset and then appened all these files at end to get a single XDP file. Saved the final file as .xdp.



Then in .net at the click of a button i just used javascript to display this PDf as a seperate window like this,



s = ""

s = "
"

******* tempname is the name of the final XDP file i created *******

Response.Write(s)



It works perfectly now.



I am working on another request where the rows in the pdf file should dynamically increase based on the calculation from fields in the XML file.



I am kinda stuck ..



I have a XML file which provides input to the pdf.

This file is used to dynamically create rows in a subform.

Based on the values in this fields in subform i have to generate table of data which displays calculated income,tax info etc for each row of data.



The data for this is not coming from an XML. It is calcuated based on the previous one.



Let me know if you have any sugestions.



Thanks,

Vidya

Avatar

Former Community Member
Hi Tarek,



the request put forward was to generate a pdf from the application . once generated and printed we have to go back to the application .



With the solution before with displaying the pdf using response.flush and response.end(), the pdf displayed perfectly but the whole application was terminated once the pdf was generated. This was not intened. So i figured out a way to create a .xdp and save it in the sever and then use java script to open this .xdp on the client side.



Thanks,

vidya

Avatar

Level 8
vidya radhakrishnan,



Greate job ! I think I will use your solution one day.



Please, do post back all details about any solution you find for any problem.



To make the PDF Dynamic, you have to save as Dunamic, and set the subform properties to be dynamic also. I cannot remember all the details of how to do it, you may check the sample help files that comes with LiveCycle DEsinger, and see the PO Example or something like that.



Regards ...



Tarek.

Avatar

Former Community Member
Hello...



I'm a .NET Developer, I'm pretty new to Livecycle. I started using Livecycle 8.1 last week. I designed my first form.



I came across this thread, and I want to be able to use a PDF and dynamically populate it with data by injecting XML.



My requirements are as follow:



-- Users submit data via a aspx webform. Which gets stored in a SQL database.



-- After submittion, I need to be able to review these entries, which will be a list of submittions with a link that says: "View PDF". I click on it, and have the ASP.NET page generate XML and launch the PDF premade form, with the values entered by the user.



--That's it



I have followed this thread, and I've used some of the code presented. I created a single field form in livecycle, in order to simplify my life and be able to test this method. But every time I run my asp.net page it launches the PDF. But the values do not reflect what is fed into the pdf form via XML. The fields in the pdf file is blank.



Can somebody tell me in the simples way?. A step by step process. Because I don't even know if the way I created the form in livecycle is right.



Can somebody post a simple example of this?, maybe a sample zip with a PDF and a aspx page.



I've been at this for two days straight, and this thread has gotten quite large. I might just be missing something.



PS. I have been able to databind the form directly to my SQL server. But I see no way of passing parameters to PDF or to modify the SQL Command on the fly(To retrieve a specific record).



Thanks in advance. This will be amazing if I get this to work.



Thanks

Avatar

Level 8

Hi to all ...

I am back to my beloved thread, looking for information on how to implement new certain requirements...

I have upgraded to new LiveCycle Desinger 8.1 few days ago, and still do not know all the new features.

I was requested to develop new LiveCycle Form, but this time it has to be secured by Digital Signatures or what every appropriate method.

The form has exactly 2 sections and 2 Digital Signatures:

1. The first section/part is to be filled by the Staff (let us call him the Authoring Staff).

Any one can fill the first part.

After the first part is signed, the Data Entry on the first part should be locked, and no one on Earth should be able to change the data on the first part. Only the signer of the first part is allowed to update/clear the signature but only and only of the Second part is not yet signed.

The staff should not be allowed to sign the form unless all mandatory fields and other validation logic is statisfied.

Only the Signer of the Form and special authorized staff/group of staff will be allowed to open the form. Let us call them Group01.

2. The second section/part is to be filled by special authorized staff/group (say Group02), they are basicall HR Staff (this is a secret).

The second part can only be filled if the first part is filled and signed by the Authoring Staff.

The second part can be signed only if the validation logic on the second part is true (no errors, and all mandatory fields are filled).

Once the second part is signed, the first part the the second part should be locked, and no one on earth should be able to change anything on the form.

Only the signer of the form should be able to clear the signature of the 2nd part and make any changes requried.

If the 2nd part is signed, the Authoring Staff should not be able to change anything on the form.

*****End of Requirements.*****

I have just started, and I am requested to desing the form and implement the required security in 10 days only.

Can any one please help me ?

I am doing my research now.

Thank you.

Tarek.