Back

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

Forum Replies Created

Viewing 15 posts - 301 through 315 (of 340 total)
  • Author
    Posts
  • in reply to: FIT TextFrame to it's Contents by Java Script #81010
    Peter Kahrel
    Participant

    In the object browser in the ESTK (or any of the other available object-model overviews) select textFrame. The in textFrame’s properties, look through the list — you’ll see fit at some point. Click it to follow through the properties/arguments of ‘fit’ and eventually you come up with something like this (where

    myFrame

    is a reference to a text frame):

    myFrame.fit (FitOptions.FRAME_TO_CONTENT);

    I didn’t know you can fit a frame by clicking twice on an anchor, and it doesn’t work for me. Could you elaborate?

    Peter

    in reply to: Apply Character Style to all Digits After First Sentence #80907
    Peter Kahrel
    Participant

    You’ll have to do it in two steps (that is to say that that’s the only way I can get it to work):

    1. Apply the character style to all digits in the paragraph
    2. Apply the character style [None] to ^.+?\.

    If you want to do that in a GREP style, bear in mind that [None] doesn’t have the same effect as applying it normally, outside a GREP style: it does nothing at all. Create a character style Black, set its colour to Black and use it instead of [None].

    Peter

    in reply to: Need advice re: scripting and GREP #80796
    Peter Kahrel
    Participant

    GREP styles can change form, not substance: they can apply formatting, but can’t change the text itself. You suggested what would seem the most appropriate approach: use a word list to fix case after the change to sentence case. The very rudimentary script below does just that.

    To use the script, open the word list that has all words in their correct case (PetSmart, InDesign, NATO, RSPB), each word on a new line. Then open the document that needs to be treated and change its content’s case to sentence case. Make sure that the text and the list are the only two open documents and that the text is the active document. Then run the script.

    The script reads the list, then looks in the text for the lower-case instance of each list item, case-insensitive (?i) and whole word only (). Case-insensitive searches are needed because sentence case may have rendered unfindable words at the beginning of sentences, such as Nato and Indesign.

    As I said, it’s rudimentary but the basics are there and it can be refined in all kinds of ways.

    (function(){
      app.findGrepPreferences = app.changeGrepPreferences = null;
      var list = app.documents[1].pages[0].textFrames[0].parentStory.contents.split('\r');
      for (var i = 0; i < list.length; i++) {
        app.findGrepPreferences.findWhat = '(?i)b' + list[i].toLowerCase() + 'b';
        app.changeGrepPreferences.changeTo = list[i];
        app.documents[0].changeGrep();
      }
    }());

    Peter

    in reply to: find/change on left or right page only? #80485
    Peter Kahrel
    Participant

    Shouldn’t be too hard. Did you ask Marc Autret (https://www.indiscripts.com)? It says in the script file that he rewrote the script, so he should be your first port of call.

    Peter

    in reply to: Reverse Numbering #80151
    Peter Kahrel
    Participant

    Should be fairly simple, though I haven’t seen your document. Prepare your document as follows: on each master page place a text frame for the page number and name it ‘folio’ (without the quotes) on the Layers panel. Then run this script:

    (function () {
      var i, index;
      var frame;
      var n = 1;
      var pages = app.documents[0].pages.everyItem().getElements();
      for (i = pages.length-1; i >= 0; i--) {
        n--;
        if (pages[i].textFrames.item('folio').isValid) {
          pages[i].textFrames.item('folio').remove();
        }
        if (pages[i].appliedMaster !== null) {
          index = pages[i].side === PageSideOptions.LEFT_HAND ? 0 : 1;
          frame = pages[i].appliedMaster.pages[index].textFrames.item('folio');
          if (frame.isValid) {
            frame = frame.duplicate (pages[i]);
            frame.contents = String(n);
          }
        }
      }
    }());

    When you add and/or delete pages, simply run the script again.

    Peter

    in reply to: GREP help requested #80134
    Peter Kahrel
    Participant

    I think the problem is the order in which you apply the GREP styles. Start with the descriptor, applying your style to .+$
    Then do the other parts. The effect is that the descriptor style is applied to the whole paragraph, then the dollar sign, disappear, etc. styles override the descriptor at the beginning of the paragraph.

    Peter

    in reply to: Batch convert script not working #79678
    Peter Kahrel
    Participant

    Delete the script’s configuration file. See the script’s web page for details.

    Peter Kahrel
    Participant

    (Without [code] and [/code], naturally. Forgot the correct format for those.)

    Peter Kahrel
    Participant

    You’re replacing text content, which is dangerous because you may delete index markers, cross-references, etc. etc. And you might make a mess of formatting. It’s safer to let InDesign do the replacements rather than JavaScript. Something like this:

    [code]app.documents[0].textPreferences.typographersQuotes = false;
    app.findGrepPreferences = app.changeGrepPreferences = null;

    app.findGrepPreferences.findWhat = ‘(["’])’;
    app.changeGrepPreferences.changeTo = ‘$1’;
    imgtext.changeGrep();

    app.documents[0].textPreferences.typographersQuotes = true;[/code]

    Peter

    in reply to: selecting frames and running a script? #79502
    Peter Kahrel
    Participant

    I’m guessing that each page has four rows of three frames, and that you want to thread the frames in each row, so that you end up with four stories on each page. If the frames were placed left to right and top to bottom, then the threading is simple.

    What’s less simple is the option to fit frames to their content. When you do that in the interface, text frames can be fitted only vertically. So how should the frames be fitted? That is, where should the text be after fitting it? Maybe a screenshot of the before and after situations might be an idea.

    in reply to: Getting glyphs out of text or string #79454
    Peter Kahrel
    Participant

    The string ‘differ’ that you see on screen doesn’t contain any underlying ligature: ‘ff’ is just rendered as a ligature on your screen. You can see that in (at least) two ways: you can place the cursor between the two f’s, and when you select the word, the Info panel reports 6 characters. So I don’t think it’s possible to get the dump you’re after.

    in reply to: GREP: Finding Zero #79453
    Peter Kahrel
    Participant

    In your (?<!.)0(?!.) the dot stands for ‘everything’. Try (?<!\.)0(?!\.) and see what happens. If there are more exclusions, do them as classes, as in (?<![\.,(])0(?![\.,)])

    Peter

    in reply to: GREP help needed (finding all instances of words) #79288
    Peter Kahrel
    Participant

    The two should prevent finding ‘just’ in ‘adjustment’, etc. matches only at word boundaries.

    in reply to: selecting frames and running a script? #79173
    Peter Kahrel
    Participant

    Maybe if you take the time to explain yourself in some more detail, someone might decide if a simple script is possible or if you need a complicated one.

    1. ‘select 3 text frames’ — which 3 frames?
    2. ‘run the join text frame script’ — which script is that?
    3. ‘the merge frame fitting button’ (desperately in need of a hyphen here) — which button? What do you mean by ‘merge frame’: threading?
    4. ‘then move to the next three frames’ — which next three frames? Where are they?

    Peter

    in reply to: Limit scope of GREP String #79170
    Peter Kahrel
    Participant

    Probably because in InDesign you enter them in the GREP tab of the Find/Change window, and it’s become a habit to referer to regexes as GREPS.

Viewing 15 posts - 301 through 315 (of 340 total)