Expand my Community achievements bar.

Radically easy to access on brand approved content for distribution and omnichannel performant delivery. AEM Assets Content Hub and Dynamic Media with OpenAPI capabilities is now GA.

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

Hi Tarek:

I am really thankful to you for initiating this thread; I printed all the 50 pages of this thread and went through them over a 2 hour reading. Thanks for being not only an initiator but the major active contributor to this thread. Actually, I am not replying to your question addressed in the thread but asking for some inputs from you.

Just FYI; I have worked with LC designer 8.1 for more than a year now. I have developed a few Dynamic XML PDF forms which use ODBC connecting option to pull data from MS Access DB ( all client based) to publish the same on the PDF. This app was a 2-Tier approach.

My current requirement:

I need to develop the ASP.NET version of the same form developed by me earlier in 2008 so that I can publish this form over an IIS for everyone over the internet to use the form on-demand. I will use a .NET application to accept the Input Parameters (Request) for which the data needs to be fetched from DB and published in the PDF form (over the browser). The final PDF published in the web browser needs to be saved in a WORD document since the clients cannot afford Adobe Acrobat in every client.

My Limitations: My case is similar to all the limitations mentioned in this thread. Budget does not permit the following.

1. Cannot buy or install Adobe Reader Extension Server in the Server.

2. Cannot buy or install Adobe Livecycle Designer ES or Adobe Livecycle Forms.

3. Cannot buy or install Adobe Acrobat Pro in all the clients

4. No third party tools are allowed to be installed in the client for any export import purposes.

Only Adobe Reader 9.0 is allowed for all the clients. All clients will have MS office for sure.

My Questions:

1. My complete technical design of the data flow depends on the contained object (PDF form or plain HTML form) rendered in the web browser. The contained object should allow me to save the form embedded in the browser into Word format (saved in the client). Also the word form saved here should have editable form controls for further edits in the manual workflow. I love to use Adobe Livecycle designer since the form look and feel is absolutely great. Do you think I am just trying to waste time? I strongly feel forms are best looking in Adobe LC designer. Do you think I still can use this tool to achieve what I want?

2. Do you think I should just forget about Livecycle and design a pure Visual Studio form or MS Word Form and be done with export to word using some APIs published by Microsoft?

2. Also a question answered by you to PIRZADA from your earlier thread dated June 29 2008. You had mentioned that you were planning to develop .NET Class wrapper for the form submission, initiation and Processing. Do you have that class published anywhere? Or could you please share that to this forum.

I would also appreciate if PIRZADA or anyone like Jeff Lawrence or Vidya could comment on my requirement and suggest an approach or examine my appraoch.

Avatar

Level 8

Hi Kumar,

I am really happy to know that this thread was of value to you.

Here are my quick answers to your questions:

1. Use Adobe Platofrom only if the following criteria is applicable to your situaiton:

- You can afford the cost of Implementation. You can use Adobe LRES which is the ultimate solution and very costly. Or, you can use Single Adobe Acrobat 9 version and Reader Enable the LiveCycle Form on the Server and will give about 70% of the feature provided by Adobe LRES.

- You want to have a ture Paper Replacement and provide the end user with an electronic form in PDF that will take advantage of PDF Security and all the pther features such as annotations ...etc. For example, if the users does not want to save an off-line copy of the form on his PC and does not care about the authenticity of the form, then there is no need for PDF.

- Ability to use the form accross all platforms and reduce the problem of compatibility issues.

- To use Digital Signature, not only to secure the form, but to keep track of all the versions and changes made inside the PDF.

- You need to secure different parts of the form according to the authenticated user (the new requirements I posted in my previous thread). As a matter of fact, this is really a great feature, which I found a solution for.

2. Use HTML Form, aspx Form, or MS Word Doc (rendered on the client from the server), if the above criteria does not apply to you.

3. Yes, I have developed the .NET Class Wrapper, and it was really greate. This new class, not only it will make development easier, also, it will allow me to generate large number of PDFs, and cach the result in Text File (instead of String Variable), to be pushed back to the client (download via response.write) at the end. I will publish the class as soon as I am back form my vacation on 10-Aug-2009. Please send me a reminder if you do not mind.

Tarek.

Avatar

Former Community Member

Hi Tarek.

Thank you very much for your quick response.

Now, to respond to you...

Customer cannot afford Adobe LRES at this point of time. I must tell you, at the outset that the form I am working on is a standard form and the look and feel of it should be so close to the paper form. That is the purpose why we chose Livecycle Designer in the first place. So to answer you, specifically, YES! I want to have pure paper replacement as much as possible ( say 70% close to the original paper form). Customer is willing to live with what I give as web-enabled electronic form but I want to give my best. I know HTML form/ASPX form is anyways known options

So I want to go with what you have told in the first point. to quote you "Or, you can use Single Adobe Acrobat 9 version and Reader Enable the LiveCycle Form on the Server and will give about 70% of the feature provided by Adobe LRES." I hope this means that the I can install and use Single user Adobe Acrobat 9 Professional version (WHICH INCLUDES LC DESIGNER) at the server and Reader Enable the Livecycle form. Yes I can do this. However I need to always remember that any form shown with values on the broswer should be editable and, I should be able to save the browser form into a word document.

Now my question: Using your idea I came out with the following logic. will this logic work?

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

Step 2: Fetch the relevant form data (data sets) from the database for the INPUT params

Step 3: Programmatically Generate instance(s) of the PDF (I call it generated PDF(s)) using the LC designer PDF form by populating the fetched data (sometimes this generation could result in a multi-page form and/or multiple instances of the form)

Step 4: Store the generated PDF(s) in a SOURCE folder inside the server

Step 5: Reader Enable the generated PDF(s) "programmatically" using the SINGLE ACROBAT 9 Professional installed in the server( This is your idea!!!!!)

Step 6: Store the Reader Enabled generated PDF in a DESTINATION folder

Step 7: Now show the browser (response object) with Reader Enabled generated PDF extracted from the DESTINATION folder

Step 8: Now from the web broswer allow save of this form into MS-Word ( how this will happen - donot know now..hmm I need to test it out)

Please feel free to criticize if any of the steps mentioned above is beyond your imagination. If I am sounding too abstract for you, please feel free to comment. I would wait for your valuable feedback. In the meanwhile let me do a Hello world run of the whole logic to test it out. Shall keep you posted.

Besides. I will, for sure, remind you after Aug 10, 2009 regarding the class you will be publish it for this group

Regards

Kumar

Avatar

Level 8

Hi Kumar,

This is to confirm your approach and clarify some points.

- The logic you have mentioned is correct, excpet for the points mentioned here.

- I do not see the need to convert PDF back to word, unless there is a direct requirement to change the PDF Content in MS Word. This kind of requirement is outside the scope of LC Desinger and there is no direct and easy way that I know to do that programatically from within PDF say using JavaScript.

If you want to do that, then you have to give the user 2 options: 1. Generate PDF, 2. Generate MS Word. You have to write 2 separate ASP.NET Programs to render the PDF and MS Word, separately, from the Server to the client using Response.ContentType + Response.Write (bla bla bla) + Response.end.

- You can definitally use single Adobe Acrobat Prof. 9 to Desing the Form and Reader-Enable it. But, you will lose some of the advanced features provided by Adobe LRES such as Allow Using Digital Signature under Adobe Reader. I am not exactly sure what else you will loose.

- When you generate the PDF using XDP Format, there is no way you can save the result in PDF Binary Format. I hope I made this point clear. At this point in time, you can only get a TEXT Representation of the XDP File (XML Format). At any point in time, you can "Response.write" the content of this file back to the client, and it will work as long as the ContentType is set properly.

At this point in time, you can Merge Data with the PDF Form. So, here, get all the data you want from the Database using .NET APIs, and merge it with the PDF Form.

- When the PDF File is Rendered back to the client (generated for the first time), and you provided a "Submit" button which will submit the Data + PDF, then, on the server, you can receive the submitted stream which has the Form Field Values (Data) + the PDF Binary (under the "chunk" element) in Base64 String Format, which can be converted easily to a Binary Format using .NET APIs, and saved as PDF on the Server.

- After the PDF File is saved as PDF Binary Format, then, there is no easy way you can push more data back to the PDF from the Server. You can do that, but it will require very complex programming which is not really worth it. Unless, however, you are using some Adobe LC Server Product (I forgot the name) which will enable such functionality, but it will cost a lot.

- After the PDF is Generated and finally saved on the Server using a well-defined naming criteria (use GUID if you like), you have to save all the forms under a special web folder. Then, you have to generate a URL link to the generated PDF, and either save the URL in a record in the Database, or send the user an email with a link to the PDF, or just give him confirmation as Response.Write message. This way, the user can refer back to the PDF to complete the work later, to allow another user to complete his part.

- The "Submit" logic on the PDF Button, and the related ASP.NET part, will work correctly in both cases: 1. After the PDF is Generate for the first time, 2. After it was saved, and rendered back to the client using direct URL. But, you have to wirte the .NET part in a flexible way to check if the file exists, and if you want to keep different versions after each submit.

- To generate the form in MS Word Doc, kindly do google on this as I have never done this before, but I am sure it is only a matter of generateing HTML Tags properly, and set the Respose.ContentType to indicate MS Word Doc, and finally Response.Write ....etc. Maybe it is much simpler to ask the user to try "Save As" the PDF to MS Word, but he must have Acrobat I think.

I hope this will help you implement your project.

Tarek.

Avatar

Former Community Member

Hi Tarek:

Cannot see such a sincere responder to questions raised by me. Cannot thank you enough.

Now I need to respond with some real "action" which will take sometime. I will test the options given by you and send you the code whenever it is completely ready..may be it will take a few weeks for me since I do lots of other things along with this development. As of now I would go with all your ideas. I will not be able to respond in the forum as of now anything until I see some results from my side.

Shall remind you about the class you have written after Aug 10, 2009.

Thanks once again

regards

Kumar

Avatar

Former Community Member

Hi Tarek,

It's been some time since I visited the forum. I had a previous request to create dynamic PDF and populating the data using XML and .net.
I was able to complete it and it's working fine, I had multiple choices provided to the user as a radio button list and based on selection generated the documents.
Now they want checkboxes instead of radio buttons, so I have to merge the multiple xdps created to a single xdp.
each selected option is a unique pdf file, can you provide me some suggestions for merging xdps at runtime based on selection?
We are not planning to use any third party tools for pdf merge, I have only adobe livecycle and .Net to work with.

Thanks,
Vidya

Avatar

Level 8

Hi Vidya,

I did not understand your requirements. If you can clarify or provide some layout as a sample to give more details, I will try to help.

Tarek.

Avatar

Former Community Member

Hi Tarek,

Currently I have three documents A,B and C.

I have provided the user a radio button to select these documents, based on the selection I generate a dynamic pdf with values populated from database.

The requirement is instead of generating a single document at a time, I should provide the user to select multiple documents and when selected I should generate a single pdf with doc A and B combined as one.

When I Provide a checkbox selections, the user selects doc A,B then I should generate the dynamic pdf A, B and merge both the documents as a single document and display to the user.

I am not planning to use any third party pdf tools for this. Is it possible using Adobe and .Net to merge documents as required.

Sorry for not being clear previously.

Thanks,

Vidya

Date: Tue, 15 Sep 2009 19:54:49 -0600

From: forums@adobe.com

To: vidya_radkrish@hotmail.com

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

Hi Vidya,

I did not understand your requirements. If you can clarify or provide some layout as a sample to give more details, I will try to help.

Tarek.

>

Avatar

Former Community Member

Hi Tarek,

I am very new to this adobe life cycle though i learnt alot from your favorite post in less time. Really thank you very much,

My requirement is as below,  i need help / suggession from you..

1. The user will login to the system, Then we show two section on fill able pdf form

          a) Part I: preloaded user information, I am able to achieve this by creating xml file after user successful login, after that I can embed this xml file to pdf form. (DONE)

          b) Part II set of questions need to be answer by user.

I need help on below issue,

1. I need to validate the part II, need to check for user answered all the questions or not. (How to check can you provide any sample code available)

2. I need to save pdf (with data key-in by user) after user click submit button [which located on pdf form].(How to save pdf file in Server folder)

[I refered in from this article and notice that using "chunk" convert binary data to pdf and save to server, am i correct?]

3. I had signature field on the form, so when save as pdf can we save form including signature field.(is this can be achieved)

[After i sign the form using signature field why received save form dialog? do we can control this?]

I am using Adobe life cycle 8.2 to design pdf form, and client will use adobe reader to fill up the form.

Thanks in advance.

Thanks.

Avatar

Level 8

Hi $Aravind.K$

I have read your post and I will be able to reply by next coming Sunday God Willing. I am preparing for my return to the Office after comleting my Eid Vacation and I have very limied access to the Internet. Sorry about that.


