Skip navigation

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

Mar 26, 2007 9:38 PM

  Latest reply: anand.padmanabhan, Feb 23, 2013 12:40 PM
Replies 1 2 3 4 5 6 7 Previous Next
  • Currently Being Moderated
    Jan 18, 2010 4:33 PM   in reply to tarekahf

    Hi Tarek,

     

         I have only used iTextSharp to populate textfields and manipulate the visibility of buttons inside a PDF.  You can populate any objects inside a PDF as long as you assign a definite name per object.  This is as far as I have used the dll.  It actually took me awhile to understand how to use it as there aren't a lot of help on the web

     

    Goodluck on your new challenge

     
    |
    Mark as:
  • Currently Being Moderated
    Jan 28, 2010 5:19 AM   in reply to tarekahf

    Hello can you send me

    a working copy of a PDF with asp or PDF

    that will take the users Name and when the user Clicks the SAVE AS button the pdf file will go to a folder on the server with the users name form the PDF file so we know what file each user saves. You can email me at fredssmith@mail.com 

     

    Help needed please

     
    |
    Mark as:
  • Currently Being Moderated
    Jan 29, 2010 10:20 PM   in reply to tarekahf

    Hi Tarek,

     

    Thank you very much for the reply.

     

    I have one  doubt. You mentioned "need at least one license from Adobe Acrobat if you go for client-side application", that means we have to buy licence in each client mechine in which we install the application or only in my developemt mechine ?  If I install free Adobe Acrobat reader in end user mechine, this will work or not. I can include Adobe dll in my setup if required. Bcz I can't tell all end users  to buy Adobe license.

     

    Thanks & Regards

    Ajo Joseph

     
    |
    Mark as:
  • Currently Being Moderated
    Jan 29, 2010 10:44 PM   in reply to tarekahf

    Hi Tarek,

     

    Thank you very much for the information.

    In my case, reading data from a filled form and updating data back to database is not that much important. I need to dynamically fill the form using the data from my database before I email the forms to end users. For this purpose can you give any sample code/Docuementation ? I am going through VBJavaScript.Pdf. I am planning to continue with VB.Net, not ASP/WEB, bcz I am familiar with VB.NET and C#.NET.

     

    Thanks & Regards

    Ajo Joseph

     
    |
    Mark as:
  • Currently Being Moderated
    Jan 30, 2010 10:17 PM   in reply to tarekahf

    Hi Tarek,

     

    Sorry to disturb you.

    I got some sample codes from Acrobat 9 SDK c# samples, and that code is enough for my purpose. I have attached that code below. but the issues is I am getting one error while running this code "No document is currently open in the Acrobat Viewer" when it reach on red color line. could u please check this. In this code  Object formApp      ( IAFormApp formApp = new AFormAppClass() ) is not associated to any other objects like AcroAppClass, theny how its getting form details ? its taking form from currently opened Acrobat window ? I spent lot of time in google to get a good documentation of these classes, but not available, any idea about these documentations ?

     

    Thanks in advance

     

    Ajo Joseph

     

     

     

     

    using System;
    using System.Collections;
    using System.Windows.Forms;
    using System.ComponentModel;
    using Acrobat;
    using AFORMAUTLib;

    namespace FillFormCS
    {
    /// <summary>
    /// Summary description for FillFormCS.
    /// </summary>
    class FillFormCS
    {
      // Hard-coded file name, it can be changed when needed.
      /// <summary>
      /// The main entry point for the application.
      /// </summary>
      [STAThread]
      static void Main(string[] args)
      {
                String FORM_NAME = Application.StartupPath + "\\..\\..\\..\\..\\..\\TestFiles\\SampleForm.pdf";
       // Initialize Acrobat by cretaing App object.
       CAcroApp acroApp = new AcroAppClass();
      
       // Show Acrobat Viewer
       acroApp.Show();

       // Create an AVDoc object
       CAcroAVDoc avDoc = new AcroAVDocClass();

       // Open the pdf
       if(!avDoc.Open (FORM_NAME, ""))
       {
        string szMsg = "Cannot open" + FORM_NAME + ".\n";
        Console.WriteLine(szMsg);
        return;
       }

       // Create a IAFormApp object, so that we can access the form fields in
       // the open document
       IAFormApp formApp = new AFormAppClass();

       // Get the IFields object associated with the form
       IFields myFields = (IFields)formApp.Fields;

       // Get the IEnumerator object for myFields
       IEnumerator myEnumerator = myFields.GetEnumerator();

       bool bFound = false;

       // Fill the "Name" field with value "John Doe"
       while(myEnumerator.MoveNext())
       {
        // Get the IField object
        IField myField = (IField)myEnumerator.Current;

        // If the field is "Name", set it's value to "John Doe"
        if(myField.Name == "Name")
        {
         bFound = true;
         myField.Value = "John Doe";
         break;
        }
       }

       if(bFound)
        Console.WriteLine("Sucessfully changed the \"Name\" field value to \"John Doe\".");
       else
        Console.WriteLine("Failed to locate the \"Name\" field in the form.");
      }
    }
    }

     

     

     
    |
    Mark as:
  • Currently Being Moderated
    Apr 28, 2010 8:27 PM   in reply to tarekahf

    thanks this is really good...

     

     

     

     

     

     

     

     

     

    Date: Tue, 27 Apr 2010 08:46:12 -0600

    From: forums@adobe.com

    To: vidya_radkrish@hotmail.com

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

     

     

     

    I have developed a Simple Class to defined and render a PDF Form. It will simplify your job to a great extent:

     

     

     

    Imports System.IO

    <Serializable()> _

    Public Class AdobeLiveCycleForm

     

    #Region "  Business Methods  "

        Private Shared mXDPHeader As String

        'Private mXDPData As String

        Private mXDPFooter

        Private mXDPData As Text.StringBuilder

        Private mDoWriteToFile As Boolean

        Private mFileName As String

        Private mOutputFile As StreamWriter

     

        Public ReadOnly Property XDPHeader() As String

            Get

                Return mXDPHeader

            End Get

        End Property

     

        Public Property XDPData() As String

            Get

                Return mXDPData.ToString

            End Get

            Set(ByVal value As String)

                mXDPData.Length = 0

                mXDPData.Append(value)

                If mDoWriteToFile Then

                    mOutputFile.Close()

                    IO.File.Delete(mFileName)

                    mOutputFile = New System.IO.StreamWriter(mFileName, False, Text.UTF8Encoding.UTF8)

                    mOutputFile.Write(mXDPHeader & mXDPData.ToString)

                End If

            End Set

        End Property

     

        Public ReadOnly Property XDPFooter() As String

            Get

                Return mXDPFooter

            End Get

        End Property

     

        Public ReadOnly Property FileName() As String

            Get

                Return mFileName

            End Get

        End Property

     

        Public ReadOnly Property GetXDP() As String

            Get

                Return mXDPHeader & mXDPData.ToString & mXDPFooter

            End Get

        End Property

     

        Public Sub CloseXDP()

            If mDoWriteToFile Then

                mOutputFile.Write(mXDPFooter)

                mOutputFile.Flush()

                mOutputFile.Close()

                mOutputFile.Dispose()

                mOutputFile = Nothing

            End If

        End Sub

     

        Public Sub CloseFile()

            If mDoWriteToFile Then

                Try

                    mOutputFile.Flush()

                    mOutputFile.Close()

                    mOutputFile.Dispose()

                    mOutputFile = Nothing

                Catch ex As Exception

     

                End Try

            End If

        End Sub

     

        Private Sub InitStringBuilder()

            If mXDPData Is Nothing Then

                mXDPData = New Text.StringBuilder

            End If

        End Sub

     

        Public Sub AppendXDPData(ByVal NewXDPData As String)

            mXDPData.Append(NewXDPData)

            If mDoWriteToFile Then

                mOutputFile.Write(mXDPData.ToString)

                mXDPData.Length = 0

            End If

        End Sub

     

        Public Sub Render(ByVal WebResponse As System.Web.HttpResponse)

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

            If mDoWriteToFile Then

                WebResponse.WriteFile(mFileName)

                'WebResponse.TransmitFile(mFileName)

            Else

                WebResponse.Write(GetXDP)

            End If

            'WebResponse.End()

        End Sub

     

    #End Region

     

    #Region " Constructors "

        Public Sub New(ByVal XDPFormLink As String)

            Dim strXMLBuilder As Text.StringBuilder = New Text.StringBuilder

     

            If String.IsNullOrEmpty(mXDPHeader) Then

                '

                ' Build the Constant XDP Header which is common for all forms

                '

                strXMLBuilder.Length = 0

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

                strXMLBuilder.Append("<?xfa generator='AdobeDesigner_V7.0' APIVersion='2.2.4333.0'?>")

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

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

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

                mXDPHeader = strXMLBuilder.ToString

            End If

     

            InitStringBuilder()

     

            '

            ' Build the XDP Footer part

            '

            strXMLBuilder.Length = 0

            strXMLBuilder.Append("</xfa:data>")

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

            '

            ' Point the XPD to the PDF Form created under Adobe LiveCycle Desinger

            '

            strXMLBuilder.Append("<pdf href='" & XDPFormLink & "' xmlns='http://ns.adobe.com/xdp/pdf/' />")

            '

            ' Close the XPD File

            '

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

            mDoWriteToFile = False

            mXDPFooter = strXMLBuilder.ToString

        End Sub

     

        Public Sub New(ByVal XDPFormLink As String, ByVal OutputFilePath As String)

            Me.New(XDPFormLink)

            mFileName = OutputFilePath

            mOutputFile = New System.IO.StreamWriter(mFileName, False, Text.UTF8Encoding.UTF8)

            mDoWriteToFile = True

            mOutputFile.Write(mXDPHeader)

        End Sub

     

        Private Sub New()

     

        End Sub

    #End Region

     

        Protected Overrides Sub Finalize()

            MyBase.Finalize()

            Try

                If Not mOutputFile Is Nothing Then

                    mOutputFile.Flush()

                    mOutputFile.Close()

                    mOutputFile.Dispose()

                End If

            Catch ex As Exception

            Finally

                mOutputFile = Nothing

            End Try

        End Sub

    End Class

     

     

    Also, I developed this "LabRequestReport" class, which uses the above class, also, it uses "XmlDocument" object to generate the XML, much more simplere than before:

     

    Imports System.Xml

    Namespace Clinic

     

        Public Class LabReport01PDF

            Inherits AdobeLiveCycleForm

     

            Public Sub New(ByVal theLabRequestID As String)

                MyBase.New(Configuration.ConfigurationManager.AppSettings("LabReport0 1URLRoot").ToString)

                Dim theLabRequest As LabRequest

                Dim theLabItem As LabRequestItem

                Dim theLabItems As Csla.SortedBindingList(Of LabRequestItem) = Nothing

                Dim theStaffBasicInfo As StaffBasicInfo

                Dim theLastCatg As String

                Dim CurrCatg As String

                Dim theXML As XmlDocument

                Dim xmlDecl As XmlDeclaration

                Dim theLabInfo As XmlElement

                Dim theLabGroup As XmlElement

                Dim theNode As XmlElement

                Dim theLabReport01 As XmlElement

                Dim theTableData As XmlElement = Nothing

                Dim theTableDataRow As XmlElement = Nothing

     

                '

                ' Generate XML String which will be used as a DataSource for the

                ' LabReport01.PDF LiveCycle Form.

                '

                ' The output XML must match the Sample XML File "LabReportTestData.xml".

                '

                theLabRequest = LabRequest.GetLabRequest(theLabRequestID)

                theStaffBasicInfo = StaffBasicInfo.GetStaffBasicInfo2(theLabRequest.PatientID)

                theXML = New Xml.XmlDocument()

                'initialize the report master data

                theLabReport01 = theXML.CreateElement("LabReport01")

                theLabInfo = theXML.CreateElement("LabInfo")

     

                theNode = theXML.CreateElement("StaffID")

                theNode.InnerText = theLabRequest.PatientID

                theLabInfo.AppendChild(theNode)

     

                theNode = theXML.CreateElement("Name")

                theNode.InnerText = theLabRequest.PatientName

                theLabInfo.AppendChild(theNode)

     

                theNode = theXML.CreateElement("Dept")

                theNode.InnerText = theStaffBasicInfo.StaffDept

                theLabInfo.AppendChild(theNode)

     

                theNode = theXML.CreateElement("Sex")

                theNode.InnerText = theStaffBasicInfo.StaffSex

                theLabInfo.AppendChild(theNode)

     

                theNode = theXML.CreateElement("DoB")

                theNode.InnerText = theStaffBasicInfo.DOB

                theLabInfo.AppendChild(theNode)

     

                theNode = theXML.CreateElement("Nationality")

                theNode.InnerText = theStaffBasicInfo.Nationality

                theLabInfo.AppendChild(theNode)

     

                theNode = theXML.CreateElement("Doctor")

                theNode.InnerText = theLabRequest.DoctorName

                theLabInfo.AppendChild(theNode)

     

                theNode = theXML.CreateElement("LabDate")

                theNode.InnerText = theLabRequest.LabRequestDateDMYStr

                theLabInfo.AppendChild(theNode)

     

                theNode = theXML.CreateElement("LabNo")

                theNode.InnerText = theLabRequest.LabRequestID

                theLabInfo.AppendChild(theNode)

     

                theNode = theXML.CreateElement("ReportDate")

                theNode.InnerText = Now.ToString("dd/MM/yyyy hh:mm:ss tt").ToLower

                theLabInfo.AppendChild(theNode)

     

                theNode = theXML.CreateElement("Comment")

                theNode.InnerText = theLabRequest.LabComments

                theLabInfo.AppendChild(theNode)

     

                theNode = theXML.CreateElement("Tech")

                theNode.InnerText = theLabRequest.TechnicianName

                theLabInfo.AppendChild(theNode)

     

                theLabReport01.AppendChild(theLabInfo)

                'populate the report with the item details

                'create a sorted list of lab result items

                If Not theLabRequest.RequestItems Is Nothing Then

                    theLabItems = New Csla.SortedBindingList(Of LabRequestItem)(theLabRequest.RequestItems)

                    theLabItems.ApplySort("LabReport01Sort", ComponentModel.ListSortDirection.Ascending)

                End If

                theLastCatg = "*"

                theLabGroup = Nothing

                For Each theLabItem In theLabItems

                    CurrCatg = theLabItem.LabTestCatg

     

                    If theLastCatg = "*" Or theLastCatg <> CurrCatg Then

                        'create Group if first time or there is a break

                        If Not theLabGroup Is Nothing Then

                            'if this is not the first time, append the last group

                            'to the Lab Report

                            theLabGroup.AppendChild(theTableData)

                            theLabReport01.AppendChild(theLabGroup)

                        End If

                        'initialize group header and Table Data

                        theLabGroup = theXML.CreateElement("LabGroup")

                        theNode = theXML.CreateElement("Lab")

                        theNode.InnerText = theLabItem.LabTestCatg

                        theLabGroup.AppendChild(theNode)

                        theTableData = theXML.CreateElement("TableData")

                    End If

     

                    'populate the table data with Lab Results.

                    theTableDataRow = theXML.CreateElement("TableDataRow")

                    theNode = theXML.CreateElement("TestCode")

                    theNode.InnerText = theLabItem.LabTestName

                    theTableDataRow.AppendChild(theNode)

     

                    theNode = theXML.CreateElement("Result")

                    theNode.InnerText = theLabItem.LabTestResult

                    theTableDataRow.AppendChild(theNode)

     

                    theNode = theXML.CreateElement("RefRange")

                    theNode.InnerText = theLabItem.RefRange

                    theTableDataRow.AppendChild(theNode)

     

                    theTableData.AppendChild(theTableDataRow)

     

                    theLastCatg = CurrCatg

                Next

                If Not theLabGroup Is Nothing Then

                    'this is the last group, append it to the Lab Report

                    theLabGroup.AppendChild(theTableData)

                    theLabReport01.AppendChild(theLabGroup)

                End If

                theXML.AppendChild(theLabReport01)

                xmlDecl = theXML.CreateXmlDeclaration("1.0", "utf-8", Nothing)

                'theXML.InsertBefore(xmlDecl, theLabReport01)

                Me.XDPData = theXML.InnerXml

            End Sub

     

     

        End Class

    End Namespace

     

    I hope this will be of help to all of you.

    >

     
    |
    Mark as:
  • Currently Being Moderated
    Jul 22, 2010 9:12 AM   in reply to Vidya_radkrish

    Hi Tarek,

     

       Thanks for this wonderful forum as it helped me achieving 1st part of prepopulating the values in pdf form from ASP.NET.

     

    Currently when I call pdf form from ASP .Net , it launches Acrobat reader and displays the PDF with pre-populated value. However when I try to submit the form again using following code :

     

    event.target.submitForm( {cURL: "http:/localhost:4147:/website3/default.aspx", aPackets:

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

     

    Acrobat reader gives the error "Nothing done" and it's not going ahead.

     

    Do we need any server component for this ? We are only using Adobe Live Cycle designer ( Acrobat Pro ) but not using Reader externsion.

     

    Your reply would be greatly appreciated.

     

    Thanks & Regards,

    Anup.

     
    |
    Mark as:
  • Currently Being Moderated
    Aug 10, 2010 11:10 AM   in reply to tarekahf

    Hi Tarek,

     

    We have an ASP.NET 3.5 application that is serving PDFs and works perfectly in IE 6 but has some bad behavior in IE 7.

     

    We are using Forms Authentication, cookies, session variables, and Master pages. Our application is running in IIS on Server 2003. The application is used in our intranet only so we control all the workstations. All are XP SP2. Some have IE 6, some have IE 7.  Reader is version 9.3.3 on all PCs.

     

    Our PDFs were created using LiveCycle Designer 8.2 and we are using LiveCycle Reader Extension Server to enable the docs. All our docs have signatures using Topaz signature pads and a button that saves the document to a network server then submits data back to the ASP.NET app using JavaScript: submitForm. Enabled PDFs are stored in subdirectory of the application on the web server.

     

    The user can select documents and navigate through the set of documents, signing and saving. Each document is loaded in an iframe on our navigation page. The iframe src is set to an aspx page that creates XDP containing data to fill in the PDF and uses

    Response.Clear()

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

    Response.Write(string containing valid XDP)

       Response.End()

     

    As I said, IE 6 is fine, but in IE 7: some time after the first document but not on any particular document, a PDF will “bust out” of the iFrame and take over the application window, losing the ability to navigate through the remaining documents.

     

    Here are some ideas we had about what might be causing it but did not find any resolution

    • some setting in IE 7 or Reader or IIS
    • file associations
    • having acrobat and reader and/or multiple version of reader on a PC: we tried on a PC that only had Reader 9.3.3, same bad behavior
    • PDF files are in the same domain so the “cross-domain” security issue should not be a factor

    These are some settings were tried:

    -          Internet Options -> Security -> Custom Level -> Check the Enable(not secure) radio button for "Launching programs and files in an IFRAME"

    -          Internet Options -> Security -> Custom Level -> Check the Enable(not secure) radio button for "Navigate sub-frames across different domains"

    -          Internet Options -> Advanced -> Check the option "Empty Temporary Internet Files folder when browser is closed"

    -          Tools -> Manage Add-ons -> Disabled and Enabled the Adobe PDF Link Helper.

    -          In Adobe - Edit -> Preferences -> Internet -> Unchecked "Allow Fast Web View"

    -          In Adobe - Edit -> Preferences -> Internet -> Unchecked "Allow speculative downloading in the background"

     

    Any ideas would be greatly appreciated!

     

    Thanks…

     
    |
    Mark as:
  • Currently Being Moderated
    Aug 12, 2010 8:35 AM   in reply to tarekahf

    Hi Tarek,

    Thank you for your quick response. 

     

    We tried your suggestions:

    1. In the ASPX Page which is rendering the XDP, make sure it does not have any HTML Markup in the BODY section. Comment out all markups. Then, remove the command "response.clear()" from the code-behind. Make sure nothing is rendered before the command "response.ContentType=...",

                ~ No change in behavior

               

    2. Try using a direct link to a PDF not to ASPX Page. If this works, then the problem is most likely from "response.clear()".

       ~Direct to PDF: Fixes bad behavior SEE ADDITIONAL COMMENTS BELOW

     

    3. Check the complete documentation of IFRAME and try to find a way to tweak its behaviour.

          ~ Tried various things to no avail.

    4. Try using OBJECT or EMBED tags instead of IFRAME. Try using a Direct Link to PDF and also a link to the same ASPX page.

          ~ Tried EMBED tag, caused an ERROR in html source:

                      Validation (XHTML 1.0 Transitional): Element ‘embed’ is not supported.

       ~ Tried OBJECT tag.

      1. Aspx – always takes over parent window in both IE6 and IE7
      2. Direct to PDF – PDF loads in object, page that submitForm submits to takes over parent window.

     

    5. Try with FireFox and IE8. This could be a nasty IE7 bug.

          ~ Not an option at this time:

    a.       Firefox:  we only use IE

    b.       IE8: One of our third party apps isn’t compatible

    Here are my new questions:

    1. Can we push data into PDF without XDP and server up the PDF instead of the XDP? I know it can be done with LC Form Server, but that is not in our budget.

    2. In your response you said:

    “I never tried using IFRAME for rendering PDF (XDP) using response.write(), beucase I know this is not a recommended way, besides, I understand that IFRAME is also not a recommended approach in general.”

    Other than IFRAME, OBJECT, and EMBED, is there another way to embed a PDF in a page? We don’t want to pop a window or replace our navigation window as the user will have multiple PDFs to sign and save.

    3. How can we be 100% sure that there is no additional markup in our page?

    Here is the html side of the page. This was the barest .Net would let us make the html without causing an error.

    <%@ Page Language="vb" AutoEventWireup="false" CodeBehind="OurPage.aspx.vb" Inherits="OurDocApp.OurPage" %>

     

    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

     

    <html>

    <head runat="server">

        <title></title>

    </head>

    <body>

    </body>

    </html>

    Thanks again for your help.

     
    |
    Mark as:
  • Currently Being Moderated
    Aug 13, 2010 7:11 AM   in reply to tarekahf

    Hi Tarek,

     

    Once we saw that a PDF worked perfectly, it seemed to us like the XDP wrapper was causing our issue.

    We decided to try a server function since we have LiveCycle Reader Extension Server… we weren’t sure what functionality we would get since we only purchased LRES but it was worth a try! After looking over the Quick Starts from Adobe, we found one that suited our needs and were able to call the importData function of Form Data Integration Service. This function takes in two byte arrays: the template PDF and the XDP data and returns a new PDF with the data embedded in it. The functionality of the Signatures (Topaz) and the Reader Extenstions remain intact.

     

    In case anyone else wants to explore, here is the link to “Programming with LiveCycle ES2”

    http://help.adobe.com/en_US/livecycle/9.0/programLC/help/index.htm

    Under “API Quick Starts (Code Examples)”

                “Form Data Integration Service API Quick Starts”

                            “Invoking LiveCycle ES2 using MTOM” – explains how to add a Service Reference to your ASP.Net project: http://help.adobe.com/en_US/livecycle/9.0/programLC/help/index.htm?con tent=000532.html#1857175

                            “Quick Start (MTOM): Importing form data using the web service API” - explains how to call importData: http://help.adobe.com/en_US/livecycle/9.0/programLC/help/index.htm?con tent=000204.html#1560289

     

    Two basic steps:

    Add a Service Reference to you ASP.NET project (must be Microsoft Visual Studio 2008)

    1. In the Project menu, select Add Service Reference.
    2. In the Address dialog box, specify the WSDL to the LiveCycle ES2 service:

    http://YOURSERVERNAME:8080/soap/services/FormDataIntegration?WSDL&lc_v ersion=9.0.1

    1. Click Go
    2. Name your service, we used FormDataIntegrationService
    3. Click OK.

    This step adds a section to your web.config: <system.serviceModel>

     

    Add code to the page that is loaded in the IFRAME:

    'fill ds with data to push into template PDF

    Dim ds As New DataSet

    ' wrap in XML

    Dim xml As New StringBuilder

    With xml

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

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

           .Append("<xfa:data>")

           .Append(ds.GetXml)

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

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

    End With

    ' read XML into byte array

    Dim bXML As Byte() = System.Text.Encoding.ASCII.GetBytes(xml.ToString)

    ' read template PDF into byte array

    Dim bPDF() As Byte = File.ReadAllBytes("STRING CONTAINING VALID PATH & FILE NAME")

    ' Create Client

    Dim dataClient As New FormDataIntegrationService.FormDataIntegrationClient

    ' Important: the endpoint address must have ?blob=mtom to be able to access the MTOM objects

    ‘ we plan on using the web.config entry for address & concat ?blob=mtom so we can change servers in the future.

    dataClient.Endpoint.Address = New System.ServiceModel.EndpointAddress( _       "http://YOURSERVERNAME:8080/soap/services/FormDataIntegration?blob=mtom")

    ' Enable BASIC HTTP authentication

    Dim b As ServiceModel.BasicHttpBinding = CType(dataClient.Endpoint.Binding, ServiceModel.BasicHttpBinding)

    b.MessageEncoding = ServiceModel.WSMessageEncoding.Mtom

    dataClient.ClientCredentials.UserName.UserName = "YOURUSERNAME"

    dataClient.ClientCredentials.UserName.Password = "YOURPASSWORD"

    b.Security.Transport.ClientCredentialType = ServiceModel.HttpClientCredentialType.Basic

    b.Security.Mode = ServiceModel.BasicHttpSecurityMode.TransportCredentialOnly

    b.MaxReceivedMessageSize = 2000000

    b.MaxBufferSize = 2000000

    b.ReaderQuotas.MaxArrayLength = 2000000

    ' read template PDF byte array into BLOB

    Dim inPDF As New FormDataIntegrationService.BLOB

    inPDF.MTOM = bPDF

    ' read data byte array into BLOB

    Dim inData As New FormDataIntegrationService.BLOB

    inData.MTOM = bXML

    ' call importData and get back BLOB

    Dim outPDF As New FormDataIntegrationService.BLOB

    outPDF = dataClient.importData(inPDF, inData)

    ' set up response type

    Response.ContentType = "application/pdf"

    ' get byte array from MTOM

    Response.BinaryWrite(outPDF.MTOM)

    ' end reponse

    Response.End()

     

    Thank you so much for your time.

     
    |
    Mark as:
  • Currently Being Moderated
    Sep 3, 2010 4:23 PM   in reply to (Ulf_I_Andersson)

    Would anyone happen to know why some data may not be available in the meta data of the pdf file?  I am unable to find the images I have created in LS Designer.  I am also unable to find some upsidedown text fields.

     

    Any help is much appreciated.

     
    |
    Mark as:
  • Currently Being Moderated
    Sep 21, 2010 11:05 PM   in reply to tarekahf

    Hi Guys,

     

       

    I really need your help. I'm a newbie in Adobe LiveCycle I’m running out of time to finish my project. By the way I’m using asp.net with vb language in my web application (.Net Framework 2.0).

     

    The following at the things that I want to achieve:

    1.       Populate the pdf file (the pdf file is already existing) with the data from database and invoke the pdf reader to open the populated pdf file.

    2.       What are the libraries or software that I need to install to achieve the item no. 1 and where I can download it?

     

    Hope you can help me because my job is at stake here if can't finish this project.

     

    Any help is much appreciated.

     

     

     
    |
    Mark as:
  • Currently Being Moderated
    Sep 22, 2010 12:05 AM   in reply to tarekahf

    Hi tarek,

     

         Thank you so much for the reply.

        

         I tried all the source code that you provided but none of them is working on my side.

        

         The pdf file is already created and I want to modify the value of a certain field. From my web application I will open that pdf file there is no other thing that the user can do. the user can only view it. Please provide me some code on how to do this, I know it is too much and I apologize for it. I really dont have a knowledge on this. If you want you can drop me an email at sterling_sting_0069@yahoo.com so that I can send you the pdf file. I think that pdf file is somewhat complicated.

     

    I really need your help.

     
    |
    Mark as:
  • Currently Being Moderated
    Sep 22, 2010 2:08 AM   in reply to tarekahf

    HI tarek,

     

         What I'm what to do is to populate the data that I retrieve from the database and populate it in the pdf file and open it using adobe reader so that the user can see the result. The pdf file is provided to us by other groups.

     

    This are the tools that I'm using right now;

         Visual Studio 2005

         Adobe Reader 9 (Installed in my laptop)

         Adobe LiveCycle Designer ES2

     

     

    I open the pdf file in Adobe LiveCycle Designer  and copy the the xml source and save it as text file(IPC-1752-2_v1.1.txt).

     

    I tried to upload the pdf file but even google cannot convert it to there own format.

    If it is okay for you to provide me your email address so that I can send to you the pdf file ans the same time the text file that I use.

     

    Thank you so much.

     

    Code:

    Dim objStreamReader As New StreamReader(Server.MapPath("formats\IPC-1752-2_v1.1.txt"))

     

    Dim strLine As String

     

     

    Dim strXML As String = ""

     

     

    Try

    Response.ContentType =

     

    "application/vnd.adobe.xdp+xml"

     

     

    'Read the first line of text.

    strLine = objStreamReader.ReadLine

     

     

    'Continue to read until you reach the end of the file.

     

     

    Do While Not strLine Is Nothing

    strXML += strLine

     

     

    'Read the next line.

    strLine = objStreamReader.ReadLine

     

     

    Loop

     

     

    ' Close the XPD File

    Response.Write(strXML)

    Response.Flush()

    Response.End()

     

     

    Catch ex As Exception

     

    Finally

     

     

    'Close the file.

    objStreamReader.Close()

     

     

    End Try

     
    |
    Mark as:
  • Currently Being Moderated
    Sep 22, 2010 4:46 AM   in reply to tarekahf

     

    Hi tarek,

     

         How can I create an empty LiveCycle PDF Form? You mean I can't use the pdf file that I'm using right now?

     

    I tried the code below and it open the pdf file in adobe reader but the field is not populated.

     

    Thank you so much for your continuing support.

     

    Code:

     

    Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load

     

    Dim CompName As String = "Sample Company Name"

     

     

    Dim strXML As String

     

     

    'Set Content Type for using XDP

    Response.ContentType =

     

    "application/vnd.adobe.xdp+xml"

     

     

    'Constant XDP Header

    strXML =

     

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

    strXML +=

     

    "<?xfa generator='AdobeLiveCycleDesignerES_V9.0.0.0.20091029.1.612548' APIVersion='3.1.9277.0'?>"

    strXML = strXML &

     

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

    strXML = strXML &

     

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

    strXML = strXML &

     

    "<xfa:data>"

    strXML = strXML &

     

    "<MCD>"

    strXML = strXML &

     

    "<RoHSpage1>"

    strXML = strXML &

     

    "<RequestInformation>"

    strXML = strXML &

     

    "<RequestCompanyName>"

    strXML = strXML &

     

    "<value>"

    strXML = strXML &

     

    "<text>" & CompName & "</text>"

    strXML = strXML &

     

    "</value>"

    strXML = strXML &

     

    "</RequestCompanyName>"

    strXML = strXML &

     

    "</RequestInformation>"

    strXML = strXML &

     

    "</RoHSpage1>"

    strXML = strXML &

     

    "</MCD>"

    strXML = strXML &

     

    "</xfa:data>"

    strXML = strXML &

     

    "</xfa:datasets>"

     

     

    ' Point the XPD to the PDF Form created under Adobe LiveCycle Desinger

    strXML = strXML &

     

    "<pdf href='" & Server.MapPath("formats/IPC-1752-2_v1.1.pdf") & "' xmlns='http://ns.adobe.com/xdp/pdf/' />"

     

     

    ' Close the XPD File

    strXML = strXML &

    "</xdp:xdp>"

     

    Response.Write(strXML)

    Response.Flush()

    Response.End()

     

    End Sub

     
    |
    Mark as:
  • Currently Being Moderated
    Sep 22, 2010 7:06 PM   in reply to tarekahf

    FDFToolkit.net for ASP.net can parse, populate, merge PDF data formats such as, FDF, XDP, XFDF, and XML. Adobe Acrobat Standard or Pro is not required! With just Adobe Reader, your users can submit, download filled PDFs, or e-mail recipients without using Client Email software such as Outlook.

     

    FDFToolkit.net works with Adobe LiveCycle and Adobe Acrobat Forms in pretty much the same way as FDFToolkit by Adobe, plus, it can merge and combine Adobe Acrobat & LiveCycle PDFs. FDFToolkit.net is a 100% Microsoft .net library, not a com object, so there is no server-side setup required, and it can work on just about any remote and local web servers, as well as standalone applications.

     

    FDFToolkit.net programming can parse incoming FDF,XFDF,XDP, and XML files directly from a Adobe LiveCycle or Acrobat PDF form submission using ASP.net. Importing ADO.net datarow and datasets is easy with FDFToolkit.net. Import PDF data formats from a byte array, stream, string, or file.

     

    FDFToolkit.net can also write FDF, XFDF, XDP, and XML based formats. Exporting data to ADO.net datasets and datarows is easy with FDFToolkit.net. Just name the PDF form field names the same as the ADO.net datacolumns, and populating the datarow is done with one function.  Export PDF data formats to a byte array, stream, string, or file.

     

    FDFToolkit.net has many features not listed on this page.

     

    For more information, please visit:

    http://www.fdftoolkit.net/

     

    For online tutorials and code examples, please visit:

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

     

     

    Thank you for your time and I hope this information can help.

     

    Also, be sure to check out:

    http://www.pdfemail.net/

     

     

     

    Kind Regards,

     

     

    Nick K.

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

     
    |
    Mark as:
  • Currently Being Moderated
    Sep 23, 2010 10:47 PM   in reply to tarekahf

    Hi tarek,

     

         Thank you so much for your help, I'm able to populate now the pdf file.

     

         One more thing, I want to automatically save the populated pdf file to my local machine without any user intervention.

    How can I achieved this thing?

     

    Regards,

     

    rp_0069

     
    |
    Mark as:
  • Currently Being Moderated
    Sep 24, 2010 9:47 PM   in reply to rp_0069

    FDFToolkit.net can also "Force a Download" of the merged PDF form.

     

    Take Care,

     

     

    Nick K.

    www.nk-inc.com

     
    |
    Mark as:
  • Currently Being Moderated
    Sep 26, 2010 6:57 PM   in reply to NKOWA

    Hi NKOWA,

     

         Does the FDFtoolkit.net has a trial version? Where I can download it?

     

    Thanks and Regards

     
    |
    Mark as:
  • Currently Being Moderated
    Sep 26, 2010 8:57 PM   in reply to rp_0069

    Please contact me at:

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

     

    I do not want to post the registration and download urls online.

     

     

    Regards,

     

    Nick K.

    www.nk-inc.com

     
    |
    Mark as:
  • Currently Being Moderated
    Oct 4, 2010 11:22 PM   in reply to tarekahf

    Hi tarek,

     

         Thank you so much for your help, I'm able now to populate the pdf file.

     

         I need you help again, is it possible to sign the pdf file using the xml or xfa or using the source code that you have posted?

     

         I review the sourcode that you posted but there is no example that sign the pdf file.

     

         Hope you can help me again.

     

    Regards,

    rp_0069

     
    |
    Mark as:
  • Currently Being Moderated
    Oct 4, 2010 11:29 PM   in reply to rp_0069

    I am glad I was able to help.

     

    You you mean you want to sing the PDF using code (programatically) ? Write javascript codes to sign the document in the background ?

     

    If Yes, you have to tell me at what time the code should triggered ?

     

    As a mater of fact, I have not done that before. I will have to spend some time to research this matter.

     

    In the mean time, please confirm my questions above.

     

    Tarek.

     
    |
    Mark as:
Actions

More Like This

  • Retrieving data ...

Bookmarked By (0)