Spawn a page using drop down box

Is it possible to create a drop down list to spawn multiple types of page templates made from the information from one form? (using Adobe Acrobat DC Pro
Example
Form A with B template
Form A with C template
Form A with D template
Form A with E template


I am brand new to Acrobat and Java so please provide specific Java for this.


JENNIFER RICHARDS


4 Answers

Voted Best Answer

First, we are dealign with JavaScript. Even though the name sounds very similar, it is a completely different environment from Java. This is important if you try to google for information. Anything you find about Java would not be applicable.

Assuming you have a dropdown that uses export values from 1 to 5, and you have a button that when clicked is getting the information from the dropdown and then spawns the template, you can use the following script as the mouse up action of the button:

// get the value from the dropdown control
var sel = this.getField("Dropdown").value;

// determine the template name
var templateName = "";
switch (sel) {
    case 1 : templateName = "TemplateA";
        break;
    case 2 : templateName = "TemplateB";
        break;
    case 3 : templateName = "TemplateC";
        break;
    case 4 : templateName = "TemplateD";
        break;
    case 5 : templateName = "TemplateE";
        break;
}

// if we have a template name, spawn the template
if (templateName != "") {
    var t = this.getTemplate(templateName);
    t.spawn();
}

Karl Heinz Kremer
PDF Acrobatics Without a Net
PDF Software Development, Training and More...
http://www.khkonsulting.com


By Karl Heinz Kremer   

Please provide more clarity. What are the drop-down values and what do you want to happen when they are selected?


David Dagley   

What do you mean by "perimeters"?

When you take my original code, and merge it with the three potential settings from your code, this should work:

// get the value from the dropdown control var sel = this.getField("Post Admission Letters").value;

// determine the template name var templateName = ""; switch (sel) { case 1: templateName = "MCR ONLY"; break; case 2: templateName = "MCR WITH INS AND MCD"; break; case 3: templateName = "MCR WITH INSURANCE"; break; }

// if we have a template name, spawn the template if (templateName != "") { var t = this.getTemplate(templateName); t.spawn(); }

Again, this only works if your dropdown control does use the values 1, 2 and 3 as export values.

Karl Heinz Kremer
PDF Acrobatics Without a Net
PDF Software Development, Training and More...
http://www.khkonsulting.com


Karl Heinz Kremer   

Oops, it looks my code formatting did not survive. Let's try again:

// get the value from the dropdown control 
var sel = this.getField("Post Admission Letters").value;

// determine the template name
var templateName = ""; 
switch (sel) { 
  case 1: templateName = "MCR ONLY"; 
    break; 
  case 2: templateName = "MCR WITH INS AND MCD";
    break; 
  case 3: templateName = "MCR WITH INSURANCE";
    break; 
}

// if we have a template name, spawn the template 
if (templateName != "") { 
  var t = this.getTemplate(templateName); 
  t.spawn(); 
}


Karl Heinz Kremer   


Please specify a reason: