Planet PDF Forum Planet PDF Forum
  New Posts New Posts RSS Feed - fdf load document javascript
  FAQ FAQ  Forum Search   Register Register  Login Login


Hi, welcome to the Foxit Planet PDF Forum. If you have PDF or Adobe Acrobat questions then the right place to ask them is here, in this forum.

fdf load document javascript

 Post Reply Post Reply
Author
mikew1 View Drop Down
New Member
New Member


Joined: 03 Aug 2017
Location: Kamloops BC
Points: 4
Post Options Post Options   Quote mikew1 Quote  Post ReplyReply Direct Link To This Post Topic: fdf load document javascript
    Posted: 03 Aug 2017 at 12:47am
Hi
I have been trying to find some information on fdf in particular loading document javascript.  i am sure i am not the first person to do this,   we have numerous pdfs with combo boxes (up to 25) on a page that contain employee names.  I presently have a document javascript that loads the combo boxes.  I would like to set this into a fdf so there is only one place to manage the employee name lists for all the pdfs (over 50) for when employees change leave or are hired.  The pdfs are all in one directory and the fdf would be in that directory as well.  Is this possible?  What am i doing wrong, and is there any good references for fdf.

%FDF-1.2
1 0 obj
<<
/FDF
<<
/JavaScript 
<<
var aItems = new Array([" ",""],
 ["1Andy","48"],
 ["1Bill","69"],
 ["1Ian","11"],
 ["1Lee","24"],
 ["1Leif","25"],
 ["1Kyle","61"],
 ["1Riley","30"],
 ["1Andrew","91"]
 ["1Duncan","26"],
 ["Rich","24"],
 ["Tyler","70"],
 ["  ","   "]); 
var oComboBox = this.getField("NTech1");
oComboBox.setItems(aItems);
var oComboBox = this.getField("NTech2"); 
oComboBox.setItems(aItems);
var oComboBox = this.getField("NTech3");
oComboBox.setItems(aItems);
var oComboBox = this.getField("NTech4");
oComboBox.setItems(aItems);
var oComboBox = this.getField("NTech5");
oComboBox.setItems(aItems);
var oComboBox = this.getField("NTech6");
oComboBox.setItems(aItems);
var oComboBox = this.getField("NTech7");
oComboBox.setItems(aItems);
var oComboBox = this.getField("NTech8");
oComboBox.setItems(aItems);
var oComboBox = this.getField("NTech9");
oComboBox.setItems(aItems);
var oComboBox = this.getField("NTech10");
oComboBox.setItems(aItems);
var oComboBox = this.getField("NTech11");
oComboBox.setItems(aItems);
var oComboBox = this.getField("NTech12");
oComboBox.setItems(aItems);
var oComboBox = this.getField("NTech13");
oComboBox.setItems(aItems);
var oComboBox = this.getField("NTech14");
oComboBox.setItems(aItems);
var oComboBox = this.getField("NTech15");
oComboBox.setItems(aItems);
var oComboBox = this.getField("NTech16");
oComboBox.setItems(aItems);
var oComboBox = this.getField("NTech17");
oComboBox.setItems(aItems);
var oComboBox = this.getField("NTech18");
oComboBox.setItems(aItems);
var oComboBox = this.getField("NTech19");
oComboBox.setItems(aItems);
var oComboBox = this.getField("NTech20");
oComboBox.setItems(aItems);
var oComboBox = this.getField("NTech21");
oComboBox.setItems(aItems);
var oComboBox = this.getField("NTech22");
oComboBox.setItems(aItems);
var oComboBox = this.getField("NTech23");
oComboBox.setItems(aItems);
var oComboBox = this.getField("NTech24");
oComboBox.setItems(aItems);
var oComboBox = this.getField("NTech25");
oComboBox.setItems(aItems);>>
>>
endobj
trailer
<<
/Root 1 0 R
>>
%%EOF
Back to Top
Sponsored Links


Back to Top
gkaiseril View Drop Down
Senior Member
Senior Member


Joined: 15 Jul 2011
Location: USA
Points: 4071
Post Options Post Options   Quote gkaiseril Quote  Post ReplyReply Direct Link To This Post Posted: 04 Aug 2017 at 5:29pm
A search of the content of this site has sAutomatic Insertion of Document-Level JavaScript by D.P. Story. You need to define either an object or stream which contains your script and the name to assign to it. It is even possible to run other scripts before or after the addition of the script. So you could add the script and then execute after it has been added.

