Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save joonaspaakko/3752836f282819949d5d0ab7268007dd to your computer and use it in GitHub Desktop.
Save joonaspaakko/3752836f282819949d5d0ab7268007dd to your computer and use it in GitHub Desktop.
Example code generated with ScriptUI Dialog Builder: https://github.com/joonaspaakko/ScriptUI-Dialog-Builder-Joonas
/*
Code for Import https://scriptui.joonas.me — (Triple click to select):
{"activeId":1,"items":{"item-0":{"id":0,"type":"Dialog","parentId":false,"style":{"text":"Import Multiple PDF pages","preferredSize":[0,0],"margins":16,"orientation":"row","spacing":10,"alignChildren":["left","top"]}},"item-1":{"id":1,"type":"Panel","parentId":20,"style":{"text":"Page Selection","preferredSize":[0,205],"margins":10,"orientation":"column","spacing":10,"alignChildren":["left","top"],"alignment":null}},"item-2":{"id":2,"type":"StaticText","parentId":1,"style":{"text":"Import PDF Pages:","justify":"left","preferredSize":[0,0],"alignment":null}},"item-3":{"id":3,"type":"EditText","parentId":6,"style":{"text":"1","preferredSize":[60,0],"alignment":null}},"item-4":{"id":4,"type":"StaticText","parentId":6,"style":{"text":"thru","justify":"left","preferredSize":[0,0],"alignment":null}},"item-5":{"id":5,"type":"EditText","parentId":6,"style":{"text":"1","preferredSize":[60,0],"alignment":null}},"item-6":{"id":6,"type":"Group","parentId":1,"style":{"preferredSize":[0,0],"margins":0,"orientation":"row","spacing":10,"alignChildren":["left","center"],"alignment":null}},"item-7":{"id":7,"type":"StaticText","parentId":1,"style":{"text":"Start Placing on Doc Page:","justify":"left","preferredSize":[0,0],"alignment":null}},"item-8":{"id":8,"type":"Checkbox","parentId":1,"style":{"text":"Reverse Page Order","preferredSize":[0,0],"alignment":null}},"item-9":{"id":9,"type":"Panel","parentId":20,"style":{"text":"Sizing Options","preferredSize":[0,160],"margins":10,"orientation":"column","spacing":10,"alignChildren":["left","top"],"alignment":null}},"item-10":{"id":10,"type":"Checkbox","parentId":9,"style":{"text":"Fit to Page","preferredSize":[0,0],"alignment":null}},"item-11":{"id":11,"type":"Checkbox","parentId":9,"style":{"text":"Keep Proportions","preferredSize":[0,0],"alignment":null}},"item-12":{"id":12,"type":"Checkbox","parentId":9,"style":{"text":"Bleed the Fit Page","preferredSize":[0,0],"alignment":null,"checked":true}},"item-13":{"id":13,"type":"StaticText","parentId":9,"style":{"text":"Scale of Imported Page","justify":"left","preferredSize":[0,0],"alignment":null}},"item-14":{"id":14,"type":"Group","parentId":9,"style":{"preferredSize":[0,0],"margins":0,"orientation":"row","spacing":10,"alignChildren":["left","center"],"alignment":null}},"item-15":{"id":15,"type":"EditText","parentId":14,"style":{"text":"100","preferredSize":[40,0],"alignment":null}},"item-16":{"id":16,"type":"StaticText","parentId":14,"style":{"text":"Y%","justify":"left","preferredSize":[0,0],"alignment":null}},"item-17":{"id":17,"type":"EditText","parentId":14,"style":{"text":"100","preferredSize":[40,0],"alignment":null}},"item-18":{"id":18,"type":"StaticText","parentId":14,"style":{"text":"X%:","justify":"left","preferredSize":[0,0],"alignment":null}},"item-19":{"id":19,"type":"Group","parentId":0,"style":{"preferredSize":[0,0],"margins":0,"orientation":"column","spacing":10,"alignChildren":["fill","top"],"alignment":null}},"item-20":{"id":20,"type":"Group","parentId":0,"style":{"preferredSize":[0,0],"margins":0,"orientation":"column","spacing":10,"alignChildren":["fill","top"],"alignment":null}},"item-21":{"id":21,"type":"Panel","parentId":19,"style":{"text":"Positioning Options","preferredSize":[0,205],"margins":10,"orientation":"column","spacing":10,"alignChildren":["fill","top"],"alignment":null}},"item-22":{"id":22,"type":"StaticText","parentId":21,"style":{"text":"Position on Page Aligned From:","justify":"left","preferredSize":[0,0],"alignment":null}},"item-23":{"id":23,"type":"DropDownList","parentId":21,"style":{"text":"","listItems":"Top Left, Top Center, Top Right, Center Left, Center, Center Right, Bottom Left, Bottom Center, Bottom Right, -, Top - Relative to spine, Center - Relative to spine, Right - Relative to spine","preferredSize":[0,0],"alignment":null,"selection":0}},"item-24":{"id":24,"type":"DropDownList","parentId":21,"style":{"text":"Rotation:","listItems":"0, 90, 180, 270","preferredSize":[0,0],"alignment":null,"selection":0}},"item-25":{"id":25,"type":"StaticText","parentId":21,"style":{"text":"Offset by:","justify":"left","preferredSize":[0,0],"alignment":null}},"item-26":{"id":26,"type":"Group","parentId":21,"style":{"preferredSize":[0,0],"margins":0,"orientation":"row","spacing":10,"alignChildren":["left","center"],"alignment":null}},"item-27":{"id":27,"type":"StaticText","parentId":26,"style":{"text":"X:","justify":"left","preferredSize":[0,0],"alignment":null}},"item-28":{"id":28,"type":"EditText","parentId":26,"style":{"text":"0","preferredSize":[40,0],"alignment":null}},"item-29":{"id":29,"type":"StaticText","parentId":26,"style":{"text":"X:","justify":"left","preferredSize":[0,0],"alignment":null}},"item-30":{"id":30,"type":"EditText","parentId":26,"style":{"text":"0","preferredSize":[40,0],"alignment":null}},"item-31":{"id":31,"type":"Panel","parentId":19,"style":{"text":"Placement Options","preferredSize":[0,160],"margins":10,"orientation":"column","spacing":10,"alignChildren":["fill","top"],"alignment":null}},"item-32":{"id":32,"type":"DropDownList","parentId":31,"style":{"text":"Crop to:","listItems":"Art, Crop, Trim, Bleed, Media","preferredSize":[0,0],"alignment":null,"selection":0}},"item-33":{"id":33,"type":"Checkbox","parentId":31,"style":{"text":"Place Pages on a New Layer","preferredSize":[0,0],"alignment":null}},"item-34":{"id":34,"type":"Checkbox","parentId":31,"style":{"text":"Ignore Font and Image Errors","preferredSize":[0,0],"alignment":null}},"item-35":{"id":35,"type":"Checkbox","parentId":31,"style":{"text":"Transparent PDF Background","preferredSize":[0,0],"alignment":null,"checked":true}},"item-36":{"id":36,"type":"Group","parentId":0,"style":{"preferredSize":[0,0],"margins":0,"orientation":"column","spacing":10,"alignChildren":["fill","top"],"alignment":null}},"item-37":{"id":37,"type":"Button","parentId":36,"style":{"text":"OK","justify":"center","preferredSize":[0,0],"alignment":null}},"item-38":{"id":38,"type":"Button","parentId":36,"style":{"text":"Cancel","justify":"center","preferredSize":[0,0],"alignment":null}},"item-39":{"id":39,"type":"EditText","parentId":1,"style":{"text":"1","preferredSize":[60,0],"alignment":null}},"item-40":{"id":40,"type":"Checkbox","parentId":1,"style":{"text":"Map to Doc Pages","preferredSize":[0,0],"alignment":null}}},"order":[0,20,1,2,6,3,4,5,8,7,39,40,9,10,11,12,13,14,18,15,16,17,19,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38]}
*/
// DIALOG
// ======
var dialog = new Window("dialog");
dialog.text = "Import Multiple PDF pages";
dialog.orientation = "row";
dialog.alignChildren = ["left","top"];
dialog.spacing = 10;
dialog.margins = 16;
// GROUP1
// ======
var group1 = dialog.add("group");
group1.orientation = "column";
group1.alignChildren = ["fill","top"];
group1.spacing = 10;
group1.margins = 0;
// PANEL1
// ======
var panel1 = group1.add("panel");
panel1.text = "Page Selection";
panel1.preferredSize.height = 205;
panel1.orientation = "column";
panel1.alignChildren = ["left","top"];
panel1.spacing = 10;
panel1.margins = 10;
var statictext1 = panel1.add("statictext");
statictext1.text = "Import PDF Pages:";
// GROUP2
// ======
var group2 = panel1.add("group");
group2.orientation = "row";
group2.alignChildren = ["left","center"];
group2.spacing = 10;
group2.margins = 0;
var edittext1 = group2.add("edittext");
edittext1.text = "1";
edittext1.minimumSize.width = 60;
var statictext2 = group2.add("statictext");
statictext2.text = "thru";
var edittext2 = group2.add("edittext");
edittext2.text = "1";
edittext2.minimumSize.width = 60;
// PANEL1
// ======
var checkbox1 = panel1.add("checkbox");
checkbox1.text = "Reverse Page Order";
var statictext3 = panel1.add("statictext");
statictext3.text = "Start Placing on Doc Page:";
var edittext3 = panel1.add("edittext");
edittext3.text = "1";
edittext3.minimumSize.width = 60;
var checkbox2 = panel1.add("checkbox");
checkbox2.text = "Map to Doc Pages";
// PANEL2
// ======
var panel2 = group1.add("panel");
panel2.text = "Sizing Options";
panel2.preferredSize.height = 160;
panel2.orientation = "column";
panel2.alignChildren = ["left","top"];
panel2.spacing = 10;
panel2.margins = 10;
var checkbox3 = panel2.add("checkbox");
checkbox3.text = "Fit to Page";
var checkbox4 = panel2.add("checkbox");
checkbox4.text = "Keep Proportions";
var checkbox5 = panel2.add("checkbox");
checkbox5.text = "Bleed the Fit Page";
checkbox5.value = true;
var statictext4 = panel2.add("statictext");
statictext4.text = "Scale of Imported Page";
// GROUP3
// ======
var group3 = panel2.add("group");
group3.orientation = "row";
group3.alignChildren = ["left","center"];
group3.spacing = 10;
group3.margins = 0;
var statictext5 = group3.add("statictext");
statictext5.text = "X%:";
var edittext4 = group3.add("edittext");
edittext4.text = "100";
edittext4.minimumSize.width = 40;
var statictext6 = group3.add("statictext");
statictext6.text = "Y%";
var edittext5 = group3.add("edittext");
edittext5.text = "100";
edittext5.minimumSize.width = 40;
// GROUP4
// ======
var group4 = dialog.add("group");
group4.orientation = "column";
group4.alignChildren = ["fill","top"];
group4.spacing = 10;
group4.margins = 0;
// PANEL3
// ======
var panel3 = group4.add("panel");
panel3.text = "Positioning Options";
panel3.preferredSize.height = 205;
panel3.orientation = "column";
panel3.alignChildren = ["fill","top"];
panel3.spacing = 10;
panel3.margins = 10;
var statictext7 = panel3.add("statictext");
statictext7.text = "Position on Page Aligned From:";
var dropdown1_array = ["Top Left","Top Center","Top Right","Center Left","Center","Center Right","Bottom Left","Bottom Center","Bottom Right","-","Top - Relative to spine","Center - Relative to spine","Right - Relative to spine"];
var dropdown1 = panel3.add("dropdownlist", undefined, dropdown1_array);
dropdown1.selection = 0;
var dropdown2_array = ["0","90","180","270"];
var dropdown2 = panel3.add("dropdownlist", undefined, dropdown2_array);
dropdown2.selection = 0;
dropdown2.text = "Rotation:";
var statictext8 = panel3.add("statictext");
statictext8.text = "Offset by:";
// GROUP5
// ======
var group5 = panel3.add("group");
group5.orientation = "row";
group5.alignChildren = ["left","center"];
group5.spacing = 10;
group5.margins = 0;
var statictext9 = group5.add("statictext");
statictext9.text = "X:";
var edittext6 = group5.add("edittext");
edittext6.text = "0";
edittext6.minimumSize.width = 40;
var statictext10 = group5.add("statictext");
statictext10.text = "X:";
var edittext7 = group5.add("edittext");
edittext7.text = "0";
edittext7.minimumSize.width = 40;
// PANEL4
// ======
var panel4 = group4.add("panel");
panel4.text = "Placement Options";
panel4.preferredSize.height = 160;
panel4.orientation = "column";
panel4.alignChildren = ["fill","top"];
panel4.spacing = 10;
panel4.margins = 10;
var dropdown3_array = ["Art","Crop","Trim","Bleed","Media"];
var dropdown3 = panel4.add("dropdownlist", undefined, dropdown3_array);
dropdown3.selection = 0;
dropdown3.text = "Crop to:";
var checkbox6 = panel4.add("checkbox");
checkbox6.text = "Place Pages on a New Layer";
var checkbox7 = panel4.add("checkbox");
checkbox7.text = "Ignore Font and Image Errors";
var checkbox8 = panel4.add("checkbox");
checkbox8.text = "Transparent PDF Background";
checkbox8.value = true;
// GROUP6
// ======
var group6 = dialog.add("group");
group6.orientation = "column";
group6.alignChildren = ["fill","top"];
group6.spacing = 10;
group6.margins = 0;
var button1 = group6.add("button");
button1.text = "OK";
button1.justify = "center";
var button2 = group6.add("button");
button2.text = "Cancel";
button2.justify = "center";
dialog.show();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment