Print Page | Close Window

fdf load document javascript

Printed From: Foxit's Planet PDF Forum
Category: Lets Talk PDF
Forum Name: General
Forum Description: This is for experienced PDF users. Here you can talk about any topics not set aside for Developers, Prepress and PDF Forms.
URL: http://forums.planetpdf.com/forum_posts.asp?TID=2220
Printed Date: 24 Nov 2017 at 2:57pm
Software Version: Web Wiz Forums 11.10 - http://www.webwizforums.com


Topic: fdf load document javascript
Posted By: mikew1
Subject: fdf load document javascript
Date 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



Replies:
Posted By: gkaiseril
Date Posted: 04 Aug 2017 at 5:29pm
A search of the content of this site has s http://www.planetpdf.com/developer/article.asp?ContentID=6505%20 - Automatic 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?


Posted By: mikew1
Date 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
uploads/3356/testdataloadpdf.zip - uploads/3356/testdataloadpdf.zip


Posted By: gkaiseril
Date 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.


Posted By: mikew1
Date 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


Posted By: albanomoura
Date 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


Posted By: mikew1
Date 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



Print Page | Close Window

Forum Software by Web Wiz Forums® version 11.10 - http://www.webwizforums.com
Copyright ©2001-2017 Web Wiz Ltd. - https://www.webwiz.net