delete pages after the choice change with a dropdown list

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

234

Likes

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

delete pages after the choice change with a dropdown list

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

235

Likes

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
May 03, 2018 0
Most Valuable Participant ,
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.

Likes

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
Reply
Loading...
May 03, 2018 0
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();

}

Likes

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
Reply
Loading...
May 03, 2018 0
Most Valuable Participant ,
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?

Likes

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
Reply
Loading...
May 03, 2018 0
May 07, 2018

Copy link to clipboard

Copied

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

Likes

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
Reply
Loading...
May 07, 2018 0
Adobe Community Professional ,
May 07, 2018

Copy link to clipboard

Copied

HI,

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

Regards

Malcolm

Likes

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
Reply
Loading...
May 07, 2018 0
Most Valuable Participant ,
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);

Likes

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
Reply
Loading...
May 07, 2018 0
May 07, 2018

Copy link to clipboard

Copied

Yes, only one page 😃

Likes

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
Reply
Loading...
May 07, 2018 0
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 !!!

Likes

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
Reply
Loading...
May 07, 2018 0
Most Valuable Participant ,
May 07, 2018

Copy link to clipboard

Copied

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

Likes

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
Reply
Loading...
May 07, 2018 0
Most Valuable Participant ,
May 07, 2018

Copy link to clipboard

Copied

(assuming those templates are hidden, of course)

Likes

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
Reply
Loading...
May 07, 2018 0
May 07, 2018

Copy link to clipboard

Copied

yes it is 😃

Likes

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
Reply
Loading...
May 07, 2018 0