Back

If your email is not recognized and you believe it should be, please contact us.

Forum Replies Created

Viewing 15 posts - 16 through 30 (of 47 total)
  • Author
    Posts
  • in reply to: Glyph Find and Replace #14323117
    Brian Pifer
    Participant

    If you’re sure you are passing a Document reference to myFindGlyph(doc) in main, only other thing I can think of is to ensure the find font is installed and you have the right glyph ID.

    in reply to: Glyph Find and Replace #14323120
    Brian Pifer
    Participant

    Where do you call the function in your main code? Are you sure you are passing a Document reference to it?

    Also are you sure that is the correct font in the findWhat? One has XE in the font name, while the change font name does not.

    in reply to: Glyph Find and Replace #14323122
    Brian Pifer
    Participant

    In your function definition, you are passing an argument called myobject, but you are referencing myDocument in the function, which is not declared in scope, so it is undefined.

    in reply to: Script for hyphenation #14323135
    Brian Pifer
    Participant

    Are you just changing one or two existing Paragraph Styles with this new hyphenation? If so, probably just easier to set up corresponding Paragraph Styles with the right hyphenation settings and doing a Find/Replace. Also, what is that dropdown at the end of your image? I don’t see it in my Hyphenation settings. Maybe a plugin? Not sure that would be scriptable, unless I’m missing something.

    Brian Pifer
    Participant

    Disclaimer: GREP is not my strong suit, but I think this can be accomplished via script. The following will find all bracketed content, and compare the brackets to the first and last characters within the brackets to compare their applied fonts. Not sure if my app.findGrepPreferences.findWhat line will match exactly all the time — if you already have a good GREP you’re using, feel free to sub it in (add an additional escape backslash for the script purposes. I haven’t fully tested, but you can give it a shot.

    var doc = app.activeDocument;

    app.findGrepPreferences = NothingEnum.NOTHING;
    app.changeGrepPreferences = NothingEnum.NOTHING;
    app.findGrepPreferences.findWhat = “[(w*| *){1,}]”;
    var finds = doc.findGrep();

    for (var i = 0; i < finds.length; i++) {
    var firstBrack = finds[i].characters[0];
    var lastBrack = finds[i].characters[-1];
    var firstChar = finds[i].characters[1];
    var lastChar = finds[i].characters[-2];
    if (firstChar.appliedFont.fullName.toLowerCase().indexOf(“italic”) >= 0 && lastChar.appliedFont.fullName.toLowerCase().indexOf(“italic”) >= 0)
    {
    firstBrack.appliedFont = firstChar.appliedFont;
    lastBrack.appliedFont = firstChar.appliedFont;
    }
    else if (firstChar.appliedFont.fullName.toLowerCase().indexOf(“italic”) == -1 && lastChar.appliedFont.fullName.toLowerCase().indexOf(“italic”) == -1) {
    firstBrack.appliedFont = firstChar.appliedFont;
    lastBrack.appliedFont = firstChar.appliedFont;
    }
    }

    app.findGrepPreferences = NothingEnum.NOTHING;
    app.changeGrepPreferences = NothingEnum.NOTHING;

    in reply to: Resizing all my frames at once by a certain amount #14323248
    Brian Pifer
    Participant

    Hi Mark,

    You can try this script: https://raw.githubusercontent.com/jpobojewski/InDesign-Toolbox/master/Resize%20Selected%20Items.jsx

    You can also select all the objects you want, and set the anchor point to the top center or left center point (the grid in properties), then type -.25 in the W (width) property.

    If you want to roll your own, here’s how to get started:

    This line of code will get you the current selection as an “array”, meaning you can select multiple text frames and iterate through them.

    var selections = app.selection;

    The iteration looks like this:

    for (var i = 0; i < selections.length; i++) {

    }

    Inside the bracket, you’ll want to get the frame’s coordinates and use either resize or reframe. This part is a bit complicated, but essentially you are using the “resolve” method of a frame to get its current coordinates, then performing math on those coordinates and using resize or reframe using points (9 points = .125 in).
    var frame = selections[i];
    var topleft = frame.resolve(AnchorPoint.TOP_LEFT_ANCHOR, CoordinateSpaces.INNER_COORDINATES, true)[0];
    var bottomright = frame.resolve(AnchorPoint.BOTTOM_RIGHT_ANCHOR, CoordinateSpaces.INNER_COORDINATES, true)[0];
    var x1 = topleft[0] + 9;
    var y1 = topleft[1];
    var x2 = bottomright[0] – 9;
    var y2 = bottomright[1];
    frame.reframe(CoordinateSpaces.INNER_COORDINATES, [[x1, y1], [x2, y2]], true);

    In that math, you are moving the x1 coordinate inward by 9 points (.125 in) and shrinking the x2 coordinate by .125. If you to change the height, you’d do the same operations on the y coordinates.

    The full code put together:

    var selections = app.selection;
    for (var i = 0; i < selections.length; i++) {
    var frame = selections[i];
    var topleft = frame.resolve(AnchorPoint.TOP_LEFT_ANCHOR, CoordinateSpaces.INNER_COORDINATES)[0];
    var bottomright = frame.resolve(AnchorPoint.BOTTOM_RIGHT_ANCHOR, CoordinateSpaces.INNER_COORDINATES)[0];
    var x1 = topleft[0] + 9;
    var y1 = topleft[1];
    var x2 = bottomright[0] – 9;
    var y2 = bottomright[1];
    frame.reframe(CoordinateSpaces.INNER_COORDINATES, [[x1, y1], [x2, y2]]);
    }

    This also assumes you don’t need to resize the containing images after the resize. There’s lots of things that go into writing a script to do what you want to do, but hope this gives you a good starting point for understanding.

    in reply to: Get Selected Table Rows With ExtendScript? #14323318
    Brian Pifer
    Participant

    So weird that you have to select a cell in rows.itemByRange, but there you have it. Michel also PM’d me with a similar solution. Thanks, Peter!

    in reply to: Get Selected Table Rows With ExtendScript? #14323323
    Brian Pifer
    Participant

    Resurrecting this thread, as I’m struggling to get certain rows selected in a table.

    I want to select all rows after a certain point in the table using itemByRange. I’m trying the following.

    var rowsToMove = table.rows.itemByRange(i, rowCount-1).getElements();
    app.select(rowsToMove, SelectionOptions.REPLACE_WITH);

    I get the following error on the app.select line: Error Code# 30477: Invalid value for parameter ‘selectableItems’ of method ‘select’. Expected Object, Array of Objects, NothingEnum enumerator or SelectAll enumerator, but received (Row, Row, Row, Row, Row, Row)

    I’ve tried setting app.selection[0] = rowsToMove; I’ve tried rowsToMove without the getElements(). Mind-boggling.

    Any thoughts? Thanks.

    in reply to: Random font per character script #14323372
    Brian Pifer
    Participant

    Be sure you copied what I have above into a plain text editor such as Notepad, then save as a .jsx, not a word processing application like Word.

    in reply to: Random font per character script #14323376
    Brian Pifer
    Participant

    Sure. With the text in question selected:

    var chars = app.selection[0].characters;
    var fonts = [“Font1”, “Font2”, “Font3”, “Font4”];
    for (var i = 0; i < chars.length; i++) {
    var rando = Math.floor(Math.random() * Math.floor(4));
    chars[i].appliedFont = fonts[rando];
    }

    in reply to: script to detect overset text in indesign 2020 #14323377
    Brian Pifer
    Participant

    Agree it’s probably easier to use to preflight as you can navigate to the textframe in question through the panel, but here you go.

    var tfs = app.documents[0].textFrames;
    var oversetPageNums = [];

    for (var i = 0; i < tfs.length; i++) {
    if (tfs[i].overflows) {
    oversetPageNums.push(tfs[i].parentPage.name);
    }
    }

    alert(oversetPageNums);

    Brian Pifer
    Participant

    This is a pretty niche thing, so don’t think a script exists for it. You could create a paragraph style that does what you want, then cycle through the paragraphs, see if they have 3 or fewer lines, and apply the paragraph style to those lines?

    in reply to: Start position of paragraph text #14323460
    Brian Pifer
    Participant

    This will hit the insertion point at the start of every paragraph on the first page of a document.

    var pagePars = app.document[0].pages[0].textFrames.everyItem().paragraphs.everyItem().getElements();
    for (var i = 0; i < pagePars.length;i++) {
    var ip = pagePars[i].insertionPoints[0];
    //do something at each insertionPoint
    }

    There are other ways to get to whichever paragraphs you need. For instance, if you had a textFrame selected with the black arrow tool, you could get the textFrame’s parent story paragraphs with this:

    var psPars = app.selection[0].parent.paragraphs;
    for (var i = 0; i < psPars.length; i++) {
    var ip = psPars[i].insertionPoints[0];
    //do something at each insertionPoint

    }

    in reply to: Problem with the paragraph.contents property #14323512
    Brian Pifer
    Participant

    Are you using string.replace? Have you tried changing one graf with GREP. If that works, you could set a GREP replace script instead of string.replace, replacing with that arrow character with the character that copies over and maybe setting that character with a style that you can apply on the GREP replace?

    in reply to: Dealing with a password-protected PDF in script #14323746
    Brian Pifer
    Participant

    Relatedly, I just discovered that each file above is a multipage PDF. So, essentially, I am attempting to automate the placement of multiple multipage pdfs. I figure I can handle each page using PDFPlacePreference.pageNumber, but I need to know the total number of pages in each multipage PDF before doing that. I can’t seem to find where this info would be exposed though. Does anyone have any thoughts?

Viewing 15 posts - 16 through 30 (of 47 total)