Do you own a Debenu Quick PDF Library version 7, 8, 9, 10, 11, 12, 13 or iSEDQuickPDF license? Upgrade to Debenu Quick PDF Library 14 today!

Debenu Quick PDF Library - PDF SDK Community Forum Homepage
Forum Home Forum Home > For Users of the Library > I need help - I can help
  New Posts New Posts RSS Feed - Javascript - Where?
  FAQ FAQ  Forum Search   Register Register  Login Login

Javascript - Where?

 Post Reply Post Reply
Author
Message
drsebast View Drop Down
Beginner
Beginner


Joined: 02 May 12
Location: Ohio
Status: Offline
Points: 3
Post Options Post Options   Thanks (0) Thanks(0)   Quote drsebast Quote  Post ReplyReply Direct Link To This Post Topic: Javascript - Where?
    Posted: 02 May 12 at 12:57PM
I have created pdf map pages from ESRI's ArcMap that contain multiple layers.  I have created pushbuttons (5 formfield checkboxs) on the legend items.  I want to attach javascript code (which I already have) to the each button which will toggle the visibilityof the legend layer (OCG) item.  This allows users to quickly toggle these 5 OCGs on and off.  Easier than using the layer menu because the script also toggles the labels for the OCG.

I have 476 map pages to update with this code.  I already have the code for entering other fields in place on these pages but I am stuck with the javascript.

I have gotton to where I am supposed to enter the javascript in the function (FormFieldJavaScriptAction for example).  My code is multiline.  How do I put it in this or other functions?  Can I enter a reference to a text file that has the code so that it loads the file and runs the script when clicked?  Do I have to somehow include the code in the pdf?  If so, how?  Basic code examples would be a great help.

Thanks in advance.
 
Back to Top
AndrewC View Drop Down
Moderator Group
Moderator Group
Avatar

Joined: 08 Dec 10
Location: Geelong, Aust
Status: Offline
Points: 841
Post Options Post Options   Thanks (0) Thanks(0)   Quote AndrewC Quote  Post ReplyReply Direct Link To This Post Posted: 02 May 12 at 3:35PM
Back to Top
drsebast View Drop Down
Beginner
Beginner


Joined: 02 May 12
Location: Ohio
Status: Offline
Points: 3
Post Options Post Options   Thanks (0) Thanks(0)   Quote drsebast Quote  Post ReplyReply Direct Link To This Post Posted: 02 May 12 at 3:52PM
I have already checked those out, but they don't answer my basic question.

For example, when entering the function FormFieldJavaScriptAction it calls for "Javascript as String" as a parameter.  One of the scripts I want to run when this button is pushed is:

var docOCGs = this.getOCGs();
for (var x=0; x < docOCGs.length; x++)
{
if(docOCGs[x].name == "City")
{
docOCGs[x].state = !docOCGs[x].state;
}
if(docOCGs[x].name == "City - Default")
{
docOCGs[x].state = !docOCGs[x].state;
}
}

This toggles the City OCG and its label OCG.  I can't enter this as the parameter because of the length and multilines.  How do I actually enter the above javascript into the pdf so that I can use this function to run it?  I can do it from a pdf editor one file at a time, but that isn't practical.
Back to Top
AndrewC View Drop Down
Moderator Group
Moderator Group
Avatar

Joined: 08 Dec 10
Location: Geelong, Aust
Status: Offline
Points: 841
Post Options Post Options   Thanks (0) Thanks(0)   Quote AndrewC Quote  Post ReplyReply Direct Link To This Post Posted: 03 May 12 at 12:04PM
You code can easily be added as a string.

string s = "var docOCGs = this.getOCGs();\n" +
  "for (var x=0; x < docOCGs.length; x++)\n" +
  {\n" + 
  if(docOCGs[x].name == "City") \n" +  
  {\n" +  
  docOCGs[x].state = !docOCGs[x].state;\n" +  
  }\n" +  
  if(docOCGs[x].name == "City - Default")\n" +  
  {\n" +  
  docOCGs[x].state = !docOCGs[x].state;\n" +  
  }\n" +  
  } \n";

Just pass this string to the FormFieldJavaScriptAction.  You could even put all of the code on one line and it would run fine.

I have already checked those out, but they don't answer my basic question.

For example, when entering the function FormFieldJavaScriptAction it calls for "Javascript as String" as a parameter.  One of the scripts I want to run when this button is pushed is:

string js = "var docOCGs = this.getOCGs();  for (var x=0; x < docOCGs.length; x++) if(docOCGs[x].name == "City") docOCGs[x].state = !docOCGs[x].state; if(docOCGs[x].name == "City - Default") docOCGs[x].state = !docOCGs[x].state; } "
Back to Top
drsebast View Drop Down
Beginner
Beginner


Joined: 02 May 12
Location: Ohio
Status: Offline
Points: 3
Post Options Post Options   Thanks (0) Thanks(0)   Quote drsebast Quote  Post ReplyReply Direct Link To This Post Posted: 03 May 12 at 12:11PM
Thank you for the idea and response.

I had just stumbled upon that approach yesterday and it does work.  It does seem clumsy and that there should be an easier way, but it works.

I may attempt to try reading the scripts from a file as a string just for the heck of it.  This would allow for much easier editing of the java and longer scripts.

Thanks again.
Back to Top
AndrewC View Drop Down
Moderator Group
Moderator Group
Avatar

Joined: 08 Dec 10
Location: Geelong, Aust
Status: Offline
Points: 841
Post Options Post Options   Thanks (0) Thanks(0)   Quote AndrewC Quote  Post ReplyReply Direct Link To This Post Posted: 04 May 12 at 10:05AM

Loading it as a string from a file would be the easiest and most manageable approach.

Andrew.
Back to Top
 Post Reply Post Reply
  Share Topic   

Forum Jump Forum Permissions View Drop Down

Forum Software by Web Wiz Forums® version 11.01
Copyright ©2001-2014 Web Wiz Ltd.

Copyright © 2017 Debenu. Debenu Quick PDF Library is a PDF SDK. All rights reserved. AboutContactBlogSupportOnline Store