473,387 Members | 1,534 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,387 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 6589
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: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...

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.