473,230 Members | 1,432 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,230 software developers and data experts.

Fill form fields in a PDF

Hi there,
I have a PDF that has editable form fileds. I want to be able dynamically
fill in those form fields based on values I provide to the PDF. Right now, I
can create an instance of the object, open the PDF document, but can't get a
handle on the JavaScript portion of the document in order to change any of
the form field values.

Here is a snippet of my code so far:
Type AcroApp = Type.GetTypeFromCLSID(new
System.Guid("{85DE1C45-2C66-101B-B02E-04021C009402}"));

Type AcrobatType = Type.GetTypeFromCLSID(new
System.Guid("{72498821-3203-101B-B02E-04021C009402}"));

Type AcroPD = Type.GetTypeFromCLSID(new
System.Guid("{FF76CB60-2EC8-101B-B02E-04021C009402}"));

//create instances of the Acrobat objects needed
Acrobat.CAcroApp oApp = (Acrobat.CAcroApp) Activator.CreateInstance(AcroApp);
Acrobat.CAcroAVDoc avdoc= (Acrobat.CAcroAVDoc)
Activator.CreateInstance(AcrobatType);
Acrobat.CAcroPDDoc adoc = (Acrobat.CAcroPDDoc)
Activator.CreateInstance(AcroPD);

avdoc.Open(Server.MapPath("pdfs/test.pdf"),"test PDF");
adoc = (Acrobat.CAcroPDDoc)avdoc.GetPDDoc();

/* I need to get a hold of the form fields here and fill in their values */

oApp.Show(); //displays the proper PDF
adoc.Close();

Any help would be greately appreciated.

--
Thanks,

John Scott.
Jul 21 '05 #1
2 6569
To be honest, I don't know how to drive PDF.

