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

delete pages after the choice change with a dropdown list

New Here ,
May 03, 2018 May 03, 2018

Copy link to clipboard

Copied

Hi ! i am working with acrobat DC (15) on Windows.

thanks to : Spawn a page using drop down box (JavaScript) , i am able to spawn a template.

I have a dropdown list with 3 choices (A,B and C) and a button submit ( the code from the topic are inside this button) and then i spwan a template.

However, i would like to delete the template if the user change his choice from A to B ...

i konw how to delete a page : {this.deletePages(1)} but where i could apply it ???

Thxxxxxxx !!!

TOPICS
Acrobat SDK and JavaScript

Views

847

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 ,
May 03, 2018 May 03, 2018

Copy link to clipboard

Copied

In the same place where you're spawning the pages. You will need to first check if there's a need to delete such a page, though.

For example, you can check the total number of pages in the file (numPages property). If it's not the original number, delete the additional pages and then spawn the new ones.

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
New Here ,
May 03, 2018 May 03, 2018

Copy link to clipboard

Copied

I am really a newbie ... may i have some code ?? 😃

I have this :

// get the value from the dropdown control

var sel = this.getField("liste_qualif").value;

// determine the template name

var templateName = "";

switch (sel) {

  case 1: templateName = "CRI";

    break;

  case 2: templateName = "FI";

    break;

  case 3: templateName = "FTI de FTI";

    break;

    case 4: templateName = "FTI";

    break;

    case 5: templateName = "IRI";

    break;

    case 6: templateName = "MCCI";

    break;

    case 7: templateName = "SFI";

    break;

    case 8: templateName = "STI";

    break;

    case 9: templateName = "TRI";

    break;

}

// if we have a template name, spawn the template

if (templateName != "") {

  var t = this.getTemplate(templateName);

  t.spawn();

}

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 ,
May 03, 2018 May 03, 2018

Copy link to clipboard

Copied

How many pages are there in the file before you spawn the template?

Are you always spawning the new pages as the last pages of the file?

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
New Here ,
May 07, 2018 May 07, 2018

Copy link to clipboard

Copied

i have 9 pages and yes it will always spawn at the last page

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 ,
May 07, 2018 May 07, 2018

Copy link to clipboard

Copied

HI,

Will you always only spawn one page at the end of the document?

Regards

Malcolm

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
New Here ,
May 07, 2018 May 07, 2018

Copy link to clipboard

Copied

Yes, only one page 😃

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 ,
May 07, 2018 May 07, 2018

Copy link to clipboard

Copied

Then you can use this code to delete all the spawned pages:

if (this.numPages>9) this.deletePages(9, 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
New Here ,
May 07, 2018 May 07, 2018

Copy link to clipboard

Copied

Sorry i misread, i have only one page ... but 8 templates which gonna spawn. I understood what you've wrote 😃 thx !!!

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 ,
May 07, 2018 May 07, 2018

Copy link to clipboard

Copied

In that case replace "9" with "1" in the code above...

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 ,
May 07, 2018 May 07, 2018

Copy link to clipboard

Copied

(assuming those templates are hidden, of course)

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
New Here ,
May 07, 2018 May 07, 2018

Copy link to clipboard

Copied

LATEST

yes it is 😃

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