javascriptpdfadobeacrobat

Hiding Specific Page in adobe Acrobat pro DC


Hiding specific pages based on a checkbox is unchecked and when checked it will show the page. Here's the script that I'm using but it is not working please help:

// Replacing "Checkbox1" with the actual name of your checkbox field

var checkbox = this.getField("Checkbox1");

// Replacing "PageNumberToHide" with the page number you want to hide

var pageToHide = this.getPageNthNum("PageNumberToHide");

if (checkbox.value == "Off") {
    this.hidePages([pageToHide]);
} else {
    this.showPages([pageToHide]);
}

Solution

  • change the ("c1") with your button or checkbox name, change the template name ("2") to spawn your template, and lastly change the delete page number ("1") which page you want to delete.

    Delete page method is 0= page1, 1= page2 , 2= page3....etc.

    var f = this.getField("c1");
    if(f.isBoxChecked(0)){
    this.getTemplate("2").spawn();
       }
    else {
         this.deletePages(1);
    }