These forums are now Read Only. If you have an Acrobat question, ask questions and get help from one of our experts.

Dialog question

sclark1
Registered: Feb 23 2009
Posts: 20
Answered

Why does this example not working? I've added this to the document level javascripts as a function then call it from a mouse up event on a button using the following code, and all I get is a blank menu pop up with "Untitled" as the title? Maybe Thom can pitch in since he's the Dialog guru.
 
Here's the button code:
app.execDialog(dialog);
  
Here's the dialog code:
 
function dialog()
{
var dialog1 = {

initialize: function (dialog) {
// Create a static text containing the current date.
var todayDate = dialog.store()["date"];
todayDate = "Date: " + util.printd("mmmm dd, yyyy", new Date());
dialog.load({ "date": todayDate });
},
commit:function (dialog) { // called when OK pressed
var results = dialog.store();
// Now do something with the data collected, for example,
console.println("Your name is " + results["fnam"]
+ " " + results["lnam"] );
},
description:
{
name: "Personal Data", // Dialog box title
align_children: "align_left",
width: 350,
height: 200,
elements:
[
{
type: "cluster",
name: "Your Name",
align_children: "align_left",
elements:
[
{
type: "view",
align_children: "align_row",
elements:
[
{
type: "static_text",
name: "First Name: "
},
{
item_id: "fnam",
type: "edit_text",
alignment: "align_fill",
width: 300,
height: 20
}
]
},
{
type: "view",
align_children: "align_row",
elements:
[
{
type: "static_text",
name: "Last Name: "
},
{
item_id: "lnam",
type: "edit_text",
alignment: "align_fill",
width: 300,
height: 20
}
]
},
{
type: "static_text",
name: "Date: ",
char_width: 25,
item_id: "date"
},
]
},
{
alignment: "align_right",
type: "ok_cancel",
ok_name: "Ok",
cancel_name: "Cancel"
}
]
}
};
}

My Product Information:
Acrobat Pro 8.0, Windows
gkaiseril
Expert
Registered: Feb 23 2006
Posts: 4307
Accepted Answer
You need to provide the name of the dialog to execute. You do not need to wrap the dialog in a function.

If you want to use a function:

function dialog() {
// call the dialog1 dialog
app.execDialog(dialog1);
}

// define dialog object
var dialog1 = {
...
};

Then for your button script:

// call the dialog function
dialog();

George Kaiser

sclark1
Registered: Feb 23 2009
Posts: 20
Thanks George, I thought I had tried that but now it works.
sclark1
Registered: Feb 23 2009
Posts: 20
Adding to this post:

Is there an element to add an image to a dialog?
Dimitri
Expert
Registered: Nov 1 2005
Posts: 1389
Hi sclark1,

Yes there is- it is called the Image object. Details can be found in the Acrobat JavaScript Reference.

This page has some examples- the top 2 show images in custom dialogs-
http://www.windjack.com/resources/Examples/DialogUses.pdf

The tricky part to adding the images is getting them in the right format, hexadecimal string.

Hope this helps,

Dimitri
sclark1
Registered: Feb 23 2009
Posts: 20
Thanks Dimitri!

I've looked everywhere in the Javascript reference manuals for 5,6,7,and 8 and don't see anything about the "Image" object for dialogs? Any chance you have a page number for that? :)

Just looking at that code for the image in you guys examples, I can see I'll probably need a converter to go from image to hex.

This is more or less experiential learning for me. :)

Dimitri
Expert
Registered: Nov 1 2005
Posts: 1389
Hi sclark1,

Sorry, I am incorrect that the image object is in the Acrobat JavaScript reference. But as you can see from the samples I referred to, it does indeed exist- it's just not undocumented.

Hope this helps,

Dimitri
sclark1
Registered: Feb 23 2009
Posts: 20
Awesome thanks again!