However, I have a suggestion. When you fill a PDF form and submit it, an
XML stream is sent to the destination of the form. This is how PDF Forms
work (it's very similar to Microsoft Office Infopath, BTW).

So my suggestion is this: if you don't need the customer to see the data in
the form (e.g. you've collected in another way), it may be possible just to
compose the XML stream and submit it to the web server, as though your
program were the acrobat viewer, without ever loading up acrobat.

I hope this helps,

--
--- Nick Malik [Microsoft]
MCSD, CFPS, Certified Scrummaster
http://blogs.msdn.com/nickmalik

Disclaimer: Opinions expressed in this forum are my own, and not
representative of my employer.
I do not answer questions on behalf of my employer. I'm just a
programmer helping programmers.
--
"John Scott" <jo*******@despammed.com> wrote in message
news:2A**********************************@microsof t.com...
Hi there,
I have a PDF that has editable form fileds. I want to be able dynamically
fill in those form fields based on values I provide to the PDF. Right
now, I
can create an instance of the object, open the PDF document, but can't get
a
handle on the JavaScript portion of the document in order to change any of
the form field values.

Here is a snippet of my code so far:
Type AcroApp = Type.GetTypeFromCLSID(new
System.Guid("{85DE1C45-2C66-101B-B02E-04021C009402}"));

Type AcrobatType = Type.GetTypeFromCLSID(new
System.Guid("{72498821-3203-101B-B02E-04021C009402}"));

Type AcroPD = Type.GetTypeFromCLSID(new
System.Guid("{FF76CB60-2EC8-101B-B02E-04021C009402}"));

//create instances of the Acrobat objects needed
Acrobat.CAcroApp oApp = (Acrobat.CAcroApp)
Activator.CreateInstance(AcroApp);
Acrobat.CAcroAVDoc avdoc= (Acrobat.CAcroAVDoc)
Activator.CreateInstance(AcrobatType);
Acrobat.CAcroPDDoc adoc = (Acrobat.CAcroPDDoc)
Activator.CreateInstance(AcroPD);

avdoc.Open(Server.MapPath("pdfs/test.pdf"),"test PDF");
adoc = (Acrobat.CAcroPDDoc)avdoc.GetPDDoc();

/* I need to get a hold of the form fields here and fill in their values
*/

oApp.Show(); //displays the proper PDF
adoc.Close();

Any help would be greately appreciated.

--
Thanks,

John Scott.

Jul 21 '05 #2
There is a product called ActivePDF that I have used that does this. There
is a toolkit among other things that is relatively cheap. It has a whole
interface to quickly parse PDF template data.

"Nick Malik [Microsoft]" <ni*******@hotmail.nospam.com> wrote in message
news:2u********************@comcast.com...
To be honest, I don't know how to drive PDF.

However, I have a suggestion. When you fill a PDF form and submit it, an
XML stream is sent to the destination of the form. This is how PDF Forms
work (it's very similar to Microsoft Office Infopath, BTW).

So my suggestion is this: if you don't need the customer to see the data
in the form (e.g. you've collected in another way), it may be possible
just to compose the XML stream and submit it to the web server, as though
your program were the acrobat viewer, without ever loading up acrobat.

I hope this helps,

--
--- Nick Malik [Microsoft]
MCSD, CFPS, Certified Scrummaster
http://blogs.msdn.com/nickmalik

Disclaimer: Opinions expressed in this forum are my own, and not
representative of my employer.
I do not answer questions on behalf of my employer. I'm just a
programmer helping programmers.
--
"John Scott" <jo*******@despammed.com> wrote in message
news:2A**********************************@microsof t.com...
Hi there,
I have a PDF that has editable form fileds. I want to be able
dynamically
fill in those form fields based on values I provide to the PDF. Right
now, I
can create an instance of the object, open the PDF document, but can't
get a
handle on the JavaScript portion of the document in order to change any
of
the form field values.

Here is a snippet of my code so far:
Type AcroApp = Type.GetTypeFromCLSID(new
System.Guid("{85DE1C45-2C66-101B-B02E-04021C009402}"));

Type AcrobatType = Type.GetTypeFromCLSID(new
System.Guid("{72498821-3203-101B-B02E-04021C009402}"));

Type AcroPD = Type.GetTypeFromCLSID(new
System.Guid("{FF76CB60-2EC8-101B-B02E-04021C009402}"));

//create instances of the Acrobat objects needed
Acrobat.CAcroApp oApp = (Acrobat.CAcroApp)
Activator.CreateInstance(AcroApp);
Acrobat.CAcroAVDoc avdoc= (Acrobat.CAcroAVDoc)
Activator.CreateInstance(AcrobatType);
Acrobat.CAcroPDDoc adoc = (Acrobat.CAcroPDDoc)
Activator.CreateInstance(AcroPD);

avdoc.Open(Server.MapPath("pdfs/test.pdf"),"test PDF");
adoc = (Acrobat.CAcroPDDoc)avdoc.GetPDDoc();

/* I need to get a hold of the form fields here and fill in their values
*/

oApp.Show(); //displays the proper PDF
adoc.Close();

Any help would be greately appreciated.

--
Thanks,

John Scott.


Jul 21 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
by: Barry Margolin | last post by:
Can I do the following with Javascript? My state has a web site that can be used for online filing for unemployment benefits. Every week I have to go to the site and fill in a form, checking...
1
by: Tom G | last post by:
Hello, I need some advice on which way to resolve the following. On a form, the user will make a selection from a combo box, after the selection several different fields need to be updated on...
0
by: tshad | last post by:
MSN has a toolbar that has a Form Fill function that will try to fill form fields on forms when they come up. The problem is that it causes problems with some forms and functions. I found this...
5
by: cgian31 | last post by:
I need to access an info page in an external website, normally accessible after filling username and password in a form. I would like to hide this complexity (!) from the user, allowing them to...
2
by: Woody Splawn | last post by:
I have a question about technique with regard to filling drop downs. I have a Winform that has several different tabs and tables associated with it. In an effort to keep the load time small I...
2
by: John Scott | last post by:
Hi there, I have a PDF that has editable form fileds. I want to be able dynamically fill in those form fields based on values I provide to the PDF. Right now, I can create an instance of the...
19
by: Alex | last post by:
Hello list This question has probably already been asked, but let me ask again I have a mysql database to which I connect with my php scripts. The database contains articles. Name, Unit_Price...
1
by: Kev | last post by:
Hello I have a form (RosterForm) based on a table - RosterRange RosterRange has 4 fields: RosterRangeID Autonumber RosterStartDate Date RosterEndDate Date (probably...
4
by: MichaelK | last post by:
Hello. I have all data already collected on the current page? I want to open another window with the form, fill the fields and submit that form. So basically the question is how can I fill all...
0
by: VivesProcSPL | last post by:
Obviously, one of the original purposes of SQL is to make data query processing easy. The language uses many English-like terms and syntax in an effort to make it easy to learn, particularly for...
0
by: jianzs | last post by:
Introduction Cloud-native applications are conventionally identified as those designed and nurtured on cloud infrastructure. Such applications, rooted in cloud technologies, skillfully benefit from...
0
by: abbasky | last post by:
### Vandf component communication method one: data sharing ​ Vandf components can achieve data exchange through data sharing, state sharing, events, and other methods. Vandf's data exchange method...
2
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 7 Feb 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:30 (7.30PM). In this month's session, the creator of the excellent VBE...
0
Git
by: egorbl4 | last post by:
Скачал я git, хотел начать настройку, а там вылезло вот это Что это? Что мне с этим делать? ...
1
by: davi5007 | last post by:
Hi, Basically, I am trying to automate a field named TraceabilityNo into a web page from an access form. I've got the serial held in the variable strSearchString. How can I get this into the...
0
by: MeoLessi9 | last post by:
I have VirtualBox installed on Windows 11 and now I would like to install Kali on a virtual machine. However, on the official website, I see two options: "Installer images" and "Virtual machines"....
0
by: DolphinDB | last post by:
The formulas of 101 quantitative trading alphas used by WorldQuant were presented in the paper 101 Formulaic Alphas. However, some formulas are complex, leading to challenges in calculation. Take...
0
by: Aftab Ahmad | last post by:
So, I have written a code for a cmd called "Send WhatsApp Message" to open and send WhatsApp messaage. The code is given below. Dim IE As Object Set IE =...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.