Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
0

Is it possible to use an array to print page templates from a popup menu? (using Adobe Acrobat Pro X)

New Here ,
Jan 12, 2017 Jan 12, 2017

I have a form that has 3 standard pages(fillable) with several templates arranged into three categories (instructions).  I would like for the user to be able to print only the instructional pages needed by selecting them from a menu button. Is it possible to place the templates into an array by category that can be selected from a menu for printing?

var cChoice = app.popUpMenu( "Category A", "Category B", "Category C);

if (cChoice !=null){

    switch (cChoice) {

            case "Category A":

                    var a = new Array("Template_Page1", "Template_Page2", "Template_Page3", "Template_Page4","Template_Page5");

                        for (i = 0; i < a.length; i++){

                        a.spawn(this.numPages, false, false);}

                        //print Category A templates

                break;

            case "Category B":

                        var a = new Array("TemplateB_Page1", "TemplateB_Page2", "TemplateB_Page3");

                        for (i = 0; i < a.length; i++){

                        a.spawn(this.numPages, false, false);}

                        //print Category A templates

                break;

            case "Category B":

                        var a = new Array("TemplateC_Page1", "TemplateC_Page2", "TemplateC_Page3");

                        for (i = 0; i < a.length; i++){

                        a.spawn(this.numPages, false, false);}

                        //print Category A templates

                break;

    }

    }

TOPICS
Acrobat SDK and JavaScript , Windows
616
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Jan 13, 2017 Jan 13, 2017

I miss this.getTemplate( ... ) in your code.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Jan 15, 2017 Jan 15, 2017

Okay, I am not sure where this.getTemplate(...) would go in my code.  But here is my attempt at placing the missing statement in group A code.

var cChoice = app.popUpMenu( "Category A", "Category B", "Category C);

if (cChoice !=null){

    switch (cChoice) {

            case "Category A":

                    var a = new Array("Template_Page1", "Template_Page2", "Template_Page3", "Template_Page4","Template_Page5");

                    var b = this.getTemplate(a);

                    for (i = 0; i < b.length; i++){

                        b.spawn(this.numPages, false, false);}

                        //print Category A templates

                break;

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Jan 16, 2017 Jan 16, 2017

Read the documentation. The method getTemplate uses only one name as argument, no array.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Jan 16, 2017 Jan 16, 2017

Your code was close, but not quite there... It needs to be something like this:

var a = new Array("Template_Page1", "Template_Page2", "Template_Page3", "Template_Page4","Template_Page5");

for (i = 0; i < a.length; i++) {

    var b = this.getTemplate(a);

    b.spawn(this.numPages, false, false);

}

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Jan 26, 2017 Jan 26, 2017
LATEST

Thanks for the code assistance.  My final code result was :

var a = this.templates
for (i = 0; i < 6{ 

a.spawn(this.numPages, false, false); }
print ....

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines