Hi gurlnpink ,
Appreciate your update. I might use iTextSharp in my next project.
As per my research about 2 years ago, I figured out that iTextSharp was desinged to handle Acrobat PDF not XFA Forms. I thought at that time that it will not be easy for example to populate a XFA form with repeating subform in a Dynamic PDF. I am not 100% sure though.
I appreciate it if you let me know if you can use iTextSharp to populate and read from a repeating Subform in a Dynamic XFA PDF.
Tarek.
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 ![]()
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
fredssmith,
What you are asking for can be done, but is a client side type of solution.
I mean, each user who wants to use your form, must do some configuration work to so that he can use the form functions.
So, if the number of the users is small, that is fine. Otherwise, it will be hell of a job. Not to mention the maintenance overhead.
Why not implement a server-side solution ? It will take a bit more time to get started, but this is the right direction.
Could you please specify your requirements, I need more details to be able to help you. Do not mention how to impelement the solution, just talk about your requirements.
Tarek.
AjoJoseph wrote:
Hi Tarek
Firstly let me say thank you for the great help you are doing through the forum.
With Google, I did a very long search to find out how to fill a PDF form from a database. I achieved this using the iTextSharp dll. But this dll not supporting adobe extended features. thatsy once i filled forms using this class, result form will be flat form and we cant fill it manually again. even this will disable adobe extended features when i open it in adobe reader.
I am working with a project to simplify immigration process (CANADA). I already have all immigration forms created using LiveCycle. That means when i open these form in free Adobe Reader I can fill the form manually and can save locally (offline).
My Workflow as follows
1. I am working with .Net Frame Work 2, Visual Studio 2005, Windows Applications (not Web/ASP)
2. I have fillable forms designed using Adobe LiveCycle (I can fill the form manually and can save locally (offline) using Adobe Reader).
3. I have to dynamically fill these forms with data from a database (data is already available and its almost achieved using iTextSharp Dll)
4. Once its dynamically filled, I will send these forms to client through email, because some of the data should be filled by client.
5. client can open these forms in free Adobe Reader and they can fill and save these forms(because Adobe extended feature enabled in this form, so they can fill and save in Adobe Reader)
6. Once they fill and save the form, they will send back final form to us through emal (no Online Submit required).
7. We will check it and finalize, take printout and attach to our document management system.
8. I can't use any great technologies bcz I dont need any online Submision/Rejection thing and our budjet is low.
9. I am looking some technologies same as itextShar, simply fill data to form and save it as a new PDF, but it should support Adobe Extended Featers( what is currently not available in iTextSharp), so that customer can fill and save it again using simple and free ADOBE READER.
That's it !!
could u please verify my workflow is correct or not, bcz am new to PDF things and can u please suggest me solution to achieve this.
Thanks in advance
Ajo Joseph
This is a reply to the original thread posted here:
http://forums.adobe.com/thread/564995?tstart=0
I will come back with an answer soon.
Tarek.
Hi AjoJoseph,
Looks like your application does not need to be web-enabled, right ?
In that case, you will have to develop some kind of client-side application using VB.NET. There is no need to develop web-application using ASP.NET since this will add some confusion to the user, but in my opinion, it will be easier to develop web application than a client-side application. Keep in mind that you need at least one license from Adobe Acrobat if you go for client-side application.
However, if you decide to make it client-side, then check this thread:
http://www.acrobatusers.com/forums/aucbb/viewtopic.php?id=15695
I never used iTextSharp. I used Acrobat SDK, XDP (xfa) and XML to handle data communication from/to the Database and the PDF Form.
I tried to work with iTextSharp about 2 years ago, and I got lost, so I decided to use the available tools from Adobe and .NET to achieve my requirements.
The workflow you suggested is correct. If you do not want to do fancy job (on-line submission), then this is the way to go. We implemented similar workflow process last year to deal with about 200 PDF Forms, and it worked 100% correct.
I will add the following to make it work properly from the technical side:
1. Write a .NET Program using Acrobat IAC (OLE) to generate and populate the PDF. First, Generate the XML Data, use Empty PDF as a template, then attach the XML Data to the PDF, then save the PDF using a Key Value as the File Name. You can use .NET XML Object to generate the XML String. Make sure to assign the Key Value to a field inside the PDF as Read-Only. Also, put some control fields inside the PDF like: Status, DateTime Stamp, PDf Version ...etc to help you make correct decisions while processing the PDF.
2. Decide if you want to send the generated PDF also from a .NET Program. It can be done.
3. Once you receive the PDF as a reply by email, save them all to a folder in the local drive (we have done this manually).
4. Write a .NET Program to iterate over the saved PDF Files, extract the XML Data, and write the result back to a Database, if needed. You can then here send confirmation by email to the applicant.
I hope this will be of help to you.
Tarek.
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
Hi Ajo Joseph,
You only need Acrobat Pro License on the PC where you will run the program that uses Acrobat SDK/IAC/OLE. If you enable Reader Rights, to the best of my knowldge, it will be maintained and the end-user do not neet to have Acrobat License. You need Acrobat in any case to Enable Reader Rights from the source.
Tarek.
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
Just go through the sample code you I gave you. What you are asking for is just the reverse operation. As a matter of fact, the sample code I provided is generating a Unique Serial Number and saving the result in "Form_Id" field, then it will save the form back. It has everything you need to get started.
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.");
}
}
}
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.
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.
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.
>
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.
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
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"});
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
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…
Hi JimboWx,
Actually, it is not easy to predict the cause of the prolem you are
facing, but I will try to help. 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. I used IFRAME, OBJECT or EMBED tags (if
I remember correctly) to render a PDF using a direct link to the PDF,
and they all worked successfully.
Try any combination of the following:
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-behined. Make sure
nothing is rendered before the command "response.ContentType=...",
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()".
3. Check the complete documentation of IFRAME and try to find a way to
tweak its behaviour.
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.
5. Try with FireFox and IE8. This could be a nasty IE7 bug.
I hope my suggestions will be of help to you.
Tarek.
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.
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.
Hi JimboWx,
You must have spent a lot of effort on this. I can only imagine
different way trying to help.
Try the following:
1. Use IFRAME Nested Inside IFRAME, ie, IFRAM1 points to IFRAME2 which
points to the ASPX Page rendering the PDF,
2. Use IFRAME pointing to HTML/ASPX Page which is EMBEDing or using
OBJECT Tag to ASPX page rendering the PDF.
3. Using IFRAME according to its documented functions, should not cause
the problem you are reporting. So, try in FireFox or IE8 just to see if
the behaviour is the same or not.
Tarek.
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)
http://YOURSERVERNAME:8080/soap/services/FormDataIntegration?WSDL&lc_v ersion=9.0.1
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.
Hi JimboWx,
I am really happy you found the solution to the problem. I hope my input was helpful.
It never occurred to my mind that if you have Adobe LiveCycle Reader Extensions Server then you can generate PDF by merging Template with XDP Data. I though that LRES is only to reader enable PDFs, but you can Generate PDFs ? No licensing issues here ?
The result of your work is so valuable to me.
Thank you so much for your feedback.
Tarek.
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.
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.
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.
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.
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
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.
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
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.
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:
For online tutorials and code examples, please visit:
Thank you for your time and I hope this information can help.
Also, be sure to check out:
Kind Regards,
Nick K.
function(){return A.apply(null,[this].concat($A(arguments)))}rp_0069 wrote:
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
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.
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.
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
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.
North America
Europe, Middle East and Africa
Asia Pacific