[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.
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.");
}
}
}
Views
Replies
Total Likes
If you are running the FillFormCS sample code without any changes to the logic, then make sure of the following:
1. The path to the file is correct with proper escaping, like this "c:\\folder\\filename.pdf"
2. The file exists,
3. Ensure the file is opened and give it enough time to load completely,
4. Debug step by step, and wait for a few sconds before executing the line where it fails,
5. Before you starting the application using "F5", kill all the tasks named "Acrobat.exe" from Windows task manager.
6. Call Show() after the Open(), not before.
If you have done all the steps above and still there is error, then there is a problem with Acorbat 9 Prof. Try Acrobat Prof 7.0.5.
Also, try following the sample I provided you. I used Acorbat Prof. 7.0.5 SDK to get this code and tested successfully under Adobe Acorbat 7.0.5. If it does not work with you, then this is an issue in Acrobat 9.
Also, you can get Acrobat SDK Paid Support by contacting europartners@adobe.com
Good luck.
Tarek.
Views
Replies
Total Likes
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("LabReport01URLRoot").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
Finally, to generate the LabReport, the following code is used :
Protected Sub btnTestLabReport_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnTestLabReport.Click
Dim theLabRequest As LabRequest
Dim theLabReport As LabReport01PDF
theLabRequest = GetLabRequest()
theLabReport = New LabReport01PDF(theLabRequest.LabRequestID)
Response.Clear()
theLabReport.Render(Response)
Response.End()
End Sub
I hope this will be of help to all of you.
Tarek.
Views
Replies
Total Likes
thanks this is really good...
Date: Tue, 27 Apr 2010 08:46:12 -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.
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("LabReport01URLRoot").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.
>
Views
Replies
Total Likes
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.
Views
Replies
Total Likes
Anup,
I am glad you found it useful.
There is error in the URL, just in case, it must read as follows:
event.target.submitForm( );
Also, if you are submitting to a local website running under Visual
Studio webserver (F5), then this is not a good idea.
Deploy the website to a local virtual directory under IIS (it works on
XP) and try again.
Also, try this, it may work:
event.target.submitForm( );
I mean use relative path which is relative to the current page.
Finally, I think you should use a reader-enabled PDF to allow submit a
PDF under Adobe Reader. You must have Acrobat Prof. Client or LiveCycle
Reader Extension Server (LRES) to reader enable the PDF form. The LCRES
will give you more options for "Reader Enable" a PDF, when compared with
Acrobat.
I hope this helps.
Tarek.
On Thu, 22 Jul 2010 10:12 -0600, "mclarenriderA" <forums@adobe.com
Views
Replies
Total Likes
Sorry Anup, I just found out that there were errors in my last postings probably becuase I replied from my email directly. It should read as follows:
I am glad you found it useful.
There is error in the URL, just in case, it must read as follows:
event.target.submitForm( {cURL: "http:/localhost:4147/website3/default.aspx", aPackets:
Also, if you are submitting to a local website running under Visual Studio webserver (F5), then this is not a good idea.
It will be better Deploy the website to a local virtual directory under IIS (it works on XP) and try again.
Also, try this, it may work:
event.target.submitForm({cURL: "website3/default.aspx", aPackets: ["datasets","pdf"], cSubmitAs: "XDP"}); );
I mean use relative path which is relative to the current page.
Finally, I think you should use a reader-enabled PDF to allow submit a
PDF under Adobe Reader. You must have Acrobat Prof. Client or LiveCycle
Reader Extension Server (LRES) to reader enable the PDF form. The LCRES
will give you more options for "Reader Enable" a PDF, when compared with
Acrobat.
I hope this helps.
Tarek.
["datasets","pdf"], cSubmitAs: "XDP"});
Views
Replies
Total Likes
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.
Views
Replies
Total Likes
If you go through this thread from the beginning, you will get the complete answer.
In short, you need:
1. Adobe LiveCycle Desinger, to desing the forms.
2. Adobe Reader, this will give you minimum features,
3. Adobe Acrobat, if you want more features at the end-user side,
4. Adobe LiveCycle Reader Extensions Server, if you need more feature for users with Adobe Reader Only.
5. Write the program to generate the XDP String on the server using ASP.NET and use response.write to send the string to the client (IE or Firefox).
I hope this helps.
Tarek.
Views
Replies
Total Likes
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.
Views
Replies
Total Likes
Please upload the PDF to a shared space like Google Docs, and post the link back.
Also, based on my last post, please provide complete details, as much as you can, about what you have done, and how. What tools and software you are using. Also, post the code you have tried and did not work, and how your code was deployed.
Tarek.
Views
Replies
Total Likes
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
Views
Replies
Total Likes
Hi rp_0069,
No, this is not the way.
You need to spend some effort, and review this thread more carefully.
You must build the XML String from scratch, manually. The string has 3 parts:
1. Header (fixed),
2. Data (XML representing the data fields on the form and the values). So if the form has Text Field named "CustomerName" in the binding tab, then the XML Data Part can be somthing like this:
<root>
<CustomerName>Some Name Here</CustomerName>
</root>
Also, you can rename the root node of the Form in the hierarchy view from "form1" to "root" to make it more meaningful.
3. Footer: which has the URL pointer to the empty LiveCycle PDF Form.
Also, make sure you are working with a web site or web project, and put the code inside the Page Load Event.
I have developed a class wrapper which will make your job easier. See the thread again.
Do a simple test on a simple form with one text field, and try again.
Tarek.
Views
Replies
Total Likes
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
Views
Replies
Total Likes
Ok, now you are making some progress.
Check the following:
1. The mepty PDF is the same PDF but without data in it, or with minimum data as per your need.
2. Make a simple form with one text field "CompanyName". Open the PDF in Acrobat/Reader, and fill some data.
3. Used the menu option Forms/Export Data to XML File. I am not sure if you are allowed to export the Data from Reader.
4. Open the File in the browser or Notepad (you can use nice free tool from Microsoft Download called XML Notepad).
5. Examine the file and how it looks in XML. See how root Form and the nested Nodes inside are strucutred. Change the Field Value inside the XML Text File, save it, and import it back to the PDF. You should notice the field value is changed.
6. The Data Part of the XDP String must be exactly what you see in the exported XML File from Adobe Acrobat/Reader. You only need to strip out the first line which is the XML Declaration or something like that. You must start with the root node, which is the name of the root XFA inside your PDF. By default it is "form1".
7. The pointer to the empty PDF is the URL which must look like this http://blabla/MyTemplate.PDF . So you must put your PDF inside the WWW Virtual Folder of your website. Then, try to browse to this file from IE. After you get the URL, just copy/past in your XML String in ASP.NET.
Tarek.
Views
Replies
Total Likes
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
Views
Replies
Total Likes
Glad I was able to help.
What you are asking for can be done, but there is no direct easy way. The best option is to add a Submit button on the form, submit the form using Javascrip inside the PDF, and inside ASP.NET, you receive the Request content, process it, and save the PDF on any Folder which can be accessed from the Server Machine. This folder can be any folder even shared network folder. After that, you can provide a link to the user to open the saved PDF and then he can decide to save it to any place. This way, you can keep a record and track the User Operation "Save the PDF", also, you have a copy of the PDF on the Server, and finally, the user can also get this copy.
Remember that you are working with Web Applications, and the program under Web are not allowed to save on the client machine without a prompt ! This is for security reasons.
Maybe you want to try using fdftoolkit.net.
Tarek.
Views
Replies
Total Likes
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
Views
Replies
Total Likes
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.
Views
Replies
Total Likes
Hi tarek,
You are correct.
What I want to achieve is that, to sign the pdf programatically from my code behind. I'm using asp.net vb language.
I have a button in my aspx page. When I click that button I want to populate the pdfl file at the same time sign the pdf file using a signature file.
I'm able now to populate the pdf file but the problem is that I don't how to sign in programatically.
Thank so much for your response.
Regards,
rp_0069
Views
Replies
Total Likes
I have never done that before.
I think you need to use a tool like fdftoolkit.net, or use some Server Product from Adobe which is called maybe LiveCycle Digital Signatures or something like that.
Also, you can use Acrobat .NET DLL and sign the form from .NET Windows Application. You have to use IAC/OLE Acrobat Technology for that. But, you cannot use it from a web application due to licensing restrictions.
If anyone else has any other idea, please let is know.
Tarek.
Views
Replies
Total Likes
Views
Likes
Replies
Views
Likes
Replies