Have you considered using the Action Manager, Batch Processor, to run the script to populate the fields?
Back to Top
mikew1 View Drop Down
New Member
New Member


Joined: 03 Aug 2017
Location: Kamloops BC
Points: 4
Post Options Post Options   Quote mikew1 Quote  Post ReplyReply Direct Link To This Post Posted: 04 Aug 2017 at 11:04pm
Thanks for the reply
I used that sample for trying out,  It works and my employee name one works in adobe reader, but not in foxit phantom or reader,  comes up with generic error unable to open file.  I exported the document to a fdf, and imported.  That worked okay with just the fields.  
Used the same fdf, kept the first and last line and pasted in the sample file you sent link to and still get unable to open file.  
The users are using this out in the field on tablets, for a bit of background.

The sample fdf (testfdf3phantom) is linked to site  employee(testfdf5phantom) to workorder
Back to Top
gkaiseril View Drop Down
Senior Member
Senior Member


Joined: 15 Jul 2011
Location: USA
Points: 4071
Post Options Post Options   Quote gkaiseril Quote  Post ReplyReply Direct Link To This Post Posted: 04 Aug 2017 at 11:44pm
Not all PDF processing programs work the same way. This appears to be a feature for Acrobat and Reader. 

For updating the document level script to populate dropdown list, I would create the forms with a document level script function to populate dropdown fields and then use an Action to revise the data tables or the whole script.
Back to Top
mikew1 View Drop Down
New Member
New Member


Joined: 03 Aug 2017
Location: Kamloops BC
Points: 4
Post Options Post Options   Quote mikew1 Quote  Post ReplyReply Direct Link To This Post Posted: 04 Aug 2017 at 11:49pm
Thanks for the reply.   It appears that foxit doesn't allow fdf javascript or requires some unique formating.   I have been doing what you suggested,  but we are now over 200 different forms for the company and it would be really nice if there was one place i had to change the name list instead of 200.
Also this is a backdoor way of linking back into a db.

Mikew1
Back to Top
albanomoura View Drop Down
New Member
New Member


Joined: 17 Aug 2017
Location: Melbourne, AU
Points: 1
Post Options Post Options   Quote albanomoura Quote  Post ReplyReply Direct Link To This Post Posted: 17 Aug 2017 at 6:51am
Hi mikew1,

To manage combo boxes in multiple PDFs programmatically, do the following steps:

- First, you should edit all the PDFs and then add an action on the particular page using the JavaScript shown below.

tthis.importAnFDF("dljs.fdf") /where "dljs.fdf" is the path of the fdf file.

If you have 20 PDFs to maintain, then you should add an action to these documents one by one. Foxit Reader/PhantomPDF doesn't support adding this script to multiple PDFs without opening them.
 

- Then, prepare your fdf with the formatting shown in the script below. 

%FDF-1.2
1 0 obj
<</FDF<</UF(1.pdf)/F(1.pdf)/Fields[<</T(Combo Box0)/V(2)>><</T(Combo Box1)/V(12)>><</T(Combo Box2)/V(13)>>]>>>>

endobj
 
trailer
<</Root 1 0 R>>
%%EOF
 
That way, when you want to update an employees’ information, you just need to update the value in the brackets behind “V”.
 
- When you open the document and go to the page, the fdf will be loaded and populate the form fields with the new information.

Hope this can help,

Albano
Back to Top
mikew1 View Drop Down
New Member
New Member


Joined: 03 Aug 2017
Location: Kamloops BC
Points: 4
Post Options Post Options   Quote mikew1 Quote  Post ReplyReply Direct Link To This Post Posted: 17 Aug 2017 at 4:04pm
Thanks that will work, but i am still trying to find out if foxit pdfs will support the /javascript   in a fdf
No one seems to be able to give me an answer at foxit.

Mike
Back to Top
 Post Reply Post Reply
  Share Topic   

Forum Jump Forum Permissions View Drop Down

Forum Software by Web Wiz Forums® version 11.10
Copyright ©2001-2017 Web Wiz Ltd.

This page was generated in 0.016 seconds.