Graphic object based on the paragraph Style style?

I just checked the documentation of the API and saw nothing on the point about this.

Is it possible to write a script that applies a Style object to a jpg image based on the paragraph Style applied to this image jpg online online?

Hello

I did the following:

var curDoc = app.activeDocument;

app.findGrepPreferences = app.changeGrepPreferences = null;
app.findGrepPreferences.findWhat= "~a";
var allFounds = curDoc.findGrep();

for (var i = 0; i < allFounds.length; i++) {
  var curFound = allFounds[i];
  if (curFound.allGraphics.length > 0) {
    var pStyleName = curFound.paragraphs[0].appliedParagraphStyle.name;
    if (pStyleName == "paraStyle") {
      var rect = curFound.rectangles[0];
      rect.appliedObjectStyle = curDoc.objectStyles.itemByName("myStyle");
    }
  }
}

Kai

Tags: InDesign

Similar Questions

  • How to apply an object style based on the paragraph style?

    Having a job where a single page with a frame of 3 columns is repeated many times.

    (He is always alone and behind a title page)

    But this system is not very good if the text follows... Formatting is lost.

    Of course, anchored frames should be a solution but I could prefer to apply a definition of the structure of text (just the 3 columns) with the f/change of menu:

    My page 3 columns that have a style always will be, this definition of the image.

    In anchored frames, insert a return to get on the next page is by default?

    Why you do not use * Span/Split columns * in your paragraph styles?

  • How to change the paragraph style to each paragraph that contains only one anchored object?

    Hello

    I have a document in word that should be converted in indesign. The document contains instructions, each step followed by an image.

    I managed to import the document into Indesign and applied a paragraph with numbering style to everything (text, image).

    Now, how do I change the the paragraph style to each paragraph that contains only an image? I need to get rid of the numbering.

    Thanks in advance.

    If the images are all anchored objects, you can use find/replace to find the anchor point and change the paragraph style only once for all paragraphs.

  • 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 .

  • Insert a blank space in the paragraph style?

    Is it possible to integrate a white space inserted (en character) in a paragraph style?

    I created a paragraph to chapter headings style. Chapter and number are centered horizontally on the page with a thick end line (key) on each side - a little like that, except that I use the dashboard to create the line in this example:

    -------------------------------------  Chapter 2  ------------------------------------

    Inserted white spaces before and after 'Chapter 2'.  However, when I try to apply the paragraph style to another title, the spaces are not there.

    (Line thin thickness was created as text underscore and the offset is vertically centered with the text.  It would make a difference if I created the thick end line in the form of a graph?)

    Oh and I also tried to create an object style, but it does not recognize spaces, either.  I know that something will work, but little by little learning has not met yet the solution.

    Thank you.

    Do it like this:

    1 make the high line a paragraph above net. Assign the 'Column' width (full) and set its vertical offset in right position.

    2. Add a paragraph below NET. Together, this upright even shifted, but makes a little (or a lot) more thick. Set its color [Book]. Set the width of 'Text', not 'column '. Then set the negative value of the width approx. white space you want on the left and right - something like 'mm-2' the left indent and right.

    3. you're done!

  • Problem with the paragraph style "paragraph NET."

    I have a paragraph style with a paragraph in her net. There is something that I don't know what to do about it.

    When I hit 'back' to move a paragraph with this style, it leaves a rule in its wake. Here is a screenshot:

    Screen shot 2010-08-15 at 9.58.04 AM.png

    The title "Introduction" has a paragraph with a net of applied paragraph style. I put the cursor just before the word 'Introduction', press return, and it leaves a line in the previous line. Weird huh?

    Don't use not paragraph refers ALWAYS to put in place a space between paragraphs. Use the space before or after the space in the paragraph in withdrawal and spacing Style.

    If it's the beginning of a block of text and you want it to appear lower in the frame adjust them the object > text frame Options and give him a Medallion from the top. OR this way http://indesignsecrets.com/push-down-the-first-line-of-text.php

    The line of paragraph appears is because when you press back the paragraph he the same paragraph style, ergo the same paragraph style. To get rid of it, change the paragraph style from the paragraph above to something else.

    But you shouldn't really use back to add a space between paragraphs. Space before and after the space are much more effective.

    http://blogs.Adobe.com/indesigndocs/2009/05/5_typing_rules.html

    http://creativementor.com.au/adding-space-after-paragraphs

    http://help.Adobe.com/en_US/InDesign/6.0/WSa285fff53dea4f8617383751001ea8cb3f-6dcea.html

  • How to insert an ellipsis in the paragraph style?

    Hi all

    In the paragraph style, how to insert the selection to the last paragraph symbol.

    Please someone help me solve this problem.

    I have attached the screenshot of the sample. Like that, I have to insert "selection" symbol (three points) in the indesign paragraph style options.

    ellipse.jpg

    Very simple to do this, follow these steps

    1. double click on the paragraph style if you created (if this isn't the case create a new paragraph style, see the image)

    2. in paragraph style options, choose paragraph nets and do all the settings, see the image

    Hope this will help you

    Thank you

  • Balls, created in the paragraph style options in Indesign

    Hi all

    In the paragraph style, how to create bullets before the text and after the text also.

    Please someone help me solve this problem.

    I have attached the screenshot of the sample. Like that, I must create in indesign paragraph style options.

    Capture.JPG

    Thank you...

  • How to get the paragraph style menu to detach?

    I wish that the paragraph style menu to behave the way the menu character, that is, as its own independent box. Crazy me a little tied to any "other Panel" - no matter what the name of this Panel, it's that it is attached to.

    Thank you very much!

    Just drag it off the coast in the page.

  • How to set auto resulting in the paragraph style?

    Hello

    I give auto driving the paragraph style. Hux to use 'kTextAttrAutoLeadBoss'.

    Everyone please help.

    Kind regards

    Garza

    Hi Nicolas,.

    in the documentation of IDrawingStyle it says:

    Values less than zero is considered to be 'auto '.

    Hope that helps.

    Markus

  • How to delete, modify or rename/available/imported/defined existing chips and lists numbering in the paragraph style?

    How to rename, delete or change lists in the chips section and numbering in the paragraph Style?

    Screen Shot 2015-05-02 at 13.40.00.png

    Open you select paragraph from the option panel (icon at the top right corner) sets the list (below). Or change the selected list bullet in the bullets & numbering

  • Color of the paragraph Styles is not overridden CS5.5.

    I have some documents and I have a few Styles to paragraph (PStyles) I load in the latest documents.

    I have some who are in fact PStyles within a Table. 2 small problems; I can live with the first:

    1. It does not actually load the PStyle formatted correctly;
    2. Once I have format the PStyle as I want, the PStyle coloring does not replace the text that I assign. For example I have orange text, I then choose PStyle 1 (orange), the font is changed to the correct font type but the color does not change.

    It is certainly a fault?

    Make sure that all of the text in the paragraph of style [none] has also defined as the style of his character. You could have a paragraph style with the filling of text defined on orange and a character style with a black fill applied to all the words in the paragraph. In this case, the text would be black.

    Alternatively, you can substitute the paragraph styles. If this is the case when the text is selected, a + sign appears in the paragraph Styles Panel, next to the name of the style.

  • Where is the paragraph style tools in Indesign CC2014?

    Hello! I just started to use IDs through creative cloud on a new computer (using CC CS6 for two years), and the installer gave me rather than CS6 CC2014. So it is a question only on CC2014.

    Where is the window paragraph styles? Specifically, how can I edit, create and organize the paragraph styles, and how do I get a window up on the main screen with all stated styles? All these things were easy to find in CS6, but I can't find them in CC2014. The only thing I get (and with a bit of customization). is a drop-down list on the main toolbar, which allows me to choose from among the existing options on an existing document.

    There is no option of paragraph Windows Styles > Styles.

    There is no option under Type of paragraph Styles.

    The only paragraph window that appears is designed for text editing as you go along, don't not to apply styles.

    Using the options all point me back them to the entrance for CS6 and tell me to go to Type > paragraph Styles (which does not exist).

    I can't get a window up on the main screen to instantly apply styles in a list. I only get this drop, which has no other options.

    Can someone tell me some updated guidance or explain where all paragraph options are and how do I use them? If not, can I go back to CS6? It was easy and intuitive on the front, and now it's not...

    Thank you!

    Nothing has changed on the styles. It's exactly the same thing as CS6. Perhaps you need to restore your preferences.

  • Modify the paragraph Style Export Options of marking

    I'm having a devil of a time trying to get the "Split Document (EPUB only)" box checked for certain styles. I was hoping a perhaps experienced scripter be able to help me solve what I am sure is an easy solution.

    Below is my code snippet:

    var doc = app.activeDocument;

    var par_styles = doc.paragraphStyles.everyItem () .getElements ();

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

    par_styles [i].styleExportTagMap.splitDocument = true;

    };

    In this example, I would get the Document Split box ticked for each paragraph style in my document. However, apparently the paragraph style does not support the class 'styleExportTagMap', which is the only place where I found that the property 'splitDocument' lives.

    I guess that my ignorance is not knowing exactly what made the class styleExportTagMap (s).

    Could someone point me in the right direction?

    Looks like a hack, but it works.

    var
        doc = app.activeDocument,
        par_styles = doc.allParagraphStyles,
        i = 0;
    
    for ( i ; i < par_styles.length; i++ ) {
        par_styles [ i ].styleExportTagMaps.add ( "", "", "", "" ).splitDocument = true;
    }
    

    Hope that helps.

    --

    Marijan (tomaxxi)

    http://tomaxxi.com

  • How can I count the appearance of the paragraph style "H1" used in an .indd document?

    How can I count the appearance of the paragraph style "H1" used in an .indd document?

    OS: 10.8

    CS6

    extend the script

    Hello

    must be sth. like...

    pStyleNameToFind = 'Grundtext';;//Your pStylename here
    
    app.findTextPreferences  = app.changeTextPreferences = NothingEnum.NOTHING;
    
    app.findTextPreferences.appliedParagraphStyle = app.activeDocument.paragraphStyles.itemByName(pStyleNameToFind)
    
    var pHits = app.activeDocument.stories.everyItem().paragraphs.everyItem().findText();
    
    var counter = 0;
    for(var i = 0; i < pHits.length; i++)
    {
        if(pHits[i].length != 0) counter = counter +1
        }
    
    app.findTextPreferences  = app.changeTextPreferences = NothingEnum.NOTHING;
    
    alert(counter +  ' of ' + pHits.length + ' paragraphs in active Document are formatted with paragrahstyle ' + pStyleNameToFind)
    

Maybe you are looking for

  • New BIOS and old drivers Satellite a series

    Hello. old drivers work under the new BIOS?

  • Compaq dc7100SFF: PC refuses to start

    Hello Yesterday the Unit indicates that the CMOS battery was almost exhausted, but I checked that and it is still showing 2.9 volts. While the envelope was opened, I blew some dust/lint, I could see without disturbing all the components out of the ba

  • BlackBerry Smartphones need help with resetting the voice message counter

    Recently, I moved the United States in India and brought with me my favorite Storm 9530. In the United States, I had Verizon as my career and I went to Vodafone in India. Prior to joining Vodafone, he had 5 posts not read/unheard voices and so my Sto

  • How to block another user

    I get spam in my pm Inbox communities.vmware.com.  I can't find how to block this user or report of the msger h itself.  Is there a feature to do?  I took 1 spam to the "moderator".  Is it the right place to send it?

  • Forms are empty once downloaded, even if they are already full.

    I'm having a problem with Adobe Acrobat Reader does not download a form which is in PDF format which is already filled. I have security settings changed under the edict falling down, but the forms are still being downloaded is not filled in.