Skip to main content
Nicky G.
Known Participant
April 23, 2023
Question

create user interface SELECT FILE AND PAGE

  • April 23, 2023
  • 1 reply
  • 619 views

Hi, I need a dialog like this when I open my script.

Field Select file (ai, pdf)
text field page from, page to

these fields must be connected (the data taken), to the following code.

 

var doc = app.activeDocument;
app.userInteractionLevel = UserInteractionLevel.DONTDISPLAYALERTS;
var pdfOptions = app.preferences.PDFFileOptions;

 

var firstPage = <FROM>;
var lastPage = <TO>;

 

File = <URL OF FILE>
for (i=firstPage; i<lastPage; i++) {
   pdfOptions.pageToOpen = i;
   var thisPlacedItem = doc.placedItems.add();
    thisPlacedItem.file = File;
};


 

This topic has been closed for replies.

1 reply

femkeblanco
Legend
April 23, 2023
var file1, firstPage, lastPage;

var w = new Window("dialog");
var g1 = w.add("group");
    g1.orientation = "row";
var b1 = g1.add("button", undefined, "File");
    b1.preferredSize.width = 75;
var et1 = g1.add("edittext", undefined, "");
    et1.preferredSize.width = 300;
    file1 = et1.text;
    b1.onClick = function () {
        file1 = File.openDialog("prompt");
        et1.text = file1.fullName;
    }
var g2 = w.add("group");
    g2.orientation = "row";
var st1 = g2.add("statictext", undefined, "");
    st1.preferredSize.width = 75;
var g3 = g2.add("group");
    g3.preferredSize.width = 200;
    g3.orientation = "column";
    g3.alignChildren = ["left", "center"];
var st2 = g3.add("statictext", undefined, "Page interval");
var g4 = g3.add("group");
    g4.orientation = "row";
var st3 = g4.add("statictext", undefined, "From:");
    st3.preferredSize.width = 30;
var et3 = g4.add("edittext", undefined, "1");
    et3.preferredSize.width = 50;
    firstPage = Number(et3.text);
    et3.onChange = function () {
        firstPage = Number(et3.text);
    }
var st4 = g4.add("statictext", undefined, "to:");
    st4.preferredSize.width = 15;
var et4 = g4.add("edittext", undefined, "1");
    et4.preferredSize.width = 50;
    lastPage = Number(et4.text);
    et4.onChange = function () {
        lastPage = Number(et4.text);
    }
var g6 = g2.add("group");
    g6.orientation = "column";
var b2 = g6.add("button", undefined,"OK");
    b2.preferredSize.width = 75;
var b3 = g6.add("button", undefined, "Cancel");
    b3.preferredSize.width = 75;
w.show();

var doc = app.activeDocument;
app.userInteractionLevel = UserInteractionLevel.DONTDISPLAYALERTS;
var pdfOptions = app.preferences.PDFFileOptions;

alert("File: " + file1 + "\nFrom: " + firstPage + "\nTo: " + lastPage);

// for (var i = firstPage; i < lastPage; i++) {
//     pdfOptions.pageToOpen = i;
//     var thisPlacedItem = doc.placedItems.add();
//     thisPlacedItem.file = file1;
// }
Nicky G.
Nicky G.Author
Known Participant
May 2, 2023

@femkeblanco Is it possible to make these artboards place in different boards? Is it possible to apply a flattening of transparency with established presets?etc