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

Level 8

Hi FrobergDK,

Try the following:

1. Goto form properties -->Defaults-->Preserve script ...--> choose "Automatically".

2. Before you submit, make sure to hide the fields to be hidden.

3. Try to hide the fields first, then save the PDF manually to a local drive, then open back the PDF to see of the fields are still hidden.

I appreciate it if you could post more details about the script used to submit the form to a Web Service, and what technology you have used.

Could you also post a sample form and script ?

Thanks ..

Tarek.

Avatar

Level 1

Hi

Thank you for your time

Attached is the pdf im using for testing.

Let me know if you need help finding your way around it

1. form properties, preserve script didn't help.

2. I hide all the fields before sending.

3. If I hide all the fields and save the pdf, the fields are still hidden when I reopen the pdf.

It okks like the base64 conversion ignores the settings on the buttons.

The script I'm using is included in the form, under one of the buttons ("Arkiver formular og evt. Print" ).

When the button is clicked, some data is filled in hidden fields and use to build the data for the webservice.

Right now the webservice is running on a LiveCycle ES2 server - eventually it will be a .NET service that delivers data to an eArchive.

But for testing it is easy for me to use LC - and I can record and playback the process.

Hope this helps - please feel free to ask, your help is appriciated

/Søren

Avatar

Level 8

For my case, I am using this javascript command to submit the form:

event.target.submitForm(

{cURL: http://server/ASPNETWebPage.ASPX,

aPackets:["datasets","pdf"], cSubmitAs: "XDP"});

and, I am using this ASP.NET code to extract and convert the submitted chunk element to Binary PDF Format. In this case, all script changes are saved. The code is:

             fs = New System.IO.FileStream(mFormFileNameFolder, IO.FileMode.Create)
            bw = New System.IO.BinaryWriter(fs)
            ' Get chunk element form the submitted XML
            Dim srChunk As New StringReader(mXML.GetElementsByTagName("chunk")(0).InnerXml)
            Do While True
                Dim theChunkLine As String
                theChunkLine = srChunk.ReadLine
                If Not String.IsNullOrEmpty(theChunkLine) Then
                    theReadBytes = theChunkLine.Length
                Else
                    theReadBytes = 0
                    Exit Do
                End If
                Dim theBase64Length = (theReadBytes * 3 / 4)
                Dim buffer() As Byte
                buffer = Convert.FromBase64String(theChunkLine)
                bw.Write(buffer)
            Loop
            bw.Close()
            bw = Nothing
            fs.Close()
            fs = Nothing

Note: I don not see the attached file you mentioned.

The problem I am facing now is that the above method is generating huge PDF File. With every submit of the same PDF, the chunk element will result into a very huge PDF File, and it is doubling the size of the PDF. I have reported this to Adobe Support, and they confirmed that this is by desing. They told me that in order to resolve the problem, I have to submit the form as PDF ONLY, and on the sever, I can then save the PDF, and use Adobe service/process "exportData" in order to extract the XML Data. I have never done that, and I am not sure if I can do that from ASP.NET.

How do you submit the PDF from the browser to the server, and then save the PDF and also extract the XML Data ? Did you face this problem where the PDF File Size will increase dramatically with every submit ?

Tarek.

Avatar

Level 1

Ok, I'll try and attach the file again.

I'm not sending the pdf from a webpage.The submit button is inside the pdf document.

When the user clicks the button, the whole pdf with data is to be sent to a webservice and archived.

I will not need to extract the XML, since it is the whole document I need to save in the archive - as it looked at the time when the user clicked the button.

Hope this clarifies it

Avatar

Level 1

I found out that it is the transform step on the server that makes the buttons reapear.

So the base64 looks ok, when I view it on the server before the pdf I flattened

Avatar

Level 1

Hi Tarek,

I need your help in designing my document solution in PDF.

The requirement is :

  1. Business User will define a PDF template and will store in a location.
  2. Say for example : The template has 4 fields First Name, Middle Name, Last Name, and Location.
  3. Say Location is the field which will be editable to user other all the fields will be filled by data present in database and based on some input criteria which will be driven by BUSINESS RULE.
  4. The flow would be: User will fill the required data from .NET web page UI.
    1. Once the user click submit, the required template generated in step 1 should be selectd and data retrived from D/B should get embedded.
    2. The PDF with data once gets generated should be transferred to UI as a PDF document.
    3. The end user should be able to save the pdf in local folder and edit it as well the "LOCATION FIELD".
    4. Once the end user EDIT the generated PDF should be able to save the updated PDF in local location as well.
    5. Note : The Template has got three 4 fields as mentioned above, but based on input criterai if i get three or more records that may PDF pages should get generated with LOCATION as a editable field in each page.

Kindly advice how to attain this functionality.

Note: We are using .NET 4.0 with N Layer architecture using WCF as a mode of communication between layers. Its going to be web based application.

TIA

Robin

Avatar

Level 8

Hi TIA,

Sure I will try to help.

I think I understand your requirements, but need more clarification as follows:

1. It seems that point 4.3 and 4.4 you have mentioned the requirements to "Save" in a local folder in both paragraphs, right ? You mean the user can "Save" in a  local folder before and after he has edited the "LOCATION FIELD"?

2. Point 4.5 is not clear at all. Please rewrite this paragraph again. What do you meant by "... three 4 ..."?

2. Point 4.5 again, do you mean that you are executing a query against a back-end Database, and you may get 3 or 4 records, so each record will be redndered in a new Page inside the Dymanic PDF, right? Please clarify.

In any case, if you check my Google Workspace, you will find that what I have done seems to be a perfect match for your requirements, if you want to use ASP.NET.

Also, check this thread post, it should give you more insight about possible implementaiton methods.

Tarek.

Avatar

Level 1

Hi Tarek,

Thanks for your quick response. Here are my response

1. It seems that point 4.3 and 4.4 you have mentioned the requirements to "Save" in a local folder in both paragraphs, right ? You mean the user can "Save" in a  local folder before and after he has edited the "LOCATION FIELD"?

Ans: Yes, user should be able to SAVE the pdf file locally after editing it.

2. Point 4.5 is not clear at all. Please rewrite this paragraph again. What do you meant by "... three 4 ..."?

Ans: Let me put it in this way say as per my example i have a template of 1 page which has 4 fields and it can accomodate data of one person in it.

Say tommorow i get similar data of more than 1 person say 3 persons( each having 4 fields of data) then in that case i should be able to create 2 copies of original template and populate data of remaining 2 persons. so finally it will be a 3 page document.

2. Point 4.5 again, do you mean that you are executing a query against a back-end Database, and you may get 3 or 4 records, so each record will be redndered in a new Page inside the Dymanic PDF, right? Please clarify.

Ans : Yes , you are  right

Sorry i forgot to add one more requirement as per the above example all the pages should be merge to a single pdf file. So as per above example all the 3 pdf files should be rendered as a single pdf file with 3 pages.

Thanks ,

Robin

Avatar

Level 8

Hi Robin,

First, make sure to check this thread post, it should give you more insight about possible implementaiton methods.

Following is my feedback:

1. To save locally, the best option is to educate the user how to save locally. Simply ask the user of the form to click File-->Save As or click on the "Save" icon. This will prompt the user with a save dailog, and to avoid this dialog, it reuires edditional effort, which I recommend you to avoid doing so.

Note: The local copy saved by the user, will be used by the user to fill the required updates later even when there is no Internet. Also, it can be used for local archiving and tracking by the user, only for his convenience. But, eventually, the updates are of no value unless they are submitted back to updating the source.

2. To save, you have two options:

  2.1. Save the Data only: If you want to save the Data only back to the Server Database, then I think it is better that you use traditional HTML or Web Forms.

  2.2. Save the Data and the PDF. Usually you save PDF and Data in one file, if you want to have off-line support and to protect the intellectual property of the Company and the protect the Data Entered by the user, using Digital Signature.

Note: if you save the Data with/without the PDF, you must think of a way to update the Server Database with the updates made by the user. This way, next time the same Form is rendered back to the user, to incorrporate the new changes made on the Database (new records), so the old records will have the new updates made on the user on the form, otherwise, you will end-up loosing the Data entered by the user.

If you are thinking to merger the Data from the Server with the updates made by the user on the cleint, without any kind of updating the data back on the server, then this is a very complex process. In this case, I advice you to chage this approach and make it more simple.

3. The first time the PDF is Generated using XDP and rendered back to the client browser, now the Form is disconnected from the server. Following are the options/points to consider for reliable implementation:

  3.1.  First, you must ensure that the Data entered by the user (client updates) is saved back to the server. You can do that using a Web Service Call or by Submitting the Form to the Server, where you have to receive the XML Data, parse it using ASP.NET APIs, and save the data to the Database Server.

  3.2. Ensure to update the back-end Database with the client changes ASAP.

  3.3. You can retreive the new records from the Database and merge them with the PDF: 1) Ask the user to re-generate the Form from scratch by clicking on the same link to open the PDF and Merger with data from back-end Database, of course, he must first ensure that any updates he made on the old records are updated back on the Database, or, 2) Use a Web Server to "Retreive New Records only" and execute this web service on a click of a button.

4. You must use Adobe LiveCycle Desinger ES and make sure the Form is Dynamic, and the Subform used has flowable layout. For more info, check this Youtube Channel

5. Check my Google Workspace, and you will find a Sample PDF Form for Medical Cards, and Sample XML Data.

I hope I have answered your questions.

Tarek.

Avatar

Level 1

Hi Tarek,

Thanks for your response. Let me just put down my requirement once more to be more clear and get final view from you.

Step 1: The Business user will generate a PDF template-T1 , which they will store in some location or sever. [Please advice do i need to use static form or dynamic form based upon the below explanantion]

Say for ex : The template has three field :

FirstName

LastName

Location: A drop down field which user will update once he receives the PDF

Note : The Reader extension should be enabled here becuase my business requirement is the end user should be able to save the PDF locally if any modification done.

Step 2 : Accept Key input params from the user using a .NET application (request object). User submits the data.

Step 3: Fetch the relevant form data (data sets) from the database for the INPUT params. [Please advice do i need to use XDP /XML ]

Step 4: Once data is received, the template - T1 need to be initialized and the required data fetched at step 3 need to be filled in Template T1.

Thus we receive say three sets of records

Record 1: FirstName : Adam,LastName:ABC,Location:<To be filled by end user>

Record 2: FirstName : Joseph,LastName:XYZ,Location:<To be filled by end user>

Record 3: FirstName : John,LastName:PQR,Location:<To be filled by end user>

The Generated PDF should be having following:

* The final PDF should have three pages. One Page for each record.

*Reader extension should be enabled for the entire PDF so that if user chnages any location in any of the 3 pages it should get saved.

Step 5:Now show the browser (response object) with Reader Enabled generated PDF of Steop 4.

Step 6 : ENd user should be able to save the file in Location folder say he stored in C:\\MyPDF.

Step 7 : User open the PDF and udpate the location for all three records and then should be able to save the file locally.

Note : My business doesnt need to update the data back to application, let it be in PDF alone.

Design Approach:

* Should i have to use Adobe LiveCycle Designer 7.1 to design the form,?

*Adobe LiveCycle Reader Extensions Server 7.2 to Reader Enable the form, If yes the is it my server side deployment component?

*Adobe Reader which is Licensed free should be used by end user to view / read the PDF and modify the PDF as well as mentioned in step 7?

*All the above processing until step 6 need to be happening in server side, do i need anything at my UI layer as well. Any suggestion from your end?

Thanks

Robin

Avatar

Level 8

I think you have now clear requirements, and it should be easy to implement.

I have the following feedback:

1. The form generation should be done using server side web technology like ASP.NET or similar way. Steps:

  - Accept Key to lookup,

  - Run Query against the database,

  - Get results and convert to XML,

  - Merge XML with empty template (XDP) and render the result to the client.

2. If you decide to let the user save the generated PDF Form locally, this is fine, but I don't see the value of this step, if you don't want to collect the data later one.

3. To be on the safe side, when you generate the PDF, make sure to include Unique Primary Key with each record (where each record will represent a PDF Page on the form). This will allow you to easily update back the records when required.

4. You should use the latest possible version of Adobe LiveCycle Desinger.

5. I "think" you need only Adobe Acrobat Prof. 9 or higher which will allow you to reader enable the PDF Form which will allow to save the forms locally. Please try this to confirm. You need this version for the developer who will desing, then reader-enable and deploy the form on the server.

6. If you use Adobe Reader to open a reader-eabled PDF, you will be able to fill and save the PDF on client.

7. To generate the PDF Form and prepopulate it with data, you only need to give the user the link to the ASPX Page, and probably some nice HTML Screen to give him some instructions.

Tarek.

Avatar

Level 1

Hi Tarek,

Thanks for the reply.

Could you please advice on following:

  • Should i use Acrobat SDK or PDF SDK. What version should be used.
  • For reader extension , should the required DLL be installed at Server only? If yes what version should be installed.
  • How best the design and code be made very geneic?

Thanks

Robin

Avatar

Level 8

Ho Robin,

1. Use Acrobat SDK only if you are developing Windwos Desktop Application (VB.NET for example). I never worked with PDF SDK.

2. According to your requirements, you do not need Adobe LiveCycle Reader Extentions Server. You only need to get one license of Acrobat Prof. Then, use Acrobat to Reade-Enable to PDF Form after you have finished working with LiveCycle Desinger. So, every time you change the Form Desing, you need to reader-enable the PDF before you deploy it for production.

There is no need to install any DLL for this purpose.

3. For me, to ensure I have generic and reusable desing and implementation, I am following CSLA .NET framework for the past 4 years. Make sure to check the guide I published on my Google Workspace, and if you have any question, please let me know. The guide is not complete but I am willing to prepare a decent guide, so with you help, we can do it. All you have to do is to get started. I will update the guide everytime you get stuck.

Do you want me to upload the latest version of the code (programs) I have and the latest form desing I have completed?

Tarek.

Avatar

Level 1

Thx for a quick response Tarek.

Mine is a ASP.NET application and the server side generated PDF should be rendered to IE to client.

Thus if i can outline the entire process it would be :

  1. Generate the Template using  LiveCycle Desinger.
  2. Once Template is designed use Acrobat to Reade-Enable to PDF Form, and store it in any location.
  3. A server side .NET componet should be written that will Generate the XDP (XML) and populate the Template.

       

      If i understand right in this place i need to use either PDF library SDK or Acrobat SDK or any third party software to get a complete PDF at server side.

4 . Once i get the PDF, render the PDF to IE to end user.

5. SInce the template is already Reade-Enable, the reader extension feature will be available to the PDF being rendered at IE to user.

6.The end user as per my requirement can save, edit the PDF file as the PDF is reade-enabled?

Correct me or advice me if i missed anything.

Request you to kindly upload the latest doc and code which you had mentioned, it would be really helpful.

TIA

Robin

Avatar

Level 8

Hi Robin,

If you are using ASP.NET, so no need to use SDKs and no need to use the other SDKs you have mentioned.

Make sure to read the guide I have published on Google Docs. It has good info for you to get started.

You only need to use:

1. Windows Server, IIS, ASP.NET and .NET XML APIs.

2. Acorbat Prof. to reader enable the PDF. Once it is reader enabled, then any client can use the PDF to fill and save it off-line. But, you cannot submit outside the browser for example.

After you generate the XML and render the XDP back to the client, if the client has Adobe Reader installed properly with proper integration with the Browser, it will render propery, even of the PDF is not reader enabled. The feature "Reader-Enable" has nothing to do on the server side. It is a client feature.

3. Adobe LiveCycle Desing to desing the forms.

4. Browser like IE8 for the client to click a link to navigate to ASPX page to generate the XML using input parameters, and render XDP (PDF Form) back to the client.

5. The user must have Adobe Reader installed (version must be same or higher than the one you specified when using LC Desinger). Note that Adobe Reader can be installed, and still it will not work. In this case, remove and re-install or repair.

6. Note that Google Chrome does not support Dynamic PDF, so XDP will not render under Chrome. Firefox latest version and IE 8 and IE 9 work fine.

Tarek.

Avatar

Level 1

Hi Tarek,

I am very new to this Livecycle world, I never thought about this before yesterday .

Now I need to create this application ...

I have to connect to a livecycle website from a c# desktop application

and load a form and display the form and submit the form once done.

Now problems are

     1. All this needed to be done offline mode ... user will connect to the server for form

         and then will disconnect user will submit the form .. internet connection will have no guarantee so the application have to handle that part like uploading the data when connectivity is found.

    2. User should not be able to realize that this is a PDF form ...

    3. I do not have any browser unless I embed one in the application

    4. .NET framework 2.0

    5. No third party API can be used.

I saw a phonegap application comes with ES4 .. most probably I need create something like that...

Do you think this is possible ... or I am just wasting my time.

Any advice will be appreciated

Thanks

Shanewaj

Avatar

Level 8

Sorry Shanewaj, just found out about your query.

I hope you made some progress, however, here is my feedback.

I am sure what you are asking for can be done, but since you are asking for a solution, it will be difficult to give any specific answer. There are many approaches to meet your objectives, and you have to start with Adobe Acrobat SDK and use IAC feature (OLE Automation). Download the SDK and you will find a lot of samples. Several years ago, I collected some documents and I have some sample codes which might be of help to you:

Click here to access the code samples

My recommendation is to start by developing a simple working prototype of a very small feature.

Tarek.

Avatar

Former Community Member

Hello All,

I have created a dynamic form using Adobe Livecycle Designer ES2. The form contains a hidden textfield "submit_url" which holds the url value and there's a field of type "button" and control type "regular".

On click of the button ,I have added the following script:

event.target.submitForm({

cURL:

submit_url.rawValue,

cSubmitAs:

"PDF",

cCharset:

"utf-8"

});

The default value for submit_url is set as "pdf". When i open the form using Adobe Acrobat Pro 9, it prompts to "Save a blank copy of form". On click of cancel in the alert box ask to save the form in the local desktop folder named "pdf" {which is the default value for the same).

When i render the form using browser { where the browser pdf action (under browser settings) is set to "Use Adobe Acrobat(in Firefox)". }, onclick of the submit button prompts to "Save a blank copy of form".On click of cancel in the alert box ,doesnot submit the form to the respective URL.

Please provide some ways to do so.

Thanks.

Avatar

Level 8

Hi All,

I am now working on HTML5 forms (mobile forms) and Adaptive Forms with Process Management. Check my posts in Adobe LiveCycle ES4 forums.

I am facing a lot of limitations, and looking for workarounds !

Tarek

Avatar

Level 1

How to Populate database values into existing editable PDF by using asp.net?

Avatar

Level 8

I worked with this project long time ago, so it will be difficult for me to guide you to implement certain requirements.

However, I have done some documentation, and I am pretty sure it will be useful. If you go through the sample code and PDF templates, you will be able to develop your own. Some code is developed in a generic way, which can be easily reused.

See the shared folder below:

Working with Adobe LiveCycle ES2 Forms using ASP.NET - Google Drive

Also, check this folder:

Simple Form Rendering Example using ASP 3 - Google Drive

It has a very simple ASP 3 sample code which will help you understand the concept.

Please spend some time going through the folder content, and let me know if you have specific questions.

Tarek