Filling out a form programaticallty

PDF-XChange Viewer SDK for Developer's
(ActiveX and Simple DLL Versions)

Moderators: TrackerSupp-Daniel, Tracker Support, Vasyl-Tracker Dev Team, Chris - Tracker Supp, Sean - Tracker, Ivan - Tracker Software, Tracker Supp-Stefan

PaulT
User
Posts: 40
Joined: Tue Jun 01, 2010 9:03 pm

Filling out a form programaticallty

Post by PaulT »

We were given a .pdf form. We would like to programatically fill out the form with user name, etc. from an oracle table, and email the form to the user. They will fill in the rest and send it back.

My thought was to just create a series of .fdf files and merge these in 1 at a time. Would that work?

What are some alternative choices? If I need the SDK, so be it.

Paul
(What has Clarion got to do with pdf files?)
Tracker - Clarion Support
Site Admin
Posts: 64
Joined: Wed Jun 30, 2004 4:45 pm
Location: Maryland, USA

Re: Filling out a form programaticallty

Post by Tracker - Clarion Support »

Hi Paul!

If you can use the FDF format, go for it!

If you want to do it a bit more dynamically, please download the Viewer SDK from the Developer Downloads, and then check out demo pvxd2f20.app for an example of filling out a form programmatically.
Craig Ransom
Tracker Software - Clarion Support
http://www.tracker-software.com
PaulT
User
Posts: 40
Joined: Tue Jun 01, 2010 9:03 pm

Re: Filling out a form programaticallty

Post by PaulT »

Ok thanks, I'll have a look at the SDK.

Is info avalable about the parts of the .fdf file that aren't intuitively obvious? (ie, the binary or encryppted fields)

Paul
Tracker - Clarion Support
Site Admin
Posts: 64
Joined: Wed Jun 30, 2004 4:45 pm
Location: Maryland, USA

Re: Filling out a form programaticallty

Post by Tracker - Clarion Support »

Hi Paul!

Not from us. However, the FDF format should be documented by Adobe. I'd check their website for FDF documentation.

The example I recommended to you is a "database to form fields" using the Adobe Acrobat JavaScript extensions. It does not use FDF at all.
Craig Ransom
Tracker Software - Clarion Support
http://www.tracker-software.com
PaulT
User
Posts: 40
Joined: Tue Jun 01, 2010 9:03 pm

Re: Filling out a form programaticallty

Post by PaulT »

Oh, I see! Thanks - Then I'm off to look at the sdk.

Paul
(I get the clarion reference now...)
PaulT
User
Posts: 40
Joined: Tue Jun 01, 2010 9:03 pm

Re: Filling out a form programaticallty

Post by PaulT »

Tracker - Clarion Support wrote:... the Viewer SDK from the Developer Downloads, and then check out demo pvxd2f20.app .
I don't have that available as a demo - Is it a language specific demo that I didn't install...?

Paul
Tracker - Clarion Support
Site Admin
Posts: 64
Joined: Wed Jun 30, 2004 4:45 pm
Location: Maryland, USA

Re: Filling out a form programaticallty

Post by Tracker - Clarion Support »

Hi Paul!

It's Clarion-specific. This is posted in the Clarion forum.

What language are you developing this in?
Craig Ransom
Tracker Software - Clarion Support
http://www.tracker-software.com
PaulT
User
Posts: 40
Joined: Tue Jun 01, 2010 9:03 pm

Re: Filling out a form programaticallty

Post by PaulT »

When I first showed up at the site, Clarion was the only forum visible. (I did ask right off the top what clarion had to do with the product - and I get that now)

I haven't settled on a language yet, but did install for c++ c# and both VBs.

Paul
User avatar
Tracker Supp-Stefan
Site Admin
Posts: 17960
Joined: Mon Jan 12, 2009 8:07 am
Location: London

Re: Filling out a form programaticallty

Post by Tracker Supp-Stefan »

Do you see the other Forums now Paul?

As if not I can check your account's privileges and fix that.

Regards,
Stefan
PaulT
User
Posts: 40
Joined: Tue Jun 01, 2010 9:03 pm

Re: Filling out a form programaticallty

Post by PaulT »

Stefan,

I'm good now, thanks.

Paul
User avatar
Tracker Supp-Stefan
Site Admin
Posts: 17960
Joined: Mon Jan 12, 2009 8:07 am
Location: London

Re: Filling out a form programaticallty

Post by Tracker Supp-Stefan »

