Apply the character style to the part of the paragraph

I am inserting text in a block of text with the following code:

story.insertionPoints [-1] .silence += pgfStr;

story.insertionPoints [-1] .silence += "\t";

story.insertionPoints [-1] .silence += refStr;

story.insertionPoints [-1] .silence += "\r";

I want to apply the character style to all of the text in refStr (only the part of this paragraph). I know how the syling paragraph applies to the entire paragraph, but not a character style. I should be grateful if you would help. Thank you!

Hello

Dan - BTP says:

... the size in points and attack can be different on each page...

You are able to find a rule of these differences?

...

What do depends on what type of rule could be defined

...

The size of reference point that is 1.5 PT lower than the point size of the paragraph, whatever.

Close to the end of the script, you can code for example:

     //     Your target is "reference" which is a text inbetween tabulator and end of story (or other criteria).
     //     So you could define:
app.findGrepPreferences = null;      // just for clear it
app.findGrepPreferences.findWhat = "(?<=\\t).+\\s\\Z";     //     to catch text following tab in last para of story
     //     and after:
mFound = app.activeDocument.findGrep();
     //     so all desired text objects are in an array "mFound".
     //     you could iterate (backward) through it:
len = mFound.length;
while (len-->0)      //     ">0" in case of nothing found
     mFound[len].pointSize -= 1.5;

     //     whatever that is - is 1.5 smaller

Jarek

Tags: InDesign

