• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
0

Deleting spawned pages

Community Beginner ,
Aug 15, 2019 Aug 15, 2019

Copy link to clipboard

Copied

I am trying to find a script that will delete all spawned pages, regardless of the number of pages.  I want to be able to set the document back to original.  The number of spawned pages may vary.

TOPICS
Acrobat SDK and JavaScript , Windows

Views

1.3K

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines

correct answers 2 Correct answers

Community Beginner , Aug 15, 2019 Aug 15, 2019

This is my simplified solution to my problem, no matter how many pages were spawned there will always be a page 1 until there isn't so I have a reset button that resets all the fields and then deletes page 1 twelve times.  It will stop deleting when there is no longer a page 1 to delete.

n=app.alert("Are you sure you want to Reset?",2,1);

if (n==1){

this.resetForm();   

}

if (numPages > 1) {

deletePages(1);

deletePages(1);

deletePages(1);

deletePages(1);

deletePages(1);

deletePages(1);

deletePages(1

...

Votes

Translate

Translate
Community Expert , Aug 15, 2019 Aug 15, 2019

That's very redundant. Instead, you can use this single command:

if (numPages > 1) {

     this.deletePages(1, this.numPages-1);

}

Votes

Translate

Translate
Community Expert ,
Aug 15, 2019 Aug 15, 2019

Copy link to clipboard

Copied

Does you use form fields on the spawned pages?

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
Aug 15, 2019 Aug 15, 2019

Copy link to clipboard

Copied

I do use form fields on the pages which have all unique names, there are 9 templates that could be spawned but possible only a couple will be

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Aug 15, 2019 Aug 15, 2019

Copy link to clipboard

Copied

The field names of the spawned pages have the following form:

P<page no>:<template name>:<field name>

When you check all fields in the document you can find all spawned pages.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
Aug 15, 2019 Aug 15, 2019

Copy link to clipboard

Copied

That's great, can you get me started on the code?

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
Aug 15, 2019 Aug 15, 2019

Copy link to clipboard

Copied

This is my simplified solution to my problem, no matter how many pages were spawned there will always be a page 1 until there isn't so I have a reset button that resets all the fields and then deletes page 1 twelve times.  It will stop deleting when there is no longer a page 1 to delete.

n=app.alert("Are you sure you want to Reset?",2,1);

if (n==1){

this.resetForm();   

}

if (numPages > 1) {

deletePages(1);

deletePages(1);

deletePages(1);

deletePages(1);

deletePages(1);

deletePages(1);

deletePages(1);

deletePages(1);

deletePages(1);

deletePages(1);

deletePages(1);

deletePages(1);

}

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Aug 15, 2019 Aug 15, 2019

Copy link to clipboard

Copied

That's very redundant. Instead, you can use this single command:

if (numPages > 1) {

     this.deletePages(1, this.numPages-1);

}

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
Aug 15, 2019 Aug 15, 2019

Copy link to clipboard

Copied

LATEST

Thanks, that is much better.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines