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 8
In general, if you do not have Full Version of Adobe Acrobat on the Client, then any function that will end up using Advanced Adobe Functions such as saving a copy of the PDF Off-Line or submitting the complete PDF as Binary to the Server, then you cannot do that.



If you have Adobe Reader Extension Server (this is the product which I convinced our Management at work to purchase) which will cost you a bit, this product will allow you to Reader-Enable the PDF so that it will work under Adobe Reader as if it ware Acrobat. At work, we have more than 1000 Employee, and all are using for submitting the leave form on-line, and it worth the price.



I think (not 100% sure) that you can use the PDF as if it ware HTML Form if you want to use Adobe Reader on the Client. In this case, you can Submit the form to the Client, and on the client you can just retrieve the form values from the Request Object as if you are working with normal HTML Form. I tried this once about one year ago, and as per what I remember, it worked. If you want to do that, then you just need to use the Proper JavaScrip Submit Command on the PDF Form.



If you still need help, please let me know.



Tarek.

Avatar

Former Community Member

Hello Tarek,

I have read this link and it has a wealth of information.

I have designed a form using Livecycle designer ES2, this form will be launched from a WPF-C# desktop application.

This form needs to be prepopulated with data and data changes need to be saved back to teh database.

I am using an XML data source, the preview form comes up fine, but how do I get data into the form at run time. Currently it comes up blank.

Any help will be greatly appreciated.

Regards

Nanda

Avatar

Level 8

Hi Nanda,

Sorry for late reply...

You can populate  PDF Form (XFA) programatically uisng one of the following ways (to the best of my knowledge):

1. For Web Applications, you must compose the Data in XML Format, and it must be formatted correctly. To test if it is working, open a blank form, fill it with some data, and export the XML (using Forms/Manage Data/Export Data) to a file. Then open the file in IE for example and see how it looks. Note that, in .NET the XML Data can be composed using String Variable, and it must be formatted same way you see it when it was exported.

After you compose the Data in XML, you must compose the XDP which is: XDP Header XML + XML Data + XDP Footer (with URL to the blank form). It is simply a long string variable. Eventually, you must usine Respose Content Type to set it to be XDP Type, and write the XML String to the Response. This can be done even using PHP.

Usually, you must trigger the above logice from code-behined of ASPX page.

2. For Client Applications, you must use Acrobat SDK or IAC (Adobe Inter-application Communication or OLE Automation). In other words, you will have to write a program that uses the SDK to open Acrobat, then open the Form, then Import the XML Data to the form. So, the PC which has client application must have Acorbat installed or it will not work. If you try to use XDP to work on the client, I tried it before (2 years ago), and it did not work.

To make your job easier, you can develop a reusable program that will generate the XML Data (which can be used for Web and Client Applications), and then use it where needed, because XML Data Format it is the same regardless of where it is used.

3. Using LiveCycle ES Services. When you install Adobe LiveCycle ES Server, you will get a large number of Web Services or REST APIs which can be used from ASP.NET or VB.NET. So, there is one of the Forms Server Web Services, which simply take input the XML Data and the Path to the form, and then it will return the PDF. Also, you can use REST which is same like Web Service but much simpler. I have not doen this myself, but I worked on it when I was in Adobe LiveCycle @ MAX 2010 Training. It is very easy.

In all other cases, you will get a blank form .

I hope this helps.

Avatar

Former Community Member

Hello Tarek.....

Please do not apologize for the lateness of the reply......Its great to receive replies at all

I read thru your reply and it is very detailed and clear. The issue is that I have a desktop application and opening a browser with the pdf form, is not an option.

I checked through the installation files of Livecycle and I cant find any DLL's that make sense. I have a Trial version of Livecycle

Please see this article http://www.avoka.com/blog/?p=318

Do I require Livecycle Workbench to get data? It does not offer a trial version

My company wants to make sure, all required features work before buying the Livecycle product

Awaiting your reply,

regards

Nanda

Avatar

Level 8

Hi,

I understand from you that you need to provide the end user a feature where he can click a button from a C# Client Application, so after he clicks the button, it will open a PDF Form and it must be pre-populated with data based on some input parameters, is my understanding correct ?

