Fill form fields in a PDF

G

Guest

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.
 
N

Nick Malik [Microsoft]

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.
 
J

Jack Addington

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 said:
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.
--
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top