Skip to main content
August 27, 2023
Answered

Hiding Specific Page in adobe Acrobat pro DC

  • August 27, 2023
  • 3 replies
  • 1948 views

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]);
}

 

This topic has been closed for replies.
Correct answer
var f = this.getField("c1");
if(f.isBoxChecked(0)){
this.getTemplate("2").spawn();
   }
else {
     this.deletePages(1);
}

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.

3 replies

Correct answer
September 3, 2023
var f = this.getField("c1");
if(f.isBoxChecked(0)){
this.getTemplate("2").spawn();
   }
else {
     this.deletePages(1);
}

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.

try67
Community Expert
Community Expert
August 27, 2023

Does this need to work in Reader, as well as in Acrobat?

Thom Parker
Community Expert
Community Expert
August 28, 2023

I think JR's link is pretty good. It shows several threads that describe various aspects of using page templates. Which is where I think the poster needs to start, since the code they posted is nonsensical.

 

Thom Parker - Software Developer at PDFScriptingUse the Acrobat JavaScript Reference early and often
try67
Community Expert
Community Expert
August 28, 2023

I had a look at those results and couldn't find a good starting point.

It's not even limited to the Acrobat forum...

JR Boulay
Community Expert
Community Expert
August 27, 2023
Acrobate du PDF, InDesigner et Photoshopographe
August 27, 2023

no real help with the given link

try67
Community Expert
Community Expert
August 27, 2023

Agreed. The search results are not enough to point you in the right direction.

This is better, I think: https://community.adobe.com/t5/acrobat-sdk-discussions/acrobat-checkbox-off-to-hide-a-spawned-page/m-p/12968952