Forum Replies Created
-
AuthorPosts
-
Brian Pifer
ParticipantDisregard, I found the bug, which was unrelated to my sorting.
Brian Pifer
ParticipantSorry for the delayed reply.
Add this somewhere in your code:
var myPrompt = prompt(“Name your folder to create on the desktop”);
var f = new Folder(‘~/Desktop/’ + myPrompt);
if (!f.exists)
f.create();Then you will want to update the myFilePath variable to:
var myFilePath = f.fsName + myPageName + “.jpg”;
Note: I do not have Indesign installed and am a bit rusty. I may be forgetting some slash marks in there, and can’t remember if you will want to use f.fsName or f.fullName. But play with that.
Brian Pifer
ParticipantGreat! Glad I was able to help.
Brian Pifer
ParticipantAlain, you can set the file destination by setting the path you desire in this line of the original code. Change Desktop to the destination you want:
var myFilePath = “~/Desktop/” + myPageName + “.jpg”;
Brian Pifer
ParticipantSomething like this might work for images in a given active document. Note, I’m a bit rusty and don’t have access to ID currently to check. For more info on the properties you can write to the file, check: https://jongware.mit.edu/idcs6js/pc_Graphic.html
/////////////////////////
var graphicsArr = app.activeDocument.allGraphics;
var path = ‘~/Documents/’;
var filename = app.activeDocument.name.split()[0] + ‘.json’;
var file = new File(path + filename);file.encoding = ‘UTF-8’;
file.open(‘w’);for (var i = 0; i < graphicsArr.length; i++) {
var g = graphics.Arr[i];
if (g.itemLink.isValid) {
file.write(g.itemLink.name + “\r”);
}//the graphic’s info
file.write(g.horizontalScale.toString() + “\r”);
file.write(g.verticalScale.toString() + “\r”);
file.write(g.geometricBounds.toString() + “\r”); //this comes in as an array of four numbers
file.write(g.rotationAngle.toString() + “\r”); //second return mark to separate different graphics//the parent’s info (rectangle object, most likely)
file.write(g.parent.horizontalScale.toString() + “\r”);
file.write(g.parent.verticalScale.toString() + “\r”);
file.write(g.parent.geometricBounds.toString() + “\r”); //this comes in as an array of four numbers
file.write(g.parent.rotationAngle.toString() + “\r”); //second return mark to separate different graphics}
file.close();
Brian Pifer
ParticipantNot sure this will work as I don’t have access to ID currently and am a bit rusty, but I would try something along the lines of:
var myPars = app.document.paragraphs.everyItem();
for (var num = 0; num < myPars.length; num++) {
var revisedPointSize = myPars[num].texts.anyItem().pointSize;
myPars.appliedParagraphStyle.pointSize = revisedPointSize;
}It could be made more elegant by skipping styles already fixed, or I could be approaching it totally backward or incorrectly, but that’s how I would start. This only accounts for point size and not other properties that might be changing, or character styles, but hopefully it helps you start to tackle it.
Brian Pifer
ParticipantWhat kind of differences might you be looking to compare, and is the point of the comparison to identify the ones that need to be changed in the second part of your question?
For the second part here is a brute Force solution (I’m a bit rusty):
var myPars = app.document.paragraphs.everyItem();
for (var i = 0; i < myPars.length(); i++) {
if (myPars[i].appliedParagraphStyle == “styleToChange” {
myPars[i].applyParagraphStyle(“styleToApply”), true));
//Repeat other if statements as necessaryBrian Pifer
ParticipantThere might be other ways to approach without getting so complicated, ie, does it have to be a menu command, or could you just run a script on a given document if there were some unique characteristics about the frames you wanted to export the data on. For instance, some pseudocode would be:
For the frames in a doc,
If the frame has a linked file name,
Append that frame’s data to the json docWould something like that work, or do you only want to export some specific linked files. Are there any commonalities between them that could be identified?
Brian Pifer
ParticipantThis is not quite a trivial matter. You’ll be dealing with the application’s menu objects, script menu objects as well as event listeners, along with the code to provide the export you seek. The following article may be helpful to start wrapping your brain around it, but it would be a somewhat complex script.
https://www.indiscripts.com/post/2010/02/how-to-create-your-own-indesign-menus
Brian Pifer
ParticipantHi Dragos,
Not sure where the “vtsnsinsicpg…” line would be coming from, if the code I provided is the only thing in the .jsx file, unless you have another script that is appending some kind of root filename into other scripts. Sorry I can’t be of more help.
Brian Pifer
ParticipantHi Dragos,
Something like this should work for the first part of the problem you’re trying to solve. It assumes you have the main frame you want resized selected with the black arrow. It should resize the frame to the edge of the page. I don’t have much familiarity with bleeds so couldn’t help you too much there. Hopefully this is a useful start.
var theDoc = app.activeDocument;
var theSelection = app.selection[0];
var bounds = [0, 0, theDoc.documentPreferences.pageHeight, theDoc.documentPreferences.pageWidth];
theSelection.geometricBounds = bounds;Brian Pifer
ParticipantHi Philip, Paul’s code from Jan. 28 should work. If you need help with how to set up a script with a snippet you found here, check out this post: https://creativepro.com/how-to-install-a-script-in-indesign-that-you-found-in-a-forum-or-blog-post.php
Brian Pifer
ParticipantThank you for the response, Jake. You definitely provided a lot of food for thought. I probably wouldn’t have charged if the client hadn’t offered to pay, since I, too, script for the love of it. I think I set a fair price and developed a contract that covers my bases. I appreciate your insight.
Brian Pifer
ParticipantNo problem. I realized my explanation about using Join wouldn’t work, since you’re not working with strings with FindGrep(); rather, they’re an array of Text objects. So yes, you would need to loop through regardless.
Brian Pifer
ParticipantBecause you are not performing a task for each find within the “for” loop. All you’re doing is setting the TocTitles variable inside the loop; after you set it the first time, it immediately moves and assigns that variable to the next find. Then, when you exit the loop, you have TocTitles assigned to just one find. You basically need to be doing all the work in the loop, like so:
…
var docTitles = myDoc.findGrep();
var myPage = myDoc.pages.item(1); //fyi, a shorthand for this call is “myDoc.pages[1];”
var tocFrame = myPage.textFrames.add();
tocFrame.geometricBounds = [78.911, 273.75, 237.987, 360.25];for ( i = 0; i < docTitles.length; i++ ) {
var tocTitles = docTitles[a];
tocFrame.contents += tocTitles.contents + “\r”;
}Or you could forget the for loop entirely, and use the array’s join method to combined all the finds into one big chunk, then add them to the text frame.
var myFinds = …findGrep();
var myJoin = myFinds.join(“\r”); //the “\r” puts a return mark between each array entry.
myFrame.contents = myJoin; -
AuthorPosts
