Skip to main content
tpjmlu26
Participant
February 6, 2016
Answered

conditional page delete.

  • February 6, 2016
  • 1 reply
  • 4001 views

( I am using Adobe Pro XI and Adobe Standard XI)

I am looking for a Acroform button script to delete page 2 but only if the PDF is 3 pages ( or greater than 2 pages.)

My form is 2 pages by default and if the user needs to expand the document they can click a check box to spawn a new Template that becomes the new page 2. I have a reset button that will reset the form fields and deletes the new page 2.

THE PROBLEM: if the user does not opt to generate a new page 2 leaving it as a 2 page document as soon as they hit reset button the document now becomes a 1 page document.

So I need to figure out a way to use the page count feature to evaluate the PDF to see if it greater then 2 pages and if so then run the delete page 2 script.

The user will be using Adobe Reader XI or Reader DC to fill out the form.

Any help will be greatly appreciated from this scripting newbie.

Examples would help me modify to match my text fields.

Thanks in advance for your Help!

Tom McCarty

This topic has been closed for replies.
Correct answer George_Johnson

var spwndel = this.numPages.value;

if(spwndel>1) this.deletePages(1);

This the code I am trying to use to make this happen but it not working and not causing errors.

This would be easier if Adobe had scripting help pop ups like Excel VBA does


Change it to:

var spwndel = this.numPages;

Or simply:

if (numPages > 1) {

    deletePages(1);

}

1 reply

Inspiring
February 6, 2016

I would look at providing a document level control field that counts how many times the new page 2 has been spawned or deleted. If the count is one hide the spawn button and if 0 show the spawn field.

tpjmlu26
tpjmlu26Author
Participant
February 7, 2016

gkaiseril,

I am already hiding the spawn button if it is used once. Actually, I am using a blank text field to cover the spawn check box using show / hide.

My  need is to come up with a way to NOT delete page 2 when the reset button is selected AND  the spawn button was not pushed. The Form  is normally a 2 page document and it only becomes a 3 page document if the spawn button is pushed.

this.resetForm(["PO"]);

var g = this.getField("Current P.O. #");
g.value = Math.round(g.value + 1);

this.deletePages(1);  //this is the problem code...I need to change it to evaluate or some method to determine is the PDF is 3 pages if it is 3 pages then run the delete script if not then null.

I am not very good with scripting so this has been a road block for me.

I hope I was able to explain my problem a little better.

Thanks for the input all input is welcome and considered

tpjmlu26
tpjmlu26Author
Participant
February 7, 2016

var spwndel = this.numPages.value;

if(spwndel>1) this.deletePages(1);

This the code I am trying to use to make this happen but it not working and not causing errors.

This would be easier if Adobe had scripting help pop ups like Excel VBA does