Skip to main content
Known Participant
September 21, 2023
Question

Show/Hide pages

  • September 21, 2023
  • 4 replies
  • 2699 views

Hi

I have been reading through the treads and am just wondering if there is a way to have layering work for a full page in a pdf form?

I can set up a form using pages as templates and then deleting the spawned page, but this is a risk, in that I can't specifically specify that only the spawned page is deleted. If someone accidentally hits the delete button before adding the spawned page then the next page in the form, which is required, is deleted and you can't retrieve it unless you cancel out of the form and start again.

Is there a way to stop this from happening by changing the javascript to only delete the spawned page and no other pages in the form?

Or I would prefer to be able to show and hide pages that aren't needed like it used to do in Lifecycle, as deleting pages is problematic with users who don't know what they are doing.

Hence my reason for asking if layering can work on a whole page instead of certain areas of a page.

This topic has been closed for replies.

4 replies

JR Boulay
Community Expert
Community Expert
September 25, 2023

You should use something like this:

 

if(event.target.value == "Off")
if (this.numPages > 6) {this.deletePages(2,7);}
else {
if (this.numPages == 6) {
var a = this.getTemplate("Excursion");a.spawn(2,false,false);
var b = this.getTemplate("Catering");b.spawn(3,false,false);
var c = this.getTemplate("Boarding");c.spawn(4,false,false);
var d = this.getTemplate("Bus");d.spawn(5,false,false);
var e = this.getTemplate("Budget");e.spawn(6,false,false);
var f = this.getTemplate("Facilities");f.spawn(7,false,false);
}
}

 

 

Acrobate du PDF, InDesigner et Photoshopographe
Known Participant
September 25, 2023

Thanks JR that makes more sense and is safer :).

JR Boulay
Community Expert
Community Expert
September 22, 2023

"I have 6 static pages and 6 spawned pages (the 6 spawned pages appear between pages 2 & 3 of the static ones. "

So your JavaScript must first check the number of pages in the document before deleting any.

Is it the same template page that is spawned each time or are they different template pages?

Acrobate du PDF, InDesigner et Photoshopographe
Known Participant
September 25, 2023

JR they are 6 different templates, but I worked out how to do it using the following javascript attached to a checkbox:

 

if(event.target.value == "Off")
   this.deletePages(2,7);
else
{
   var a = this.getTemplate("Excursion");a.spawn(2,false,false);
var b = this.getTemplate("Catering");b.spawn(3,false,false);
var c = this.getTemplate("Boarding");c.spawn(4,false,false);
var d = this.getTemplate("Bus");d.spawn(5,false,false);
var e = this.getTemplate("Budget");e.spawn(6,false,false);
var f = this.getTemplate("Facilities");f.spawn(7,false,false);
}

 

 

JR Boulay
Community Expert
Community Expert
September 21, 2023

"but this is a risk, in that I can't specifically specify that only the spawned page is deleted. If someone accidentally hits the delete button before adding the spawned page"

Your button is not correctly JavaScripted otherwise there would be no risk of error.

How many static pages contain your document and how many spawned pages?

Is it spawned at the end of the file?

What is the script used?

Acrobate du PDF, InDesigner et Photoshopographe
Known Participant
September 21, 2023

I worked out what I was doing wrong. I was trying to delete the spawned pages from outside the spawned page itself. so I moved the delete button to the template so when the spawned page appears then you only delete that one page.

try67
Community Expert
Community Expert
September 21, 2023

You can delete a spawned page from any other page in the file. That's not the issue.

Bernd Alheit
Community Expert
Community Expert
September 21, 2023

Info: Users with Acrobat Reader can only delete spawned pages.