Take the pop-up selection from the dialog box and process it in a text field
Hello,
using a dialog box in which I can make a selection, I would like to filter out the selection made in order to be able to perform further operations with it.
In the Adobe AcrobatDC JavaScript API reference, example #3 is shown, which I used to select a font from several fonts.
Example 3: This example uses a list box or a popup box.
But I am not able to format the text of a form field with the selected font.
How do I get the font assigned in the 'f.textFont =' option so that the text appears in the selected font?
function PlaceText() {
var dialog3 = {
// This dialog box is called when the dialog box is created
initialize: function (dialog) {
this.loadDefaults(dialog);
},
// This dialog box is called when the OK button is clicked.
commit: function (dialog) {
// See the Dialog object for a description of how dialog.load
// and dialog.store work.
var elements = dialog.store()["subl"];
// do something with the data.
for (var s in elements) {
if (elements[s] > 0) {
console.println("Gewählter Schriftfont ist: " + s + ", which has a value of " + elements[s]);
}
}
},
// Callback for when the button "butn" is clicked.
butn: function (dialog) {
var elements = dialog.store()["subl"]
for (var s in elements) {
if (elements[s] > 0) {
app.alert("You have selected: " + s
+ ", which has a value of " + elements[s]);
}
}
},
loadDefaults: function (dialog) {
dialog.load({
subl: {
"CourierStd": +1,
"Helvetica": -2,
"Times-Roman": -3,
}
})
},
// The dialog box description
description: {
name: "Font selection", // Title of the dialog box
elements: // Child element array
[{
type: "view",
align_children: "align_left",
elements: // Child element array
[{
type: "cluster",
name: "Select",
elements: // Child Element Array
[{
type: "static_text",
name: "Select a font",
font: "default"
}, {
type: "popup", // Aufklappmenü
item_id: "subl",
width: 200,
}, {
type: "button",
item_id: "butn",
name: "Press Me"
}
]
}, {
type: "ok_cancel"
}
]
}
]
}
}
// if (dialog3.DoDialog() == "ok") {
// var WunschFont = s
var re = /.*\/|\.pdf$/ig;
var FileNM = this.path.replace(re, "") + ".pdf";
var Path = this.path;
var f = this.addField("header1", "text", 0, [100, 250, 150, 200]);
f.textColor = color.black;
f.textSize = 12;
// f.textFont = "Helvetica";
f.textFont = s; // ????????????????
f.strokeColor = color.transparent;
f.fillColor = color.transparent;
f.value = FileNM;
f.alignment = "left";
app.execDialog(dialog3);
}
PlaceText()