Forum Replies Created
-
AuthorPosts
-
Brian Pifer
ParticipantHi V S,
Sorry for the delay here, but give this a shot, and let me know what you think: https://www.designtimesolutions.com/#scripts
It gives you the choice to snap to nearest left or right column guide, margin edge, or page edge. It looks for guides that the selections don’t overlap with.
Brian Pifer
ParticipantJust saw your followup, and can’t edit my original message for some reason. But feel free to contact me through my site if you have further needs. Glad you were able to figure out how to adapt it for the undergrads. Stay safe!
Brian Pifer
ParticipantHi Billy,
Shoot me a message through the form at the bottom of my homepage at http://www.designtimesolutions.com and we can take this offline. Thanks!
Brian Pifer
ParticipantBrilliant. If you are so inclined and able, please feel free to donate to a charity of your choice focused on Covid-19 relief.
Brian Pifer
ParticipantYeah, Desktop could have been the issue. Here’s a revamp to let you select the folder to save to, and to also find by the “Portrait” object style. If this doesn’t work, let me know what the syntax error msg says.
app.jpegExportPreferences.jpegExportRange = ExportRangeOrAllPages.EXPORT_RANGE;
app.jpegExportPreferences.jpegQuality = JPEGOptionsQuality.HIGH;
var pages = app.activeDocument.pages;
var fol = Folder.selectDialog(“Choose a folder”);
for (var i = 0; i < pages.length; i++) {
var graphics = pages[i].pageItems;
for (var j = 0; j < graphics.length; j++) {
if (graphics[j].appliedObjectStyle.name == “Portrait”) {
if (graphics[j].graphics[0].itemLink.isValid) {
var fileToExport = File(fol.fsName + “/” + graphics[j].graphics[0].itemLink.name);
app.jpegExportPreferences.pageString = (pages[i].documentOffset + 1).toString();
app.activeDocument.exportFile(ExportFormat.jpg, fileToExport, false);
break;
}
}
}
}Brian Pifer
ParticipantFor the kids. This will write all the pages to your desktop. It assumes all the images that you are placing and exporting are jpegs, and that there is one linked item per page. It will export a high quality jpeg as the same name as the linked image name. Note that if the linked images are also on the desktop, it will overwrite them. Copy the text below into a plain text editor, and save it with the .jsx extension, then copy that file to your scripts folder. Run it on your open document.
app.jpegExportPreferences.jpegExportRange = ExportRangeOrAllPages.EXPORT_RANGE;
app.jpegExportPreferences.jpegQuality = JPEGOptionsQuality.HIGH;
var pages = app.activeDocument.pages;
for (var i = 0; i < pages.length; i++) {
var graphics = pages[i].allGraphics;
for (var j = 0; j < graphics.length; j++) {
if (graphics[j].itemLink.isValid) {
var fileToExport = File(“~/Desktop/” + graphics[j].itemLink.name);
app.jpegExportPreferences.pageString = (pages[i].documentOffset + 1).toString();
app.activeDocument.exportFile(ExportFormat.jpg, fileToExport, false);
break;
}
}
}Brian Pifer
ParticipantCorrect, just something to started on the UI. From there, it would be a matter of resizing the rectangles and their containing images.
app.selection returns an array of all the selected objects on a page. If you select a frame with your black arrow tool, that’s a rectangle object. With one object selected:
var rect = app.selection[0];
var containingImage = rect.graphics[0];You can look at the rect.geometricBounds property, as well as rect.resize() and rect.fit() methods. Lots of different ways to skin the cat based on your ultimate needs and how your doc is set up.
For some guidance on the Rectangle object, https://www.indesignjs.de/extendscriptAPI/indesign-latest/#Rectangle.html
Brian Pifer
ParticipantHere’s the dialog built with the handy scriptUI builder: https://scriptui.joonas.me/
Should help you get started.
// DIALOG
// ======
var dialog = new Window(“dialog”);
dialog.text = “TableStyler”;
dialog.orientation = “column”;
dialog.alignChildren = [“left”,”top”];
dialog.spacing = 10;
dialog.margins = 16;// GROUP1
// ======
var group1 = dialog.add(“group”, undefined, {name: “group1”});
group1.orientation = “column”;
group1.alignChildren = [“left”,”center”];
group1.spacing = 10;
group1.margins = 0;var radiobutton1 = group1.add(“radiobutton”, undefined, undefined, {name: “radiobutton1”});
radiobutton1.text = “Height”;var radiobutton2 = group1.add(“radiobutton”, undefined, undefined, {name: “radiobutton2”});
radiobutton2.text = “Width”;// GROUP2
// ======
var group2 = dialog.add(“group”, undefined, {name: “group2”});
group2.orientation = “row”;
group2.alignChildren = [“left”,”center”];
group2.spacing = 10;
group2.margins = 0;var edittext1 = group2.add(‘edittext {properties: {name: “edittext1”}}’);
edittext1.text = “Enter the width or height to set”;// GROUP3
// ======
var group3 = dialog.add(“group”, undefined, {name: “group3”});
group3.orientation = “row”;
group3.alignChildren = [“left”,”center”];
group3.spacing = 10;
group3.margins = 0;var button1 = group3.add(“button”, undefined, undefined, {name: “button1”});
button1.text = “OK”;var button2 = group3.add(“button”, undefined, undefined, {name: “button2”});
button2.text = “Cancel”;dialog.show();
Brian Pifer
Participantpage.appliedMaster = NothingEnum.NOTHING;
Brian Pifer
ParticipantUse the Folder object:
var fol = Folder(“some/path”);
var inddFiles = fol.getFiles(“*.indd”);
for (var i = 0; i < inddFiles.length; i++) {
var doc = app.open(inddFiles[i]);
//do stuff
}Brian Pifer
ParticipantMy pleasure. Yes, if that’s the only place that function was called, then it’s fine to remove entirely.
February 20, 2020 at 2:00 pm in reply to: Clear Overrides Throughout Document on Particular Object StyleObject #12243974Brian Pifer
ParticipantMake sure whatever is inside quotation marks (“b”) on the following line is an actual named Object Style in your document:
var oStyle = app.activeDocument.objectStyles.itemByName(“b”);
An example of the change would be:
var oStyle = app.activeDocument.objectStyles.itemByName(“myNamedStyle”);
Brian Pifer
ParticipantLeave line 113 as: var myFindChangeFile = myFindFile(“/FindChangeSupport/FindChangeListNAME1.txt”)
Then change the myFindFileFunction beginning around line 192 to:
function myFindFile(myFilePath){
var folderPath = “F:/Production/5. Tools/1. Scripts”;
myFilePath = folderPath + myFilePath;
if(File(myFilePath).exists == false){
//Display a dialog.
myFilePath = File.openDialog(“Choose the file containing your find/change list”);
}
return myFilePath;
}Brian Pifer
ParticipantI would be happy to develop something for you. Feel free to contact me at brianpifer@gmail.com for a quote.
Brian Pifer
ParticipantJust use Find/Replace after you’ve created the document?
Find in Grep would be: Donation Amount / \$\rDate of Donation /\r
-
AuthorPosts