Tarek.

Avatar

Former Community Member

I did place button(Normal button) on pdf form, and wrote validation in button click event, its working fine for me, the page validation and singnature validation(weather signed or not) is in place.

afte i click the submit button i am using below code..

var myURL = "../Acknowledge.aspx";

var myDoc = event.target;

myDoc.submitForm({cURL

: myURL,cSubmitAs: "PDF",cUsageRights: submitFormUsageRights.RMA});

the page redirecting correctly... but i am not sure how to save pdf file to server folder from here...

I need to save pdf (with data key-in by user) after user click submit button [which located on pdf form].(How to save pdf file in Server folder)

I had signature field on the form, so when save as pdf can we save form including signature field.(is this can be achieved)

[After i sign the form using signature field why received save form dialog? do we can control this?] - i figure out this, we can't control this if we open form in adobe reader. But this won't(save dialog) appear if we open pdf form using broswer like IE.

Avatar

Level 8

Hi $Aravind.K$,

I have collected for you the following lines of code to help you save the PDF along with all signtures and all data as is in binary format.

Simply, the code will retreive the submitted XDP and PDF from the imput stream in String Format, get the "chunk" element, and convert it from string back to binary and write it as PDF File using a stream writer.

The code below must be placed in ASPX Page Load Event which is the submit URL:

Dim fso As New Scripting.FileSystemObject

Dim fs As System.IO.FileStream = Nothing
Dim bw As System.IO.BinaryWriter = Nothing

Dim sreader As New System.IO.StreamReader(Page.Request.InputStream)
Dim xmlData As String = sreader.ReadToEnd()
Dim xmldoc As New System.Xml.XmlDataDocument
Dim chunk As String
Dim buffer() As Byte

Dim PDFFileName as string = "thefilename.pdf"

xmldoc.LoadXml(xmlData)

chunk = xmldoc.GetElementsByTagName("chunk")(0).InnerXml

'

' Here you can validate if chunk is empty, and stop or report unexpected error.

'
buffer = Convert.FromBase64String(chunk)
If fso.FileExists(PDFFileName) Then
   fso.DeleteFile(PDFFileName, True)
End If
fs = New System.IO.FileStream(PDFFileName, IO.FileMode.Create)
bw = New System.IO.BinaryWriter(fs)
bw.Write(buffer)
bw.Close()
bw = Nothing
fs.Close()
fs = Nothing


On the client side PDF Form, the JavaScript Submit Button, must have the following code or similar:

event.target.submitForm(
{cURL: "http://blablabla/submiturl.aspx", 
aPackets:["datasets","pdf"], cSubmitAs: "XDP"});

For Validation, you can use JavaScrip to Validate the answers of the questions, and you can always push the answers and the questions from the server to the client same like any other data fields using repeating format. This will make your form more dynamic, but this is very advanced and requires lots of programming effort.

I hope this will be of help to you.

Tarek.

Avatar

Former Community Member

Dear Tarek,

Thank you very much for your response.

with your help i manage to complete the preocess(requirement). Now every thing looks fine.

can i ask you what are the steps you follow to minimize the pdf size. because my pdf file is about 400K + (which contain 3 pages - no images only static objects - but i use font calibri which is not default font in adobe). Becuase i am posting this pdf form on web, if the file size is more it may mitigate the performance.(i save the pdf also as static pdf)

Thanks.

Regards,

Aravind.K

Avatar

Level 8

Hi Aravind.K,

Try the following:

Goto Form Properties, Save Options, and deselect the option "Generate Accessibility Info...". Save the form, and see if this will be of help.

Also note that every time you sign the form, a complete full version of the PDF is save as a snapshot in the signature itself. Later, you can view the signed version by right-click the signature and select view signed version. This will also increase the PDF size, but, it will protect the document authenticity and integrity.

Tarek.

Avatar

Former Community Member

Dear Tarek,

Many thanks for your prompt response.

i did save the form by uncheck "Generate Accessibility Info" [in save options], but there is not file size change. is any other options will help to minize the document size.

Thank you very much.

Avatar

Level 2

Hi tarekahf,

Could you help me with an issue?  I was able to successfully load and store interactive PDF through ASP.NET C# using the script you provided.  My issue is that I am unable to prepopulate the PDF at initial load.  I followed your code by creating XML but it doesn't seem to work.  Please help.  It is all I'm missing.

Avatar

Former Community Member

Response.ContentType = "application/vnd.adobe.xdp+xml"

            Dim Responsestring As New StringBuilder()

            Responsestring.Append("<?xml version='1.0' encoding='UTF-8'?>")

            Responsestring.Append("<?xfa generator='AdobeDesigner_V8.2'?>")

            Responsestring.Append("<xdp:xdp xmlns:xdp='http://ns.adobe.com/xdp/'>")

            Responsestring.Append("<xfa:datasets xmlns:xfa='http://www.xfa.org/schema/xfa-data/1.0/'>")

            Responsestring.Append("<xfa:data>")

            Responsestring.Append("<form1>")


            Responsestring.Append("<FieldID>" & --Value-- & "</FieldID>")


            Responsestring.Append("</form1>")     

         

             Responsestring.Append("</xfa:datasets>")


            Responsestring.Append("<pdf href='http://" + Page.Request.ServerVariables("HTTP_HOST").ToString & Page.Request.ApplicationPath +  "Test.pdf' xmlns='http://ns.adobe.com/xdp/pdf/' />")


            Responsestring.Append("</xdp:xdp>")


            Response.Write(Responsestring)


            Response.Flush()


            Response.End()   

Avatar

Level 1

Avatar

Level 2

Hi Tarek AHF & $Aravind.K$,

Thank you both for your input.  I tried both of your suggestions but I still couldn't get the form to populate.  I was able to extract the XML data of the form with a manually entered value just as Tarek has suggested but I still wouldn't prepopulate the field at load.  Here's my code and the generated XML from manual input.

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

-<topmostSubform>
<TextField1>Test</TextField1>
<TextField2 />
<TextField3 />
<TextField3 />
<TextField4 />
<TextField4 />
<TextField3 />
</topmostSubform>

Response.ContentType =

"application/vnd.adobe.xdp+xml";

StringBuilder XDFdataset = new StringBuilder();

XDFdataset.Append(

"<?xml version='1.0' encoding='UTF-8'?>");

XDFdataset.Append(

"<?xfa generator='AdobeDesigner_V8.2'?>");//("<?xfa generator='XFA2_4' APIVersion='2.6.7120.0'?>");

XDFdataset.Append(

"<xdp:xdp xmlns:xdp='http://ns.adobe.com/xdp/'>");

XDFdataset.Append(

"<xfa:datasets xmlns:xfa='http://www.xfa.org/schema/xfa-data/1.0/'>");

XDFdataset.Append(

"<xfa:data>");

//XDFdataset.Append(@"<form1>");

XDFdataset.Append(

"<topmostSubForm>");

XDFdataset.Append(

"<TextField1>" + "Test" + "</TextField1>");

//XDFdataset.Append(@"<Tester>");

//XDFdataset.Append("Test");

//XDFdataset.Append(@"</Tester>");

//XDFdataset.Append("</TextField1>");

XDFdataset.Append(

"</topmostSubForm>");

//XDFdataset.Append(@"</form1>");

XDFdataset.Append(

"</xfa:data>");

XDFdataset.Append(

"</xfa:datasets>");

XDFdataset.Append(

"<pdf href='" + HttpContext.Current.Server.MapPath("~/Permits/FRM19.pdf") + "' xmlns='http://ns.adobe.com/xdp/pdf/'/>");

//XDFdataset.Append("<xfdf xmlns='http://ns.adobe.com/xfdf/' xml:space='preserve'>");

//XDFdataset.Append("<annots/>");

//XDFdataset.Append("</xfdf>");

XDFdataset.Append(

"</xdp:xdp>");

Response.Write(XDFdataset);

Response.Flush();

Response.End();

The above code snippet displays the PDF form but without the value specified.  Please help!

Avatar

Level 8

There may be something wrong with your adove reader/acrobat installation.

Just to start clean, remove all adobe reader/acrobat, and re-install the latest version of reader/acrobat.

Open the empty pdf in reader, and use import to import the same generated xml into the form using the import menu option.

Also, remove the "Response.flush()". It used to cause problems for my case.

Tell me what happens.

Tarek.

Avatar

Level 2

Hi tarekahf,

Thanks for your suggestions! You've been a great help!

I decided to use iTextSharp instead to manipulate my PDF forms.  It is more flexible.

Thank you!