cSavepath not saving based on if then statements

Explorer ,
Jul 03, 2017

Copy link to clipboard

Copied

HI,

I am trying to make it so if the total number of pages (numPages) is 1, then the code inserts the "1" +  "page" and if there is a total of 3 pages , it would insert save as "3" + "pages".  I don't understand why the following is not saving the pdf with the cSavePath (i.e., filename) based on whether the total # of pages is 1 or not 1:

        cSavePath += " - "

        cSavePath += event.target.numPages

        If (event.target.numPages == "1")

       {cSavePath += " page"}

        

        If (event.target.numPages != "1")

        {cSavePath += " pages"}

    

I even tried as numerical value:

cSavePath += " - "

        cSavePath += event.target.numPages

        If (event.target.numPages = 1)

       {cSavePath += " page"}

        

        If (event.target.numPages > 1)

        {cSavePath += " pages"}

Most Valuable Participant
Correct answer by try67 | Most Valuable Participant

Also, it's "if", not "If"...

TOPICS
Acrobat SDK and JavaScript, Windows

Views

122

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

cSavepath not saving based on if then statements

Explorer ,
Jul 03, 2017

Copy link to clipboard

Copied

HI,

I am trying to make it so if the total number of pages (numPages) is 1, then the code inserts the "1" +  "page" and if there is a total of 3 pages , it would insert save as "3" + "pages".  I don't understand why the following is not saving the pdf with the cSavePath (i.e., filename) based on whether the total # of pages is 1 or not 1:

        cSavePath += " - "

        cSavePath += event.target.numPages

        If (event.target.numPages == "1")

       {cSavePath += " page"}

        

        If (event.target.numPages != "1")

        {cSavePath += " pages"}

    

I even tried as numerical value:

cSavePath += " - "

        cSavePath += event.target.numPages

        If (event.target.numPages = 1)

       {cSavePath += " page"}

        

        If (event.target.numPages > 1)

        {cSavePath += " pages"}

Most Valuable Participant
Correct answer by try67 | Most Valuable Participant

Also, it's "if", not "If"...

TOPICS
Acrobat SDK and JavaScript, Windows

Views

123

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
Jul 03, 2017 0
Adobe Community Professional ,
Jul 03, 2017

Copy link to clipboard

Copied

Use == not = for the comparsion.

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...
Jul 03, 2017 0
Most Valuable Participant ,
Jul 04, 2017

Copy link to clipboard

Copied

Also, it's "if", not "If"...

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...
Jul 04, 2017 0
Explorer ,
Jul 04, 2017

Copy link to clipboard

Copied

Ughh, yes.  It was the "If" vs. the "if".  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...
Jul 04, 2017 0