Skip to main content
Participant
December 6, 2021
Question

Deleting Pages

  • December 6, 2021
  • 3 replies
  • 381 views

If a box is ticked, I want the last 2 pages of the form deleted. 
I have used the script;

this.deletePages(0,3)

This works and deletes the first 4 pages but when I alter it to delete the last 2 it doesn't work. 
Form is 7 pages long so I did (7,8). 

Any help to what I am doing wrong would be great. Thanks

This topic has been closed for replies.

3 replies

try67
Community Expert
Community Expert
December 7, 2021

If you want to delete pages 6 and 7 use this:

 

this.deletePages(5,6);

 

If you want to delete the last two pages, no matter how many pages there are in the file (assuming there are more than 2), use this:

 

if (this.numPages>2) this.deletePages(this.numPages-2,this.numPages-1);

JR Boulay
Community Expert
Community Expert
December 7, 2021

This script deletes the last page of a document and is independent of the number of pages.

Just use it 2 consecutive times.

 

this.deletePages({ nStart: this.numPages - 1 });

Acrobate du PDF, InDesigner et Photoshopographe
Bernd Alheit
Community Expert
Community Expert
December 7, 2021

Use (5,6)

The last page is 6 and the page before the last is 5.