By the way, I forgot to mention to you that you can create a WSDL Connection directly from PDF using LC Desinger. This is a great option, I have tested it and it is working like a charm (using SAP Web Service with very complex data strucutre and very large, and still working!). But, you need to develop the Web Service using say .NET. In my case, there was only one Input Parameter, which is the Logged In User ID (Windows User). I was able to capture this parameter from inside the Web Service. Also, you can bind the Web Service Input Parameters (WSDL Connection) to any Field on the Form. Same applies to the Results (output) of the Web Service.

You can Execute the WSDL Connection on certain events like Document Ready or Initialze Events of the PDF. Also, you can execute it on a click of a button. You will get same effect you are looking for (automatice pre-population of the form) if you use WSDL Connection.

BUT ... if you use a WSDL Connection, and if the PDF will open outside the browser, you will get some annoying prompts... you can ask however to trust the WSDL Connection URL, and you will not get such prompts.

I think you cannot avoid implementing parts of your solution using a Web Technology like a Web Service for example. Also, you will gain a lot if you accept to open the result PDF (populated version) inside the browser. If you use OLE/IAC (Acrobat SDK), it will be a pure Client Solution, and it can be done. But, I do not recommend this approach.

Note: I do have not practical experience working with LiveCycle ES2 Server. Some info I present about LC/Workbench my not be 100% accurate.

The most advanced and the best option is to depend on Adobe LiveCycle ES2 Services. I have only tested it when I was in LiveCycle @ MAX 2010 training, and I can't wait until I implement a solution using LC Services.

If you want to use Wrokbench, it is even better. This way, you can build a complete workflow application, but then it will have to be triggered from the Browser. Workbench is like VisualStudio, which will help you to desing the Workflow Process using GUI and Drag & Drop Controls. Some one at Adobe MAX told that Workbench is free, but I might be worng.

After you install Adobe LiveCycle ES2, you will not get DLLs, but you will get Web Services and REST APIs. You have to open the Admin UI, and then try to find the URL of the required Web Service. If you use Workbench, it will be a lot easier. Basically, you can create a new service using Workbench which will do exactly what you want, and finally make this service callable via SOAP or REST, then you can use it from your .NET Application. From .NET, all you have to do is to add a Web Reference to the Adobe LC Web Service, that is all. Adobe LiveCycle ES2 server has several modules (services). It will have something called Foundation Services. I think you will need something called Output and also Forms (or something like that).

The issue is really very complicated and it all depends on how far you want to go. Without having a clear and detailed requirements, and without doing a detailed analysis, it will be impossible to tell you what you need exactly. The Avoka blog post you provided is an excellent resource. I have added it to my bookmarks.

So, if your requirement is to provide a user with a button, and on click it will open the PDF and prepopulate it with data, then you can do this using:

1.  Acrobat SDK. You will get a Pure Client Solution. Acrobat has DLL for .NET. Just add a reference to this DLL, and you will can do almost anything with PDF as if you are using Acrobat, but you can do it programatically.

2. Create a web page using ASP.NET (.aspx) which will generate the required PDF using XDP. Here, you don't need LC ES2 Server. From C# Client Application create an Browser Plugin (ActiveX or OCX) that will navigate to the ASPX page, and the user will not know that you are using a Browser. He will think you are using only C#. But if the user insists to know what is behined the C# application, in this case you have to say the truth . Download the Acrobat SDK and you will find examples using Browser Plugin inside a VB.NET Windows Application. I am 100% sure I found one in Acrobat 7.1 SDK.

3. Using LiveCycle ES2 Services. For complete tutorial check this: http://www.adobe.com/devnet/livecycle/articles/asp_net.html. But this is not a pure client application. You can use Workbech to desing a new Web Service to do exactly what you need, and also you can build a long-lived process with complex workflow rules. If you will need to use Workflow (Long-Lived Processes) you have to get Adobe LC ES2 Workspace (or something like that).

4. Using WSDL Connection. You need to develop the Web Services. This is really a nice option. If you connect to .NET Web Service, you will get the luxury of Integrated Windows Authentication.

I think you will need to have Acrobat on every machine, otherwise, you will have to buy Adobe LiveCycle ES Reader Extensions Server.

I hope this will be of help to you.

Tarek.

Avatar

Former Community Member

Hello Tarek,

Thank you very much for your long and detailed reply.

This is the gist of the solutions that you have recommended -

1. ADobe SDK - you hv said not to use this, I had previously downloaded and tried this, but this is not compatible with LIvecycle and class instantiation throws exceptions. So I will pursue this only as a last resort

2. WSDL - I am reading up on this further

3. Workbench - I am downloading the trial version, I will investigate this and loop back with you

4. Web services / REST API / foundation Services- I am really clueless about how to use these. but I am trying to read up on documentation, hopefully after I install Workbench, I will understand further.

Again, thank you for taking so much interest and explaining so patiently. I will try all the options recommended and reply.

Best Regards

Nanda

Avatar

Level 3

Hi Tarek,

I have a pdf file and on click of SUbmit ,I want to submit it to a webservice which has to save the entire PDF.I need to use Dot Net for teh webservice.Sample of the code will really help.

Thanks and Regards,

Leena

Avatar

Level 2

Add a "HTTP Submit Button" control in the PDF form.

In the submit URL property of the button, set a URL like http://localhost/PDFManagement/PdfProcessor.aspx?SubmittedFormPart=1 and set the "submit as" property for the button as PDF.

In the PDFProcessor.aspx web form page load event handler, you can get the full PDF using the below code,

if (Request.QueryString["SubmittedFormPart"] != null && Request.QueryString["SubmittedFormPart"].ToString() == "1")

            {

                Stream fs = this.Page.Request.InputStream;

                BinaryReader br = new BinaryReader(fs);

                Byte[] bytes = br.ReadBytes((Int32)fs.Length);

            }

Avatar

Level 3

Thanks Anand,

But when i choose Http Submit Button", I do not get an option to Set the Submit As Property in Designer9.Am i missing something?

Regards,

Leena

Avatar

Level 2

Add a Button objectUntitled.png

like in the above screen shot.

Set the control type as submit.

You will see a submit tab.

In the submit tab, you will need to set the submit to URL property and submit as property.

This will work in livecycle designer

if your form is acrobat form, steps will be slightly different

Avatar

Level 3

Thanks Anand,

I could achive the desired functionality.

Only one issue , after the PDF is saved it opens a blank PDF, is there some script with which we can have the same PDF in view?

Regards,

Leena

Avatar

Level 2

Do you display the form online? Where do you store the PDF? in database or file system?

Avatar

Level 3

There is a ASP page on which the form is opened ,then we click Save and the form gets saved in Document Repository(Using Sharepoint Portal).After clicking teh submit, a blank PDF with the title of that URL( asp url) is opening.

Regards,

Leena

Avatar

Level 8

Hi Leena,

I just want to make sure I understnad your original question. You wanted to submit the PDF to a Web Service or a Web Page ?

A Web Service ASP.NET has ".asmx" file extension, and a Web Page has ".aspx" file extension.

See this Google Docs Folder. In case you are submitting to ".aspx" web page it will be of a greate help to you.

In case you want to submit to a Web Service ".asmx" then we have to work on this, as I have never done it before. As a matter of fact, I have to develop this fearture, since submitting to ASPX web page has some limitations like:

1. All changes made by the user before submit will be lost, if the server side validation has failed due to violation of business logic.

2. All changes made by the user before submit will be lost, if there is a technical probelm on the server.

First, we need to know if this is possible?

Tarek.

Avatar

Level 3

Thanks Anand and Tarek..

I was able to achieve this.I had to have a ASP Page at the Server end instead of a webservice and submitted the Form as PDF to it which inturn saved the file to a specific  server location.

Regards,

Leena

Avatar

Former Community Member
Thanks for the reply.



I searched on Adobe Reader Extension Server but I can not find the cost of it anywhere.



Do you know the cost of Adobe Reader Extension Server and where to download it for testing?



So all I need to buy is Adobe Reader Extension Server and I will be able to online PDF forms for users ti fill without needing acrobat and they do it with reader?



Is there anything more to buy except Adobe Reader Extension Server . Anything at all?



Thanks for the help.

Avatar

Former Community Member
This thread is indeed very informative!!! Thank you all for the contributions...



I'm interested in Jeff Lawrence's post as he is using Dreamweaver or a similar product to generate his ASP page.



I have used his code and was able to make it work. My pdf button is sending the xml data to my ASP page, and i'm able to write them to the test page via Response.Write()



However, i'm more interested in sending the WHOLE PDF as an attachement and not just the data...anyone out there with help will be greatly appreciated!



I was thinking of using Jeff's code to save the pdf to the server, then have that file sent to an email and then delete it from the server...does that make sense? Is there a more direct way??



Thanks guys, you all rock :)

Avatar

Former Community Member
Hello Charlie Taminian,



>>However, i'm more interested in sending the WHOLE PDF as an >>attachement and not just the data...anyone out there with help will >>be greatly appreciated!



Problem is the solution needs Acrobat to send data from the client machine to any page asp or aspx etc. Acrobat is expensive and no one will be able to have it on there machine just to fill the form in PDF and send it. I am talking about public web sites like immigration site etc.



I am looking for a away to spend some money but I get the above functionality without clients having acrobat and they just do it with reader.

Avatar

Level 8
Pirzada,



For the price ...etc, the proper way is to get in touch with the official Adobe Sales Rep. in your area. There are different products, version, prices... all the times.



You need at least:



1. Adobe LiveCycle Designer ES (I think 500 US$ per head) !



2. Adobe LiveCycle Reader Extensions Server.



If you want to spend less effort in ASP.NET Programming, and willing to spend more, then you can buy additional server products that will generate the PDF using a few lines of code. But I do not have much info about such products.



We purchased ARES about one year ago, and I really do not remember the price, as it has some complicated scheme.



Goto to the Adobe Web Site, select your country, Product Page, Server Products, look for Adobe LiveCycle ES:



http://www.adobe.com/products/livecycle/



Now, click on "Have Adobe contact me" link and submit the request to Adobe.



Keep in mind that there are many different client/server LiveCycke ES products, and it is very easy to get confused.



You can explain the requirement to Adobe rep, and he should guide you on the proper direction.



From my experience, you need LiveCycle Designer and Reader Extension Server. Of course, you need a Server Based Development Platform like ASP.NET or Netweaver (Java based).



The technique I followed in this post (as per the complete ASP.NET Code I posted before) can be easily converted to any other platform as you have seen that one of the programmers have posted some ASP Code that does almost the same.



What is my next target ?



I am planning to develop a .NET Class Wrapper for the Form Submission, Initiation and Processing, which will be based on the CSLA .NET Framework.



Regards ...



Tarek.

Avatar

Former Community Member
Thanks for the reply Pirzada...



Tarek...i'm glad that you are still active on this thread....I have read your code and it seems that you are pretty well informed on this subject... can you please provide me with a straight forward answer to this question???



I need to send the WHOLE PDF as an attachment and NOT just the data...



I see from Jeff Lawrence's code, that he saved the pdf to the server, I can assume that there is also a script to send that same pdf from the server to the email address, thus achieving my goal of sending a pdf as an attachment to an email address......am I correct???



To make things easier for you....



My ASP page will:



1) Read the xml data

2) Save that data as a pdf on the server

3) Send that pdf to an email address as an attachment



Final result is a pdf being sent to an email address as an attachment.......is my logic correct, or is this even possible???....I don't expect you to give me code, as i'm not using .NET so I only expect you to confirm my logic...



Thanks alot man, your efforts are greatly appreciated!

Avatar

Level 8
Charlie Taminian,



Check the .NET Complete Code I posted ... it should have everything you need about using email, and to send the PDF as an attachment, some extra work is needed to use the proper MAPIs to add attachment to the email.



You can use Client PDF Functionality to send the PDF as attachment, but you need Acrobat on the Client, or Read-Enable the PDF using ARES. Client functionlity to send PDF as Email attachment is a bit tricky, confusing, and limited.



Just keep in mind, any time you need to get the PDF as Off-Line version or convert it to Binary and use it on the server, then you will need ARES or Acrobat.



The logic you have mentioned is 100% correct. This is the proper way.



Tarek.