Script of paragraph style

Hi all

I use InDesign for a newspaper until it goes to press. I created all the necessary paragraph styles, however they are not available on every new page, so I have to manually load them from a template. We are part of a chain of newspapers and do not receive our internal models, so it is difficult to have the styles incorporated into models, created from the master page to the company. It would be wise for companies to provide the same styles to all their papers, but I guess it would make too much sense.

Is there a way to create a script or another method be more easily able to load styles of paragraph for each page of the log. Some of my colleagues were really struggling with that and so that they use the wrong fonts, sizes etc. which is a real problem come press time. Thanks in advance.

Brandon

Seems to me that it is a reasonable request to have a script, preferably that is triggered by the command file open, that could automate load styles to a reference document if there is no way to get the model fitted with the correct styles upstream. Is this the best solution? No, but it would save time and ensure that the styles are always loaded and always loaded from the same source, reducing errors.

Tags: InDesign

Similar Questions

  • Bike via script of paragraph styles - need help

    Hello

    I have a large document (potentially 3000 pages), on each page is a picture of a picture frame and inside each image is a famous quote. I need to type in each quote so I have 10 configuration value different paragraph styles in a different font. I need a script that applies "QuoteStyle1" the text on the first page, "QuoteStyle2" on the next page, etc., and once that 'QuoteStyle10' has been applied the script performs a loop and continues to scroll through the styles apply a style that is different on each page, until it reaches the end of the document.

    I got a start on the script (see image), but I think the problem is the line 11 - I want to run the script without having to select anything.

    Some additional info that may or may not be of use - all quotes are drawn from a data merge. There is also a name and a color from the data merge. The background on each frame is a different color and that is created with the a very large 'rule below' in a number of other paragraph styles. They are applied with a 'Find & ReplacebyList' i.e. find replace 'Red' with the paragraph style "ColourRed. In the script, I tried to ignore these "color" paragraph styles (lines 2-9) is only the 'quote' styles that the effects of the script.

    Any help getting this race would be more useful.Screen Shot 2015-07-15 at 10.01.20.png

    First of all congratulations for the very creative use of blending modes. I would have never thought about it by myself.

    Now, for the script, here are two ways to do it (both enjoy the fact that you use a paragraph style BaseQuote):

    (1) use a grep search:

    var doc=app.activeDocument;
    var baseQ=doc.paragraphStyles.item('BaseQuoteStyle');
    var switchToStyles=[
    'QuoteStyle1',
    'QuoteStyle2',
    'QuoteStyle3',
    'QuoteStyle4',
    'QuoteStyle5',
    'QuoteStyle6',
    'QuoteStyle7',
    'QuoteStyle8',
    'QuoteStyle9',
    'QuoteStyle10'];
    var l=switchToStyles.length;
    app.findGrepPreferences=app.findChangeGrepOptions=null;
    app.findGrepPreferences.appliedParagraphStyle=baseQ;
    app.findChangeGrepOptions.includeMasterPages=false;
    var quotes=doc.findGrep();
    for (var i=0; i
    

    (2) scroll all managers of related texts:

    var doc=app.activeDocument;
    var baseQ=doc.paragraphStyles.item('BaseQuoteStyle');
    var pags=doc.pages.everyItem().getElements();
    var switchToStyles=[
    'QuoteStyle1',
    'QuoteStyle2',
    'QuoteStyle3',
    'QuoteStyle4',
    'QuoteStyle5',
    'QuoteStyle6',
    'QuoteStyle7',
    'QuoteStyle8',
    'QuoteStyle9',
    'QuoteStyle10'];
    var l=switchToStyles.length;
    for (var p=0;p		   
  • Script or a paragraph Style?

    I have an Excel worksheet with name, phone and category.

    It is true - I'm a noob InDesign - but I pick up things quickly.

    I want to format this info (more than 600 entries) in an almost "telephone directory" as put on the page.

    3 columns, "BOLD" first line, tabs: leader dashed, the phone number of regular fonts, the line category: italics.

    This link:

    The name of the company ... (555) 555-5555

    Financial services

    I also need to adjust the spacing between each (space) after paragraph, kerning between company name and the beginning of the «...» "(and after).

    Paragraph style does not... style entry all as the first line.

    Should I build a script?

    Thanks to anyone who takes the time to add an idea.

    -Josh

    Here's a little cast of the screen.

    There is a small blunder that grep change should have been made before the text of the amendment.

  • script to replace a paragraph style with a different styles, both within a folder

    I am trying to write a script that will remove a paragraph style or character and then replace it with another paragraph or character style, both are in a folder within these groups of style. I have tried so many different scripts and that you have not found the right combination to work.

    any help would be greatly appreciated! Thank you!

    To target a paragraph style that is in a folder, you will have to tunnel to him through groups of styles, thus:

    Style1 = app.activeDocument.paragraphStyleGroups.itemByName("Group1").paragraphStyleGroups.itemByN ame("Group2").paragraphStyles.itemByName ("myParagraphStyle");

    Then find the second style (one you want to replace by):

    Style2 = app.activeDocument.paragraphStyleGroups.itemByName("GroupA").paragraphStyles.itemByName ("AnotherParaStyle");

    Simple and then remove the first style, replace it with the second:

    Style1.Remove (Style2);

    HTH,

    Ariel

  • script to duplicate the standard paragraph style, and then change the size of the character point

    I want to create a script that will create a cascade of paragraph based on the style settings [standard paragraph] styles. My goal is to point size of each new paragraph style character as a percentage of the original [standard paragraph]. So if [standard paragraph] is 100% (point character size 10pt), the script would create a paragraph style called 120% ' that has a point size of character of 12 points. Then 133%, 140%, and on and on. I modified a script found on this forum to generate these new styles, but I don't know how to be based on the [standard paragraph]. Any help would be much appreciated, thanks in advance.

    current script:

    var doc = app.activeDocument,

    pStyle = ['100% ', '120% ', '133% '];

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

    {

    If (pstyle [i] is "100 %")

    {

    doc.paragraphStyles.add ({name: pstyle [i], appliedFont: 'Deer', pointSize:10});})

    }

    ElseIf (pstyle [i] == "120 %")

    {

    doc.paragraphStyles.add ({name: pstyle [i], appliedFont: "Deer", pointSize:10 * 1,2})

    }

    ElseIf (pstyle [i] == "133 %")

    {

    doc.paragraphStyles.add ({name: pstyle [i], appliedFont: "Deer", pointSize:10 * 1.33333})

    }

    }

    Try this,

    var doc = app.activeDocument,
        pstyle = ["100%", "120%", "133%" ];
    
    for(var i =0;i
    

    Kind regards

    Cognet

  • Scripts to insert metadata automatically to the document with the paragraph style

    Hello

    I am trying to find a way to insert automatically the metadata in my document through paragraph style in indesign cs5.5.

    It comes to myDocument title, author name , and description of myDocument.

    Is there anyone who can help me with this project?

    Thank you.

    Place the script at the following location: C:\Program Files\Adobe\Adobe InDesign CS6\Scripts\startup scripts

    If you close it document the script will automatically put the metadata in your indesign file (use ctrl + w or menu-> file-> the option close to close the file)

    Code:

    #targetengine session

    If you want to test the script for your active document, comment on the threshold of another, copy the script to your startup folder

    app.menuActions.itemByName ("Close").eventListeners.add ("beforeInvoke", function()

    {

    myDoc var = app.activeDocument;

    var docTitleText ="";

    var docDescripText ="";

    app.findGrepPreferences = app.changeGrepPreferences = null;

    app.findGrepPreferences.findWhat = '. +';

    found = app.activeDocument.findGrep (true);

    for (j = found.length - 1; j > = 0; j-)

    {

    var foundText = .silence found [j];

    You can set several style of paragraph for the title of the Document

    if(found[j].texts[0].appliedParagraphStyle.Name=="docTitle1")

    {

    docTitleText = found .silence [j];

    }

    of other if(found[j].texts[0].appliedParagraphStyle.name=="docTitle2")

    {

    docTitleText = docTitleText + "" + found .silence [j];

    }

    of other if(found[j].texts[0].appliedParagraphStyle.name=="docTitle3")

    {

    docTitleText = docTitleText + "" + found .silence [j];

    }

    You can define several paragraph of Description of Document style

    of other if(found[j].texts[0].appliedParagraphStyle.name=="docDescription1")

    {

    docDescripText = found .silence [j];

    }

    of other if(found[j].texts[0].appliedParagraphStyle.name=="docDescription2")

    {

    docDescripText = docDescripText + "" + found .silence [j];

    }

    of other if(found[j].texts[0].appliedParagraphStyle.name=="docDescription3")

    {

    docDescripText = docDescripText + "" + found .silence [j];

    }

    }

    with (myDoc.metadataPreferences) {}

    author = "My Name";

    documentTitle = docTitleText;

    Description = docDescripText;

    }

    });

    Vandy

  • Script for Indesign find paragraph style change at the table with the table style

    Hello

    I hope someone could help me with a script.

    I can tab with a paragraph style and I want to convert that to a table with a table style.

    Kind regards

    Patrick

    Yes

    My problem is solved

    Thank you very much.

    Patrick

  • I need help to write a script that detects the first instance of a paragraph style and then change

    I need help to write a script that detects the first instance of a paragraph style and then he goes to a different paragraph style.  I don't necessarily need someone to write all this, by the biggest problem is to find how to find just the first instance of the paragraph style.  Any help would be greatly appreciated, thank you!

    Hello

    then try this with your active doc:

    ....................

    myDoc var = app.activeDocument;

    mStyle var = myDoc.paragraphStyles.item ("PS_NameToFind"); change the name to paraStyle

    var mStyle_1 = myDoc.paragraphStyles.item ("PS_NameToChange"); change the name to paraStyle

    var mFrames = myDoc.pages.everyItem ().textFrames.everyItem () .getElements ();

    app.findTextPreferences = null;

    app.findTextPreferences.appliedParagraphStyle = mStyle;

    for (var k = 0; k)< mframes.length;="">

    {

    currFound = mFrames [k] .findText ();

    If (currFound.length > 0)

    currFound [0] .paragraphs [0] .appliedParagraphStyle = mStyle_1;

    }

    app.findTextPreferences = null;

    ................

    Rgds

  • Script for grep that looks for the B of paragraph style paragraph style

    Hello

    I am fairly new to scripting in Indesign, and I ran across something I want script that I do not know how. Among the paragraph styles that are in our files are Normal and song. I need to add an extra paragraph return between all instances of normal followed by a song. I tried to search the forums to see if what was already here somewhere, and if it is I didn't come through it. I want to implement in the form of script grep, but if anyone has another way to do it, I would like to know also.

    Thanks in advance

    Hello

    For example, you can use a script.

    I guess a block of text with a correct history is selected and the history is in a setting or related frameworks.

    ....

    monarticle = app.selection [0] .parentStory;

    If (myStory.constructor.name! == 'Story')

    {

    Alert (' select a destination text block, then try to pls\rand ");

    Exit();

    }

    myNormal = app.activeDocument.paragraphStyles.item ("Normal");

    mySong = app.activeDocument.paragraphStyles.item ("Song");

    app.findTextPreferences = null;

    app.findTextPreferences.appliedParagraphStyle = mySong;

    mFound = myStory.findText ();

    Len = mFound.length - 1;

    If (len > = 0)

    While (len)-

    {

    currPara = .paragraphs mFound [len] [0];

    If (.appliedParagraphStyle myStory.paragraphs.previousItem (currPara) is myNormal)

    currPara.insertionPoints [0] .silence = "\r";

    }

    ...

    Rgds

  • Script to create an example of each paragraph Style?

    Hi all

    Has anyone seen a script that generates an example of all the paragraph styles that are loaded into a document (the name of actual paragraph style as style would be a plus)?

    I have a script to export all paragraph style settings, but it would be nice to show all my co-workers who are preparing to move to INDD what each style looks like actually. It would also eliminate all duplicate with different names.

    Thanks in advance!

    Ah there was he: http://forums.adobe.com/thread/922205?tstart=30

  • Script of the current paragraph style

    Can someone tell me what is the code to return the paragraph style for the current position of the cursor.

    Also I can I ask something to the current paragraph is not using paragraph styles.

    For example, what would be the code to "make the current text of paragraph Red.

    Help would be much appreciated as we see questions that I'm a complete Newbie in scripting.

    if (app.documents.length > 0 && app.selection.length === 1 && app.selection[0].hasOwnProperty("baseline")) {
         // return the paragraph style for the current cursor position
         alert("Paragraph style: " + app.selection[0].appliedParagraphStyle.name);
         // Make current paragraph text Red (the 1st paragraph in the selection)
         app.selection[0].paragraphs[0].fillColor = "C=15 M=100 Y=100 K=0";
    }
    
  • 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 .

  • Change the font in the Style Script of paragraph?

    Does anyone know if there is a script to go through paragraph Styles and change the font of the other?

    Also, when it is to reduce the size of police/leader at the same time, or in two separate scripts, which would be sweet utra.

    Thanks to all those who can help in advance.

    littlemookie

    I don't know if there's a script to do this, so one here that I just did to the top. This is assuming you are using CS3 (you don't mention a version), and there are small differences between the versions of ID, so he can't run right now.

    for (var i = 2; I have
    {
    app.activeDocument.paragraphStyles [i] .appliedFont = "Helvetica";
    app.activeDocument.paragraphStyles [i] .pointSize * = 0.80;

    If (app.activeDocument.paragraphStyles [i] .leading! = Leading.AUTO)
    app.activeDocument.paragraphStyles [i] .leading * = 0.80;
    }

    "It ignores the 2 first paragraph styles because those who are"[none]"and [standard paragraph]", and apparently, it's bad karma to mess with those.

    The first line inside the loop simply sets the font. An additional style specifier (for example, 'Normal', 'Bold') is left out because you have something already there. Notice that if you try to change "Helvetica-Bold" for, say, a Frutiger, it will not be correct first time round - Frutiger is not "" BOLD"," it's called "" 65 BOLD"" for this family. Well, you can't all win'em.

    The second line takes the current set point size and multiplies it with 0.80, resulting in a new size of 80% of the previous.

    Lines possible 3rd & 4th first test for a complication. If your leader is set to automatic, you don't have to make it smaller (even worse: JavaScript code tries to multiply Leading.AUTO 0.80 and will be the bomb out with an error). Only when the value to a value fixed, it will reduce to 80%.

  • Script Export single Pages with the name and file custom paragraph Style?

    I have a document called "mydocument".

    I have a several pages in the document.

    Each page has a title of"style with a stylesheet called point title.

    I need to export each page as individual .jpg with a custom file name

    myDocument-01 - title.jpg

    01 is the page number

    Seemed like a simple request... but it turns out that it's a little challenging.

    This scipt below, that I found on another thread a little work

    It gives me a

    Title1.jpg

    But I can't figure out how...

    1. Add the name of "mydocument".

    2. have a 0 on the 1-digit numbers

    Can someone please guide me, I would be eternally grateful.

    if (app.documents.length != 0) {
         var myDoc = app.activeDocument;
        MakeJPEGfile();
    }
    else{  
         alert("Please open a document and try again.");  
    } 
    
    
    function MakeJPEGfile() { 
    
    
    
    
    
    
         for(var myCounter = 0; myCounter < myDoc.pages.length; myCounter++) {
    
              if (myDoc.pages.item(myCounter).appliedSection.name != "") {
                   myDoc.pages.item(myCounter).appliedSection.name = "";
              }
                
                var myPageName = myDoc.pages.item(myCounter).name;
              var myJpegPrefix = "";
              var isStyleExist = true;
    
              //Checking the existing of the paragraph style (filename)
              try {
                  myDoc.paragraphStyles.item("title");
              }
              catch (myError) {
                  isStyleExist = false;
              }
    
              if (isStyleExist)
    
    
              myJpegPrefix = getParagraphContent(myDoc.paragraphStyles.item("title"), myDoc.pages.item(myCounter)) + myPageName;
              app.jpegExportPreferences.jpegQuality = JPEGOptionsQuality.high; // low medium high maximum
              app.jpegExportPreferences.exportResolution = 72;
              app.jpegExportPreferences.jpegExportRange = ExportRangeOrAllPages.exportRange;
              app.jpegExportPreferences.pageString = myPageName;
    
    
              var myFilePath = "~/-client/JOYS - Just Organize Your Stuff/-Art/-art-book-kindle/" + myJpegPrefix + ".jpg";
              var myFile = new File(myFilePath);
              myDoc.exportFile(ExportFormat.jpg, myFile, false);
         }
    }
    
    
    // The new function, but needs to add checking the file name rules.
    
    
    function getParagraphContent (paragraphStyle, currentPage)
    {
        var paragraphContent = null;
        for (var c = 0; c < currentPage.textFrames.length; c++)
        {
            for (var i = 0; i < currentPage.textFrames.item(c).paragraphs.length; i++)
            {
                if (currentPage.textFrames.item(c).paragraphs.item(i).appliedParagraphStyle == paragraphStyle)
                {
                    paragraphContent = currentPage.textFrames.item(c).paragraphs.item(i).contents;
       // Remove spaces and returns at the end:
                    paragraphContent = paragraphContent.replace(/\s+$/, '');
       // Replace remaining spaces with hyphen:
                    paragraphContent = paragraphContent.replace(/\s+/g, '-');
       // Make lowercase:
                    paragraphContent = paragraphContent.toLowerCase();
                    return paragraphContent;
                }
            }
        }
        return paragraphContent;
    }
    
    

    Thank you Mi!

    One more step.

    I just need to remove the extension .indd.

    My file name is now

    myDocument.indd - 01 - title.jpg

    If (app.documents.length! = 0) {}

    myDoc var = app.activeDocument;

    MakeJPEGfile();

    }

    else {}

    Alert ("Please open a document and try again.");

    }

    function MakeJPEGfile() {}

    for (var myCounter = 0; myCounter< mydoc.pages.length;="" mycounter++)="">

    If (. appliedSection.name myDoc.pages.item (myCounter)! = "") {}

    myDoc.pages.item (myCounter).appliedSection.name = "";

    }

    var myPageName = myDoc.pages.item (myCounter) .name;

    var myJpegPrefix = "";

    var isStyleExist = true;

    Audit of the existing paragraph style (filename)

    try {}

    myDoc.paragraphStyles.item ("title");

    }

    {} catch (MonErreur)

    isStyleExist = false;

    }

    If (isStyleExist)

    myJpegPrefix = getParagraphContent (myDoc.paragraphStyles.item ("title"), myDoc.pages.item (myCounter)) + '-0 "+ myPageName;

    app.jpegExportPreferences.jpegQuality = JPEGOptionsQuality.high; low medium high maximum

    app.jpegExportPreferences.exportResolution = 72;

    app.jpegExportPreferences.jpegExportRange = ExportRangeOrAllPages.exportRange;

    app.jpegExportPreferences.pageString = myPageName;

    var CheminMonFichier = "" ~/-client/JOYS - just organize your Stuff Art / /-art-book-kindle / "+" / "+ myDoc.name +"-"+ myJpegPrefix +".jpg";

    var myFile = new File (myFilePath);

    myDoc.exportFile (ExportFormat.jpg, myFile, false);

    }

    }

    The new feature, but it will add filename rules checking.

    function getParagraphContent (paragraphStyle, currentPage)

    {

    var paragraphContent = null;

    for (var c = 0; c)< currentpage.textframes.length;="">

    {

    for (var i = 0; i)< currentpage.textframes.item(c).paragraphs.length;="">

    {

    If (currentPage.textFrames.item (c).paragraphs.item (i) .appliedParagraphStyle is paragraphStyle)

    {

    paragraphContent = currentPage.textFrames.item (c).paragraphs.item (i) .silence;

    Remove the spaces and returns at the end:

    paragraphContent = paragraphContent.replace (/ \s+$ /, ");

    Replace the remaining spaces with hyphen:

    paragraphContent = paragraphContent.replace (/ \s + / g, '-');

    Make lowercase:

    paragraphContent = paragraphContent.toLowerCase ();

    Return paragraphContent;

    }

    }

    }

    Return paragraphContent;

    }

  • Use GREP to apply paragraph styles, character styles not only

    I have a body of text, and in it, I would like to apply a specific style to the paragraphs corresponding to a model. I did a GREP style that applied some changes formatting of paragraphs, I tried that it affects, but in doing so, I found that I couldn't Center these lines using a character style. (The corresponding lines should be centered, and the rest should be left aligned.)

    I was thrilled to learn that the GREP function, then completely disappointed with this limitation. InDesign offers the possibility to automate this, so I must not cross and Center each paragraph corresponding to the hand?

    Thank you!

    InDesign provides a way to automate this so?

    Yes and no. There is no dynamically linked paragraph styles to a paragraph about his boss, but he has at least two alternatives:

    (1) use Grep-F/C

    (2) use the script FindChangeByList or MultiFindChange which is basically automate operations F/C

    HTH

    Loïc

Maybe you are looking for