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

Tags: InDesign

Similar Questions

  • 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

  • Is it possible to automatically check the paragraph Styles?

    Changes to a paragraph style are indexed with a star. That shows you where the styles are not applied correctly - as long the cursor is in this line or paragraph.

    But is there a way to index changes automatically? As you can for example check and index wrong spelling by the correction tools or the low resolution of preflight...?

    To show all the "bad points" without clicking on each paragraph.

    You can create a custom preflight profile to check text replacements: InDesign help | Preflight files before transfer. The property that you want to check is 'Text', then 'Paragraph Style and character Style overrides'. Be sure to turn off all other controls, because they slow down the whole process.

    To check if all paragraphs will have a style assigned, search for [no paragraph Style]: InDesign help | Find/replace, scroll down to find and edit the text in the shape.

  • Impossible to format document with several paragraph styles and notes

    I'm working on a document where I have several text boxes on the same page. The text boxes reflect implemented different paragraph styles so that they will autopopulate in my table of contents. However, I need to add notes to this document. I find that the notes are at the end of the text box to which they apply to, and if I had to put a note in two different text boxes on the same page, both start at 1.

    Is it possible to manage notes in several text boxes? Or, if not, is it possible that I can attach my table of contents for the styles of characters instead of paragraph styles?

    Thank you!

    Looking at your screen shot in post #2, I see no reason to require individual images. You can manage every bit of this formatting in a unique setting using the styles section to control alignment, and dashes.

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

  • 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)
    
  • 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!

  • 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

  • Apply the Master Page by using the paragraph Style

    Hi all

    I am a beginner in the script. Learn the script through tutorials cs3 scripts.

    According to the paragraph style it automatically applies the master page.

    For example:

    Paragraph style = "CT".      To apply the Master Page = 'A-Master '.

    Paragraph style = "PT";       To apply the Master Page = "B-Master".

    These are the lines I'm working on:

    myDocument var = app.activeDocument;

    var myPStyles = myDocument.paragraphStyles.everyItem () .getElements ();

    myPage var = myDocument.pages.everyItem () .getElements ();

    for (i = 0; i < myPStyles.length; i ++)

    {

    If (myPStyles [i] .appliedParagraphStyle is "CT")

    {

    .appliedMaster myPStyles [i] = 'A-master. "

    }

    }

    Where I have error. Can someone help me solve this problem.

    Thanks in advance engineering...

    Try this one,

    var myDocument = app.activeDocument;
    var myParas = myDocument.stories.everyItem().paragraphs.everyItem().getElements();
    var myPage = myDocument.pages;
    for(i=0; i
    

    Good luck...

  • error: application of fonts on the paragraph style

    Hi all

    I am facing a problem while applying fonts on the paragraph style. Below are my code.

    If (myDoc.paragraphStyles [a].appliedFont.name == "Helvetica Neue Light")

    {

    myDoc.paragraphStyles [a] .appliedFont = "Helvetica Neue LT Std";

    " myDoc.paragraphStyles [a] .fontStyle = ' Light 45."

    }

    The error is "police family is not available." asked but the fonts installed correctly and works well even if I do a request manually.
    If I apply the Light "Helvetica Neue Std 45" police anywhere in my (manual) document only once and run the script, and then his job very well.
    Where is problem?
    Any suggestion.
    Thank you
    Shonky

    The problem is, you can not apply "" Helvetica Neue LT Std"because you do not have a 'Light' in this font style; and you can't apply the style

    'light 45' first because you do not have a "Helvetica Neue 45 Light!

    That's what they call a classic "Catch 22" situation. Fortunately, there's another way: you can apply two fonts and style in a single command:

    app.activeDocument.paragraphStyles [2] .appliedFont = 'universe LT\t45 Light ';.

    (Note the font character and style tab inbetween family).

    Very irritating, it's your way to work when applied to the text, instead of a paragraph style. for a moment, you will get a pink text in the 'police' [Helvetica Neue 45 Light], and when you apply just the style, all is well again.

  • Cannot find the paragraph styles

    When I create a table, the text style sometimes as "Table Style 2" in paragraph styles section but but when I click on the triangle to the list of different styles, he is nowhere to be seen. "" I'm new on this so sorry if it's something obvious but is there more models on the list of those that appear immediately and if yes how do for them?

    Using Pages on El Capitan 10.11.1 v5.6.1. When I insert a new table, the Table Style 2 paragraph Style is visible in the text: Style tab. Click on the triangle produces a rollout with the list of paragraph Styles. I can't reproduce the problem you describe.

  • 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

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

  • 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

  • Uninstalled wireless on X 200 24F (PSPBUE) with Windows XP

    Hello everyone,I recently installed Windows Xp Pro on my laptop Toshiba X 200 24F (model PSPBUE), after installation I have updated the system to Service Pack 3 for all devices have been identified by the system, so everything works but the wireless

  • Adjustment of curve using Levenberg-Marquardt algorithm

    Hi all Thank you for my request answered in the last post. One thing I like about Labview is its ability to allow complex models to be fitted to experimental data with so much ease. I have been using the L - M unconstrained editing for some time. How

  • Remove Smartphones blackBerry 9900 - multi-mail?

    Hello: New to Smartphones... so many questions Once the email is set up & he pulls in all these emails, it took me a while to realize that I had to remove all Although it is good to have the delete option on: box mailbox & Handheld, or any handheld.

  • VPN and DMZ problem

    I have an ASA 5510 with active VPN for remote access service. Users can log in and access inside resources without problem. the question is the servers in the DMZ, as the web server, they cannot access. Is there an easy way to allow access for users

  • ASA remote VPN with DHCP failed

    I am running a version 8.3 ASA5540 (2). I have several deletion of vpn users working on this server. Lately, I have had problems with people starting or being not not able to route any where and it seems to be cause that they fight for the same IP ad