Ok so then this topic is in the wrong forums and the examples quoted by Craig are Clarion specific.
I will check now whether there are corresponding C++ examples.

Cheers,
Stefan
Tracker - Clarion Support
Site Admin
Posts: 64
Joined: Wed Jun 30, 2004 4:45 pm
Location: Maryland, USA

Re: Filling out a form programaticallty

Post by Tracker - Clarion Support »

Hi Paul!

Glad to see you got that sorted! :)

If it's Visual C++ I can still help, but my C# and VB is weak. :wink:
Craig Ransom
Tracker Software - Clarion Support
http://www.tracker-software.com
PaulT
User
Posts: 40
Joined: Tue Jun 01, 2010 9:03 pm

Re: Filling out a form programaticallty

Post by PaulT »

Thanks Stefan - that's all I need at this point.

(I didn't think anyone would want me to start over elsewhere.)

Paul
Tracker - Clarion Support
Site Admin
Posts: 64
Joined: Wed Jun 30, 2004 4:45 pm
Location: Maryland, USA

Re: Filling out a form programaticallty

Post by Tracker - Clarion Support »

Hi Paul!

We can move this thread to another forum, so that's cool.

However, the internal basics of Viewer ActiveX JavaScript remain the same, so I'm posting the JS we use in the Clarion program:

Code: Select all

function loadfield( fldName, fldValue ) {
  var tst = fldName.toUpperCase();
  for ( var i = 0; i < this.numFields; i++ ) {
    var fname = this.getNthFieldName(i);
    var ft = fname.toUpperCase();
    if ( tst == ft ) {
      var f = this.getField(fname);
      switch( f.type ) {
        case "text":
          f.value = fldValue;
          break;
        case "listbox":
        case "combobox":
          for ( var j = 0; j < f.numItems; j++ ) {
            if ( fldValue == f.getItemAt(j) ) {
              f.currentValueIndices = j;
              break;
            }
        }
        if ( f.type == "combobox" )
          f.value = fldValue;
          break;
        case "checkbox":
          switch ( fldValue.toUpperCase() ) {
            case "OFF":
            case "NO":
            case "FALSE":
            case "0":
              f.checkThisBox(0, false);
              break;
          default:
            f.checkThisBox(0, true);
            break;
          }
          break;
        case "radiobutton":
          f.checkThisBox(fldValue - 0);
        case "button":
        case "signature":
          default:
          break;
      }
    }
  }
}
// Added by Calling Program:
loadfield("DATE","75546");
loadfield("TIME","7712827");
loadfield("EMAIL","craigr@docu-track.com");
loadfield("ACCOUNT","MyAccount");
loadfield("PASSWORD","MyPassword");
loadfield("FIRSTNAME","Craig");
loadfield("LASTNAME","Ransom");
loadfield("BIRTHDATE","09/11/1947");
loadfield("BOOKSCHK","Yes");
loadfield("MAGAZINESCHK","Yes");
loadfield("NEWSPAPERSCHK","Yes");
loadfield("COUNTRY","Germany");
function loadfield remains the same in all cases.

The lines that execute loadfield at the end are built by the calling program and then the whole thing is passed to the Viewer ActiveX. The first field in each call is the PDF Form field name; the second is the data to be inserted in that field.
Craig Ransom
Tracker Software - Clarion Support
http://www.tracker-software.com
PaulT
User
Posts: 40
Joined: Tue Jun 01, 2010 9:03 pm

Re: Filling out a form programaticallty

Post by PaulT »

Stefan,

Thank you! Looks to be just what I need.

Move if you weill ;-)

Paul
User avatar
Tracker Supp-Stefan
Site Admin
Posts: 17960
Joined: Mon Jan 12, 2009 8:07 am
Location: London

Re: Filling out a form programaticallty

Post by Tracker Supp-Stefan »

Well the kudos are for Craig - he is the one "hiding" behind Tracker - Clarion Support :)

As for the topic - moved it to the non Clarion Viewer SDK forum.

Cheers,
Stefan
PaulT
User
Posts: 40
Joined: Tue Jun 01, 2010 9:03 pm

Re: Filling out a form programaticallty

Post by PaulT »

I'm working with the VB Full Demo at the moment, and pasted the JS code into the Java Script window - modifying the bottom bit for the correct field names - works like a charm.

This begs the question: does that mean the 'native' language for the active-x control is JS? Said another way - is there some other non-js way of filling in the fields? ...or... It just feels wrong somehow to come up with a basic VB app (no pun intended) at the heart of which is a bit of JS code to do the grunt work.

Paul
Tracker - Clarion Support
Site Admin
Posts: 64
Joined: Wed Jun 30, 2004 4:45 pm
Location: Maryland, USA

Re: Filling out a form programaticallty

Post by Tracker - Clarion Support »

Hi Paul!

For the Viewer ActiveX, as far as I know, JS is the only way at the current time. I'll ask our Project Manager to be sure.

If not, they may add better form management in version 3, but that is no time soon. Don't ask for a time frame for 3; I have none.
Craig Ransom
Tracker Software - Clarion Support
http://www.tracker-software.com
PaulT
User
Posts: 40
Joined: Tue Jun 01, 2010 9:03 pm

Re: Filling out a form programaticallty

Post by PaulT »

Craig,

Thanks for checking...

If any of the other SDKs have direct field support, them I'm all ears. I'll continue to have a look at the demo for now.

Paul
User avatar
Ivan - Tracker Software
Site Admin
Posts: 3556
Joined: Thu Jul 08, 2004 10:36 pm
Location: Vancouver Island - Canada

Re: Filling out a form programaticallty

Post by Ivan - Tracker Software »

This begs the question: does that mean the 'native' language for the active-x control is JS?
No, it is not. JS is just one more way to do the job, or often only one possible way to do it when feature isn't supported directly by AX (like with forms - AX doesn't provide objects to work with form fields).

You can use JS not only from AX, but also in end-user viewer through JS console (use Ctrl + J shortcut to open it).
Tracker Software (Project Director)

When attaching files to any message - please ensure they are archived and posted as a .ZIP, .RAR or .7z format - or they will not be posted - thanks.
Tracker - Clarion Support
Site Admin
Posts: 64
Joined: Wed Jun 30, 2004 4:45 pm
Location: Maryland, USA

Re: Filling out a form programaticallty

Post by Tracker - Clarion Support »

Hi guys!
You can use JS not only from AX, but also in end-user viewer through JS console (use Ctrl + J shortcut to open it).
Which is how I originally tested my script ! :)
Craig Ransom
Tracker Software - Clarion Support
http://www.tracker-software.com
PaulT
User
Posts: 40
Joined: Tue Jun 01, 2010 9:03 pm

Re: Filling out a form programaticallty

Post by PaulT »

Ivan - Tracker Software wrote:JS is just one more way to do the job, or often only one possible way to do it when feature isn't supported directly by AX (like with forms - AX doesn't provide objects to work with form fields).

You can use JS not only from AX, but also in end-user viewer through JS console (use Ctrl + J shortcut to open it).
Ahh, I see now.Just a way of being 'future ready'. Cool.

Paul
User avatar
John - Tracker Supp
Site Admin
Posts: 5219
Joined: Tue Jun 29, 2004 10:34 am
Location: United Kingdom

Re: Filling out a form programaticallty

Post by John - Tracker Supp »

:)
If posting files to this forum - you must archive the files to a ZIP, RAR or 7z file or they will not be uploaded - thank you.

Best regards
Tracker Support
http://www.tracker-software.com
Tracker - Clarion Support
Site Admin
Posts: 64
Joined: Wed Jun 30, 2004 4:45 pm
Location: Maryland, USA

Re: Filling out a form programaticallty

Post by Tracker - Clarion Support »

Hi Paul!

Actually there's more to it than that.

The PDF specification supports inclusion of JavaScripts within PDF documents. They can be triggered in various ways, including buttons, mouse-over, links, etc.

Adobe publishes JS API documentation at their site:

http://www.adobe.com/devnet/acrobat/javascript.html

The various documents describe how to use JS and how to include it in PDF documents.
Craig Ransom
Tracker Software - Clarion Support
http://www.tracker-software.com
PaulT
User
Posts: 40
Joined: Tue Jun 01, 2010 9:03 pm

Re: Filling out a form programaticallty

Post by PaulT »

Thanks for th elink - I've marked it to have a look at some point.

Paul
User avatar
John - Tracker Supp
Site Admin
Posts: 5219
Joined: Tue Jun 29, 2004 10:34 am
Location: United Kingdom

Re: Filling out a form programaticallty

Post by John - Tracker Supp »

;-)
If posting files to this forum - you must archive the files to a ZIP, RAR or 7z file or they will not be uploaded - thank you.

Best regards
Tracker Support
http://www.tracker-software.com