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

Action button on custom dialog

Guest
Mar 30, 2016 Mar 30, 2016

I am very new to this but trying to learn. The task I've been given is this:

  • Have a button on a page that when pressed will open a custom dialog with 4 buttons.
  • Each button should open a different external pdf file in a new window.

I feel like it's getting close but just can't get there. Any and all help will be greatly appreciated!

var Dlg =

{

description:

{

name: "Select File To Open",

elements:

[

{

type: "view",

elements:

[

{

item_id: "Header1",

name: "Select Document To Open",

type: "static_text",

},

{

item_id: "Button1",

name: "IOM",

type: "button",

Button1:function(dialog)

         {

             app.openDoc("/IOM/IOM.pdf", this);

},

},

{

item_id: "Button2",

name: "Submittal",

type: "button",

},

{

item_id: "Button3",

name: "Owner's Manual",

type: "button",

},

{

item_id: "Button4",

name: "Test & Balance",

type: "button",

}

]

},

{

type: "ok",

ok_name: "Close"

},

]

}

};

app.execDialog(Dlg);

TOPICS
Acrobat SDK and JavaScript , Windows
1.8K
Translate
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 1 Correct answer

Community Expert , Mar 30, 2016 Mar 30, 2016

You can use check-boxes in your dialog where the user can select which file(s) to open, and after they close the dialog you can open the selected files.

Translate
Community Expert ,
Mar 30, 2016 Mar 30, 2016

You can't do it. Dialog objects are modal. You can't tell the app to open

new documents while they are still open.

On Wed, Mar 30, 2016 at 8:37 PM, jmarshallinc <forums_noreply@adobe.com>

Translate
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
Guest
Mar 30, 2016 Mar 30, 2016

Is there anything else that would work? We just don't want 4 separate buttons on the page because this will have to be done several times on each page. Thanks

Translate
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 ,
Mar 30, 2016 Mar 30, 2016

You can use check-boxes in your dialog where the user can select which file(s) to open, and after they close the dialog you can open the selected files.

Translate
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
Guest
Mar 30, 2016 Mar 30, 2016

Thank you very much try67!

Translate
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
Guest
Mar 30, 2016 Mar 30, 2016

What about radio buttons? This is what I've done but it's not working, probably have something in the wrong place.

var docType

var Dlg ={

description:

{

name: "Select File To Open",

elements:

[

{

type: "view",

elements:

[

{

item_id: "Header1",

name: "Select Document To Open",

type: "static_text",

},

{

item_id: "Button1",

name: "IOM",

type: "radio",

group_id: "rd",

},

{

item_id: "Button2",

name: "Submittal",

type: "radio",

group_id: "rd",

},

{

item_id: "Button3",

name: "Owner's Manual",

type: "radio",

group_id: "rd",

},

{

item_id: "Button4",

name: "Test & Balance",

type: "radio",

group_id: "rd",

}

]

},

{

type: "ok_cancel",

ok_name: "Open"

},

]

}

};

commit:function (dialog) {

    var results = dialog.store();

    if (results["Button1"]) docType = 1;

    else if (results["Button2"]) docType = 2;

    else if (results["Button3"]) docType = 3;

    else if (results["Button4"]) docType = 4;

  }

app.execDialog(Dlg);

if(docType==1){

  app.openDoc("/IOM/IOM.pdf", this);

}

else if(docType==2){

  app.openDoc("/Submittal/Submittal.pdf", this);

}

else if(docType==3){

  app.openDoc("/Owners Manual/Owners Manual.pdf", this);

}

else if(docType==4){

  app.openDoc("/T&B/T&B.pdf", this);

}

Translate
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 ,
Mar 30, 2016 Mar 30, 2016

The item_id must be a unique 4-character string.

On Wed, Mar 30, 2016 at 9:42 PM, jmarshallinc <forums_noreply@adobe.com>

Translate
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
Guest
Mar 30, 2016 Mar 30, 2016

Changed all ID's to 4 characters but still nothing. Not getting any errors either.

var docType

var Dlg ={

description:

{

name: "Select File To Open",

elements:

[

{

type: "view",

elements:

[

{

item_id: "Hdr1",

name: "Select Document To Open",

type: "static_text",

},

{

item_id: "Btn1",

name: "IOM",

type: "radio",

group_id: "rdgp",

},

{

item_id: "Btn2",

name: "Submittal",

type: "radio",

group_id: "rdgp",

},

{

item_id: "Btn3",

name: "Owner's Manual",

type: "radio",

group_id: "rdgp",

},

{

item_id: "Btn4",

name: "Test & Balance",

type: "radio",

group_id: "rdgp",

}

]

},

{

type: "ok_cancel",

ok_name: "Open"

},

]

}

};

commit:function (dialog) { // called when OK pressed

    var results = dialog.store();

    if (results["Btn1"]) docType = 1;

    else if (results["Btn2"]) docType = 2;

    else if (results["Btn3"]) docType = 3;

    else if (results["Btn4"]) docType = 4;

  }

app.execDialog(Dlg);

if(docType==1){

  app.openDoc("/IOM/IOM.pdf", this);

}

else if(docType==2){

  app.openDoc("/Submittal/Submittal.pdf", this);

}

else if(docType==3){

  app.openDoc("/Owners Manual/Owners Manual.pdf", this);

}

else if(docType==4){

  app.openDoc("/T&B/T&B.pdf", this);

}

Translate
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 ,
Mar 30, 2016 Mar 30, 2016

For some reason you placed the commit function outside of the dialog

object... Move it inside and it will work.

On Wed, Mar 30, 2016 at 9:58 PM, jmarshallinc <forums_noreply@adobe.com>

Translate
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
Guest
Mar 30, 2016 Mar 30, 2016

You were right! I'm very new to javascript. It fires now but I get this error.

NotAllowedError: Security settings prevent access to this property or method.

App.openDoc:62:Field Button7:Mouse Up

Translate
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 ,
Mar 30, 2016 Mar 30, 2016

That means the file-paths you're specifying are not correct.

Translate
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
Guest
Mar 30, 2016 Mar 30, 2016

It actually appears to be a security issue. May not be able to get past it. I appreciate all your help.

Translate
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
Guest
Mar 30, 2016 Mar 30, 2016

Never mind, it was the path. I had a leading forward slash that wasn't needed. Works great now! Thanks again try67

Translate
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
Participant ,
Mar 31, 2019 Mar 31, 2019
LATEST

Hey there, I saw your post and I too was trying my best to get it to work. I'm also a novice when it comes to javascript but I enjoy learning how to apply it. Would you mind sharing your results. I, for the life of me, cannot get it to work and I would like to see it working? Kindly, let me know. Thanks.

Translate
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