Hello there
I need to develop a Windows application that will allow users to open dynamic PDF forms, view them on-screen and fill the forms with data. The data may be typed in on the form or chosen from a picklist.
The requirement is for a Windows Forms based solution developed in VB.Net, so ideally I would be looking for a control that I can drop on to a Windows form in Visual Studio.
Given the project requirements, it is vital that the control is capable of all of the following:
- Open PDF forms in a windows application
- Respond to click events in the individual editable form fields
- Allow both user-based and code-based update of form fields
- Allow saving of partially completed PDF forms for later completion
- Support JavaScript within a PDF form
I've tried a good few things and the closest I have so far are:
- Adobe's own control; this doesn't appear to respond to click events from the individual fields within a form when it is displayed, and I also couldn't see how to progrmatically set form field values.
- O2Solutions PDFView4Net control; this however doesn't support Javascript or appear to allow partially filled forms to be saved.
I'm tearing my hair out over this one...
I appreciate your help,
fiveeuros
1. A PDF viewer that can be embedded into a Windows application
2. A PDF form that the user fills out.
Don't confuse them. In many ways these two things are unrelated. Or a better way to think about it is that they don't talk to one another in any kind of direct way. The PDF form lives in it's own little world and does it's thing and the viewer lives in it's world and does it's own thing. The viewer can open and close PDF files but thats about the only feature you can control programatically from the outside world. Obviously this isn't quite true, but you'll be happier if you don't push these limits.
That said, the only viewer that will support the kind of form interactivity (i.e. JavaScript) that you want is the Acrobat ActiveX Object. This viewer is really just a window into the real viewer (Acrobat or Reader), which the user has to have on thier system. And it supports everything Acrobat supports. I don't know why it wasn't responding to mouse events. I've used it in a VB program and didn't have a problem.
This ActiveX Object also supports a message passing protocal between JavaScript in a PDF and whatever is controling the ActiveX Object. So you can set PDF field values from the VB program, but to do it the PDF has to be setup to specifically handle the messages. And your VB program has to implement the proper protocal. I don't remeber what the name of this protocal is but I wouldn't try to implement it. There is another way. This ActiveX object is the same one that the browser uses and the message passing protocal is the same one used by browsers to talk to stuff loaded into an HTML Object tag. So here's my suggestion. Use the HTML viewer in your VB program. Have it load an HTML page that contains the scripting and the object tag for loading your PDF. When you need to load a new PDF just load another HTML page.
Ok, here's another idea. PDFs, through Acrobat/Reader, can talk to a server. You're VB program could easily contain a local server. All it has to do is listen on some odd socket number. Then you can setup the PDF to trade data with the VB program through the server.
Thom Parker
The source for PDF Scripting Info
[url=http://www.pdfScripting.com]pdfscripting.com[/url]
The Acrobat JavaScript Reference, Use it Early and Often
[url=http://www.adobe.com/devnet/acrobat/javascript.php]http://www.adobe.com/devnet/acrobat/javascript.php[/url]
Then most important JavaScript Development tool in Acrobat
[url=http://www.pdfscripting.com/public/34.cfm#JSIntro][b]The Console Window (Video tutorial)[/b][/url]
[url=http://www.acrobatusers.com/tutorials/2006/javascript_console][b]The Console Window(article)[/b][/url]
Thom Parker
The source for PDF Scripting Info
www.pdfscripting.com
Very Important - How to Debug Your Script