Similar Questions

  • How to apply a character Style that has already been made in a document model?

    First of all, I would like to thank everyone who helps. I am a complete newbie to the script and appreciate your help.

    I mainly use GREP expressions to search for patterns in a document and apply a character Style that has already been done. This character style did not help script, but just in InDesign when the production and implementation of the model.

    var myDoc = app.activeDocument;
    
    
    //Clear the find/change grep preferences.
    app.findGrepPreferences = NothingEnum.nothing;
    app.changeGrepPreferences = NothingEnum.nothing;
    
    //Set the find options.
    app.findChangeGrepOptions.includeFootnotes = false;
    app.findChangeGrepOptions.includeHiddenLayers = false;
    app.findChangeGrepOptions.includeLockedLayersForFind = false;
    app.findChangeGrepOptions.includeLockedStoriesForFind = false;
    app.findChangeGrepOptions.includeMasterPages = false;
    
    //GREP Expression for finding all HEADERS
    app.findGrepPreferences.findWhat = ".+\n";
    
    //Applying formatting changes to put into All Caps, Bold and changing the font size to 12 pt.
    app.changeGrepPreferences.capitalization = Capitalization.allCaps;
    app.changeGrepPreferences.fontStyle = "Bold";
    app.changeGrepPreferences.pointSize = "12";
    myDoc.changeGrep();
    
    //Clear the find/change preferences after the search.
    app.findGrepPreferences = NothingEnum.nothing;
    app.changeGrepPreferences = NothingEnum.nothing;
    

    This is how I currently. I will manually define the changes made to the text. The problem is, each model uses a different set of fonts and not all use them "BOLD", for example Sabon can use THIS "BOLD".

    I would like to know how to apply a character Style and tried to look, but nothing seems to work.

    Any help would be appreciated.

    Thank you.

    app.changeGrepPreferences.appliedCharacterStyle = "A";

  • How to apply a character style to url an email?

    Mac-Indesign CC

    I am trying too use a grep style to apply a character style to url an email?

    Is this possible?

    Better to consider Nina Storm

    Hello

    Try this:

    [^\s]+@[^\s]+

  • I'm looking for links Hypertext in find/replace the dialogue (without applying a character style).

    I have 7000 hyperlinks in my document, with different character styles ("italic", "bold" and "italic +"BOLD""). I need to apply the blue color to each of them. If I ask a new character style "hyperlink" to all, I'll lose my formatting.

    Is there a way to find hyperlinks (for themselves, not their format) dialog find/replace in order to create and apply 4 different character styles ('hyperlink_regular', 'hyperlink_bold', 'hyperlink_italic' and ' hyperlink_bold + italic")?

    Sorry for my English, thanks for the help!

    Use Javascript!

    You can use this Javascript, for example. (Instructions on how to use a JavaScript in InDesign can be found elsewhere).

    blue = app.activeDocument.swatches.item("Blue");
    for (a=0; a
    

    Take care to provide the correct color swatch name in the first line.

  • retention of the words italic when you apply the paragraph style

    When you place text in InDesign, I want to apply a paragraph style, but keep some (foreign) words in italics without having to search for each word and apply the italic character style. Texts are long and not originated by myself.

    The most recommended book for beginners here on the forum is Visual QuickStart of Sandee Cohen for InDesign. The 'bible' in my opinion, for very advanced users is Real World InDesign.

  • Script will not apply the paragraph style

    Hello

    I'm new to scripting in InDesign (CS3), and I'm trying to understand why the scipt below does not apply a style in the following text file? :

    < ASCII-WIN >

    < ParaStyle: Heading 1 > who are we? < ParaStyle >:

    For ease of reading, I have shortend the text file to just two lines.

    The script that I use to open and to format the text file is:

    Create a new document.

    myDocument var = app.documents.add ();

    Set the units of measure and the origin of the rule.

    myDocument.viewPreferences.horizontalMeasurementUnits = MeasurementUnits.points;

    myDocument.viewPreferences.verticalMeasurementUnits = MeasurementUnits.points;

    myDocument.viewPreferences.rulerOrigin = RulerOrigin.pageOrigin;

    Get a reference to the first master spread.

    var myMasterSpread = myDocument.masterSpreads.item (0);

    Get a reference to preferences on the margins of the first page in the Master spread.

    var myMarginPreferences = myMasterSpread.pages.item (0) .marginPreferences;

    Now set up the page margins and columns.

    myMarginPreferences.left = 4;

    myMarginPreferences.top = 70;

    myMarginPreferences.right = 70;

    myMarginPreferences.bottom = 78;

    myMarginPreferences.columnCount = 2;

    myMarginPreferences.columnGutter = 14;

    The margins of page and columns for the right-hand page.

    var myMarginPreferences = myMasterSpread.pages.item (1) .marginPreferences;

    myMarginPreferences.left = 48;

    myMarginPreferences.top = 70;

    myMarginPreferences.right = 70;

    myMarginPreferences.bottom = 78;

    myMarginPreferences.columnCount = 3;

    myMarginPreferences.columnGutter = 14;

    Adding Master Page items

    var myMasterSpread = myDocument.masterSpreads.item (0);

    var myLeftPage = myMasterSpread.pages.item (0);

    var myRightPage = myMasterSpread.pages.item (1);

    var myLeftFooter = myLeftPage.textFrames.add ();

    myLeftFooter.geometricBounds = [70, 742, 728, 528];

    myLeftFooter.textFramePreferences.firstBaselineOffset = FirstBaseline.leadingOffset;

    myLeftFooter.contents = SpecialCharacters.autoPageNumber;

    myLeftFooter.parentStory.characters.item (0) .pointSize = 11;

    myLeftFooter.parentStory.characters.item (0) .leading = 14;

    var myRightFooter = myRightPage.textFrames.add ();

    myRightFooter.geometricBounds = [48, 742, 728, 542];

    myRightFooter.textFramePreferences.firstBaselineOffset = FirstBaseline.leadingOffset;

    myRightFooter.contents = SpecialCharacters.autoPageNumber;

    myRightFooter.parentStory.characters.item (0) .pointSize = 11;

    myRightFooter.parentStory.characters.item (0) .leading = 14;

    myRightFooter.parentStory.characters.item (0) .justification = Justification.rightAlign;

    Adding master text frames

    var myLeftPage = myMasterSpread.pages.item (0);

    var myRightPage = myMasterSpread.pages.item (1);

    var myLeftTextFrame = myLeftPage.textFrames.add ();

    myLeftTextFrame.geometricBounds = [70, 70, 714, 528];

    myLeftTextFrame.textFramePreferences.firstBaselineOffset = FirstBaseline.leadingOffset;

    myLeftTextFrame.textFramePreferences.textColumnCount = 3;

    myLeftTextFrame.textFramePreferences.textColumnGutter = 14;

    Add a label to make the image easier to find later.

    myLeftTextFrame.label = "BodyTextFrame";

    var myRightTextFrame = myRightPage.textFrames.add ();

    myRightTextFrame.geometricBounds = [70, 48, 714, 542];

    myRightTextFrame.textFramePreferences.firstBaselineOffset = FirstBaseline.leadingOffset;

    myRightTextFrame.textFramePreferences.textColumnCount = 3;

    myRightTextFrame.textFramePreferences.textColumnGutter = 14;

    Add a label to make the image easier to find later.

    myRightTextFrame.label = "BodyTextFrame";

    Link the two frames using the nextTextFrame property.

    myLeftTextFrame.nextTextFrame = myRightTextFrame;

    The substitution of Master Page points and adds text

    var myTextFrame = myDocument.masterSpreads.item (0).pages.item (1).textFrames.item (0) .override (myDocument.pag es.item (0));

    Add text by setting the contents of the insertion of a string.

    In JavaScript, "\r" is a return character.

    .silence myTextFrame.insertionPoints.item (0) = "dok\r";

    Adding and applying a paragraph Style

    var myParagraphStyle = myDocument.paragraphStyles.item ("title 1");

    try {}

    var myName = myParagraphStyle.name;

    }

    {} catch (MonErreur)

    //The style of paragraph don't have not exist, so create it.

    myParagraphStyle = myDocument.paragraphStyles.add ({name: 'Title 1'});

    }

    We need to create a color. Check if the color already exists.

    myColor var = myDocument.colors.item ("Green");

    try {}

    myName = myColor.name;

    }

    {} catch (MonErreur)

    //The color have not exist, so create it.

    myColor = myDocument.colors.add ({name: 'Green', model: ColorModel.process, colorValue:[100,0,100,0]});})

    }

    Now set the formatting of the paragraph style.

    myParagraphStyle.appliedFont = "Arial";

    myParagraphStyle.fontStyle = "Bold";

    myParagraphStyle.pointSize = 24;

    myParagraphStyle.spaceAfter = 24;

    myParagraphStyle.spaceBefore = 24;

    myParagraphStyle.fillColor = myDocument.colors.item ("Green");

    Apply the style to the paragraph.

    myDocument.pages.item (0).textFrames.item (0).paragraphs.item (0) .applyParagraphStyle (myParag raphStyle, true);

    You can also use:

    myDocument.pages.item (0).textFrames.item (0).paragraphs.item (0) .appliedParagraphStyle = //myParagraphStyle;

    Import a text file

    Display a standard dialog box open the file to select a text file.

    var monFichierTexte is File.openDialog ("choose a text file");.

    If you selected a text file, and if you didn't press Cancel,

    Place the file of text on the first insertion point after the title.

    If ((monFichierTexte! = "") & & (monFichierTexte!) (= null)) {}

    myTextFrame.insertionPoints.item(-1).place (myTextFile);

    }

    Place a graphic

    Display a standard dialog box open the file to select a graphic file.

    var myGraphicFile is File.openDialog ("choose a graphic file");.

    If you have selected a graphics file, and if you didn't press Cancel,

    Place the graphic file on the page.

    If ((myGraphicFile! = "") & & (myGraphicFile!) (= null)) {}

    var myGraphic = myDocument.pages.item (0) .place (myGraphicFile);

    //Since you can place multiple graphics at once, the place method

    //returns a table. For the graph you have placed, get the first

    //item in the table (beginning of JavaScript arrays with element 0).

    myGraphic = myGraphic [0];

    //Create a style object to apply to the graphic image.

    var myObjectStyle = myDocument.objectStyles.item("GraphicFrame");

    try {

    var myName = myObjectStyle.name;

    }

    catch (MonErreur) {}

    //The an object style have not exist, so create it.

    myObjectStyle = myDocument.objectStyles.add({name:"GraphicFrame"});)

    }

    myObjectStyle.enableStroke = true;

    myObjectStyle.strokeWeight = 3;

    myObjectStyle.strokeType = myDocument.strokeStyles.item("Solid");

    myObjectStyle.strokeColor = myDocument.colors.item("Green");

    //The frame containing the graphic is the parent of the graphic.

    myFrame var = myGraphic.parent;

    myFrame.applyObjectStyle (myObjectStyle, true);

    //Resize the frame to a specific size.

    myFrame.geometricBounds = [0,0,600,600];

    //Fit the graph in the image proportionally.

    myFrame.fit (FitOptions.proportionally);

    / / Next, mount the frame to the resized image.

    myFrame.fit (FitOptions.frameToContent);

    var myBounds = myFrame.geometricBounds;

    var myGraphicWidth = myBounds [3] - myBounds [1];

    //Move the graphic frame.

    var myPageWidth = myDocument.documentPreferences.pageWidth;

    var myTopMargin = myDocument.pages.item (0).marginPreferences.top;

    myFrame.move ([myPageWidth-myGraphicWidth, myTopMargin]);

    //Apply a wrap to the graphic frame.

    myFrame.textWrapPreferences.textWrapType = TextWrapTypes.boundingBoxTextWrap;

    myFrame.textWrapPreferences.textWrapOffset = [12, 24, 12, 24].

    }

    I hope someone can point me in the right direction.
    Thanks in advance.
    Ron

    Hey, Ron.

    The problem has nothing to do with your script. You can see if you attempt to place the file from indesign tagged text by hand.

    Your instinct for divide and conquer for debugging is a good - have a short text file to work with is very useful - of course this is also true for the script.

    During the validation of the scripts on the forum, please do not use the syntax insert > feature Java which lies behind the > arrow in the toolbar. Otherwise, cut and paste your script are difficult requiring manual corrections.

    Anyway, your problem is that each paragraph can have only a single paragraph style, and it's the last one that you define.

    So in your IDTT file, you set the heading 1 paragraph style, enter the content of the paragraph and then set the style of paragraph votes to zero.

    If you have included a line break before setting the style of paragraph votes to zero, you must set the None style for the following paragraph. But since you have not, it resets just the style to the current paragraph.

    In short: success back before .

  • Apply the paragraph style instead of runned text simply by clicking on the text box

    I'm changing the style of the text entity. Is there another way to change it to select all the text, and then set the style?

    Capture.JPG

    IT is threaded text block (not a box!) you have to select all the blocks of text at a time in the thread (which is impossible if they are on different spreads) or you must select all of the text to apply a style.

    If the text block is not passed, you can select and apply the text.

    I do not see a problem to select all the text. Use the text tool, click in the text and the cmd/ctrl + A and apply the style. Not a problem, not a lot of work.

    A box is something like BleedBox, CropBox or something like that. Objects in InDesign are still frames or paths.

  • Automatic table row apply the paragraph style

    Hello

    I am new to scripting in Indesign. I would like to write a script to apply a paragraph on a line style in a table like this:

    1 search for the string 'XX' in a table

    2. when the 'XX' string is found, apply a paragraph style named "ParA" to the line that contains the string "XX".

    3. apply a cell style named "CellA" to the cell that contains the sting "XX".

    4. apply the style of paragraph called 'Service' to the string "XX".

    5 search for the string "XX" to the end of the table

    Can someone help me?

    Hi Syd,

    For the selected table, use the below a.

    var doc = app.activeDocument,
        _tables = app.selection[0],
        i, j, k, l, a =0, _rows,_cells, rowlen; 
    
    _rows = _tables.rows;
    for(k =0;k<_rows.length;k++)
    {
        _cells = _rows[k].cells;
        for(l =0;l<_cells.length;l++)
        {
            if(_cells[l].contents == "xx")
            {
                rowlen = _cells[l].parent.cells.length;
                a = 0;
                while(rowlen--)
                {
                      _cells[l].parent.cells[a].paragraphs.everyItem().appliedParagraphStyle = doc.paragraphStyles.item("ParA");
                      a++;
                    }
                _cells[l].paragraphs.everyItem().appliedParagraphStyle = doc.paragraphStyles.item("ParB");
                _cells[l].appliedCellStyle = doc.cellStyles.item("CellA");
                }
            }
        }
    

    Kind regards

    Cognet

  • Apply the paragraph using Enter/Return style works only on empty paragraphs

    The InDesign CS4 document, I'm working on that has paragraph styles based on other paragraph styles. For example, the following chapter for BodyFirst style is body. Hit Enter/Return after typing a BodyFirst applies in subsection empty body, no problem.

    However, I sometimes already existing text that needs to be reformatted. For example, BodyFirst may be followed by Heading1, but Heading1 must be changed in body.

    I'm used to FrameMaker, where you can go back the Heading1 paragraph so that BodyFirst and Heading1 are in the same paragraph and then press enter/return to change quickly the correct paragraph style Heading1, body style. However, InDesign repeat the last style when I press enter/return, so that in this example, I find myself with followed BodyFirst of another BodyFirst.

    Is it possible to change this so that the following paragraph style is correct by hitting enter/return by using already existing text?

    Select the paragraphs, and then right-click (ctrl-click on Mac) on the name of the paragraph style in the paragraph Styles Panel. It should give you the possibility of style "of paragraph 1 ', then the following Style.

  • Need to search and apply a character style sheet

    I have a directory with the name and address of the student. I need to find 2 returns and replace with 2 returns, apply the character style, back. Here is a screenshot so you can see what I mean screen.

    [Picture with private information removed by Moderator]

    Allen, Davis must be condensed ital "BOLD" like Ahmed, Ehsan is above. Any help appreciated.

    Post edited by: Peter Spier

    Right. I have the impression that there is. As always... may be wrong.

  • How can I apply a character style to a sentence that has a '&amp;' in there?

    Hi all

    I am applying the "See Figure" character style to any mention of the expression (see Figure x) as I understand is: \(See Figure \d+\)

    The problem I face is that sometimes I need to list several references to figure. He must read (see Figure x & y) and in rare cases (see Figure x, y and z)

    NOTE: There are no spaces in the above numbers.

    Thank you for your help.

    Try------(see Figure [\d,&]+\) (not tested).

  • apply a character style

    I received help week last with a script to find the empty cells in a table, put a space in empty cells and apply a paragraph style to the cell. Now I would like to help with application of a "None" character style to the space in the cell. Here's the script that made me initially:

    for (a = 0; a < app.selection [0].parent.parent.cells.length; a ++)
    {
    If (app.selection [0].parent.parent.cells [a].contents.length == 0)
    {
    App.Selection [0].parent.parent.Cells [a] .silence = "";
    App.Selection [0].parent.parent.Cells [a] .paragraphs [0] .appliedParagraphStyle = app.activeDocument.paragraphStyles.item ("empty cell");

    }
    }

    If you have a selected cell, will apply as follows the tank style 'None' (not the same as [none]) in the first paragraph of the cell.

    App.Selection [0] .paragraphs [0] .appliedCharacterStyle = app.activeDocument.characterStyles.item("None");

    I suppose that him below will do what you want, but I think that using a nested style would be easier.

    for (a = 0;
    {
    If (app.selection [0].parent.parent.cells [a].contents.length == 0)
    {
    App.Selection [0].parent.parent.Cells [a] .silence = "";
    App.Selection [0].parent.parent.Cells [a] .paragraphs [0] .appliedParagraphStyle = app.activeDocument.paragraphStyles.item ("empty cell");

    App.Selection [0].parent.parent.Cells [a] .paragraphs [0] .appliedCharacterStyle = app.activeDocument.characterStyles.item("None");

    }
    }

  • keyboard shortcut to apply the paragraph tag

    I am experienced with FrameMaker 8, but just to start getting used to FrameMaker 9. A keyboard shortcut that I use constantly in FrameMaker 8 is Ctrl-9, type the first letter of the paragraph tag, and then press ENTER. If there is more than one, starting with the same letter, I keep just hitting this letter until it appears the tag I want. For example if there is a title 1 and a Title2, I type 'h' twice to get Title2. With FrameMaker 9, it seems that I have to type the whole word "Title2" before hitting entry.

    Frustrating when shortcuts favorites are messy. Is it possible to recover my old shortcut? Is there a quick way to apply paragraph tags in FrameMaker 9?

    Jay fresno wrote:

    I am experienced with FrameMaker 8, but just to start getting used to FrameMaker 9. A keyboard shortcut that I use constantly in FrameMaker 8 is Ctrl-9, type the first letter of the paragraph tag, and then press ENTER. If there is more than one, starting with the same letter, I keep just hitting this letter until it appears the tag I want. For example if there is a title 1 and a Title2, I type 'h' twice to get Title2. With FrameMaker 9, it seems that I have to type the whole word "Title2" before hitting entry.

    Frustrating when shortcuts favorites are messy. Is it possible to recover my old shortcut? Is there a quick way to apply paragraph tags in FrameMaker 9?

    Type down arrow after selecting the first of similar format names. For example, Ctrl + H 9 DnArrow moves to Title2, or whatever the second format that begins with "H".

    Consider using format names that have less of the same main characters. For example:

    Title 1 H 1

    2 H Title2

    1N Numbered1

    Numbered N

    1 typo displays 1 H Heading1; DnArrow moves to 1N Numbered1.

    Some people separate the abbreviation of the full name with an underscore instead of a space; i. e., 1H_Heading1, instead of 1 H Heading1.

    HTH

    Kind regards

    Peter

    _______________________

    Peter gold

    Know-how ProServices

  • ID CC 2015 crashes as soon as I (try to) apply the paragraph style to the text.

    I work on a Mac Pro (mid-2009), OS X 10.10.4, 16 GB of RAM

    Original hard drive is 1 TB (where applications are installed), second drive (designated as working drive, and where all the work files are housed) is 2 TB.

    Currently subscribe to Adobe CC 2015, using InDesign with last update

    I have been working for several days on a long paper (paper) and have developed 12 paragraph styles, using two fonts - Garamond first Pro and Helvetica Neue LT and the document has facing pages.

    Yesterday, my client (the author) has asked all text flow on the odd pages, for illustrations on all pages, so I did all the text boxes thread directly downward of pages on the right (odd pages).

    The first three chapters were style before I changed the threading of text box. Now, when I open the document and begin to apply styles to paragraph for the rest of the text (nine more chapters, which automatically adopted the style of main text as soon as I stuck in the newly-threaded text boxes), ID crashes when I highlighted a section of text and click a paragraph style.

    I checked the permissions and preferences. The only thing I can think is from the document from scratch.

    Any other suggestions?

    Thread the text boxes only on odd pages cause the problem, since it does not have facing pages?

    Thank you.

    There could be corruption in the document.

    Save the document with IDML and reopen the IDML in InDesign.

  • How to apply the paragraph style to all paragraphs

    Hi people,

    Simple question. New to JS script here (but so far love it).

    I am trying to apply a paragraph (myTextStyle) style to all paragraphs in a story.

    Right now, I set it up as follows:

    tabletDocument.pages.item (0).textFrames.item ("story").paragraphs.item (0) .applyParagraphSty (myTextStyle, true);

    Obviously, it's just the first paragraph - item (0)-, but no changes to the code it throws.

    Can I implement something to it or a beach (first to last), so it will apply to all of them?

    Thanks in advance!

    N

    Just set the property .appliedParagraphStyle on the whole story.

  • Apply the paragraph style to a glyph and not the glyph displayed?

    I have a large Word document I have to mark up with different paragraph styles. Fortunately the data contains different glyphs for specific text strings, and so I might have the styles of paragraph kick in when he meets the glyph. But ultimately, I need to remove the glyphs when I go to print, and therefore the style will be deleted also.

    I wonder if it is possible to change the glyph to some kind og hidden state. I could mess with the x position of the text string, but I'm not not to keen on this solution. Someone has an idea?

    You must use 'GREP', not 'text', in the Find/Replace window!

Maybe you are looking for

  • Apple Watch phone line

    I own an iPhone 5 and, currently, taking into account the purchase of an Apple Watch.  To make phone calls from the Apple Watch will take to purchase and additional phone line to my mobile operator?

  • Clock, waste of time

    I have new computer a Packard Bell. I find that the clock loses time. However, the date is ok. How can I stabilize the clock settings. For the moment, I bring up the control panel date and time in order to correct the time. Thank you for your help

  • Satellite X 200: Toshiba Vista value-added download Pack - files are corrupted

    I downloaded the valuespack severaltimes for my Satellite x 200.By extracting, I get a corrupted message that the files are corrupt. What is the problem with the file? THX

  • Qosmio F20-136: scanned TV guide channel - save the file so you can recharge?

    I have a Qosmio F20 - 136 running XP Media Center. My question is does anyone know the name of the file that has the channels scanned so that if I do a re scan and don't get all channels from the list, because of my reception antenna I can re - load

  • Equium A60 - where to find the drivers!

    Where can I find the drivers for this thing? Checked drivers download pages and lists of production left without success and I'm tough, I found them a few weeks ago. Any help would be appreciated