Paragraph to textFrame or Rectangle text

Please help, I am really stuck. I have a bunch of classified ads (each is a Paragraph) in three columns (each is a textFrame). I have no control over the foregoing. For each paragraph starting with "##", I need to remove the "##" (this part is easy) and cause the background color of an imaginary rectangle behind the paragraph to be yellow. I get stuck because I do not know how to get the position and height of the paragraph so that I could create a rectangle or a textFrame. An additional requirement is that the Editor (working in InDesign) be able to move the paragraph around along with its yellow background as a single object. Any help would be appreciated.

Hi,
Exam this code:
// BEFORE start ==> place cursor inside target textFrame or select this textFrame
var
  mDoc = app.activeDocument,
  mStory = app.selection[0].parentStory,
  paraStyleToTable = mDoc.paragraphStyles.item(0),     //     basicPara for now or modify
  mStrokeColor = mDoc.swatches.item(3),     //     3 - is an index, name of swatch can be used as well
  mFillColor = mDoc.swatches.item(6);
  app.findGrepPreferences = app.changeGrepPreferences = null;
  app.findGrepPreferences.findWhat = "^##";
var
  mFound = mStory.findGrep(),
  len = mFound.length,
  currPara, currTable;
while (len-->0) {
  currPara = mFound[len].paragraphs[0].characters.itemByRange(0,-2).texts[0];
  currTable = currPara.convertToTable()[0];
  currTable.cells[0].contents = currTable.cells[0].contents.replace(/^##/,"");
  currTable.storyOffset.appliedParagraphStyle = paraStyleToTable;
  mFormat(currTable);
app.findGrepPreferences = app.changeGrepPreferences = null;
// modify existing properties or add a new one to specify
function mFormat (thisTable) {
  with (thisTable.cells[0]) {
  bottomEdgeStrokeColor = mStrokeColor;
  leftEdgeStrokeColor = mStrokeColor;
  topEdgeStrokeColor = mStrokeColor;
  rightEdgeStrokeColor = mStrokeColor;
  bottomEdgeStrokeWeight = 0.5;     //    cell's strokeWeight to modify
  leftEdgeStrokeWeight = 0.5;
  topEdgeStrokeWeight = 0.5;
  rightEdgeStrokeWeight = 0.5;
  bottomInset = 2;
  leftInset += 0;    //    cell's left/right inset inherited from parent para
  topInset = 2;
  rightInset += 0;
  fillColor = mFillColor;
  fillTint = 30;     // tint to modify
Jarek

Similar Messages

  • Can I format a paragraph in illustrator, with multiple text sizes?

    Hi,
    I have a number of paragraphs in illustrator that have the following...
    a title = Arial bold 18 pt.
    body text =Arial reg 14 pt.
    and indents with bullets
    It seems that illustrator only supports one font, size, color, etc. for each Paragraph style. I would like to be able to set the title to Arial bold, 18pt, Blue, and the body text to Arial regular, 14pt, white, with different leadings, within the same style setting. Does anyone know if this can be done?
    Thank you in advance.
    Knewt

    What are you guys talking about? Since when does InDesign support multiple text attributes for a single Paragraph Style? At least in CS3 InDesign's Paragraph Styles have settings for nested Character Styles and drop caps, but you still define one set of text attributes for the Paragraph Style itself.
    In principle it's basically the same in Illustrator. If you want to actually have multiple text treatments in one paragraph, you apply Character Styles to text ranges within the paragraph. Illustrator's implementation of it is pure crap in that inheritance and style redefinition does not work correctly, but the fact remains you certainly can have multiple text treatments in one paragraph, but it is not done with a single Paragraph Style. If using Styles (as you should) it is a matter of nesting Character Styles within paragraphs that have Paragraph Styles applied.
    But I strongly suspect that what Mr. Harley is describing is not really a single paragraph at all. He wants different text sizes, different indents, and bullets. That clearly involves multiple paragraphs.
    Harley, in part of your description of what you want, you seem to be referring to a single textframe object as a "paragraph." A paragraph is a range of text separated by a carriage return. When you define and apply a Paragraph Style, the carriage return defines the range of the Style. When you define and apply a Character Style, the selected range of characters define the range of the Style. You can use multiple Character Styles within a paragraph that has a Paragraph Style applied.
    But you are talking about the need to define several Paragraph Styles to use in one block of text, or "story" (one or several textframe objects). You just need to define three Paragraph Styles:
    Heading: Arial Bold 18 pt.
    Body: Arial Regular 14 pt.
    BodyBullet: Same as Body, but with different indents. Set a tab at the bullet location and at the left indent. (You type your bullet characters; you don't just select "bullets" from a setting.)
    Type all your text, using carriage returns as you would expect. Each carriage return marks the beginning of a new paragraph. (This is as true in Illustrator as it is in InDesign, Word, or anything else.) Click inside a paragraph and apply the appropriate Paragraph Style.
    Now suppose you want to use a convention within your document that emphasizes certain words or phrases by painting them magenta instead of whatever color is defined in the Paragraph Style. Create a Character Style. Name it Emphasis. In that Style, set the character color to magenta. Now swipe across a word in one of your paragraphs and apply the Emphasis Character Style. The whole paragraph still has the Paragraph Style you applied to it. But now the color of a few characters is overridden by the Character Style you have applied to those characters.
    Again, like many things in Illustrator, its implementation of Paragraph Styles and Character Styles is very sloppy compared to other programs. But it is not true that 'InDesign can apply multiple text treatments in a single Paragraph Style, and Illustrator can't.' At least not up to CS3.
    JET

  • Script for search TextFrame whitout full text, and top align...

    This script "JUSTIFY_ALING" all text frames without footnotes:
    var TRUFI = app.activeDocument.textFrames.everyItem().getElements(),
         CHARLY;
    while( CHARLY=TRUFI.pop() )
         if ( CHARLY.footnotes.length == 0)
              CHARLY.textFramePreferences.verticalJustification = VerticalJustification.JUSTIFY_ALIGN;
    But I need that TextFrames whitout full text (for example: the text only go to the middle of the textframe) stay in TOP_ALIGN...
    Thanks for read me... 

    You can't tell right away if a textframe is filled all the way to the bottom. Even with linked text threads, there is usually a small space at the bottom, just not enough for an entire next line -- less than the leading of that next line. There may even be more space at the bottom, if the next frame starts with a heading, which is kept with a number of lines following it; or a large inline table or figure; or a hard page break. Or (come to think of it) a footnote -- I'm not sure what would happen then ...
    But you can get the vertical position of the last regular text line. With a text frame selected:
    alert (app.selection[0].lines.item(-1).baseline);
    will show you the absolute vertical position of that last line. If you need the distance from the top of its containing text frame, use
    alert (app.selection[0].lines.item(-1).baseline - app.selection[0].geometricBounds[0]);
    -- you might remember that the array 'geometricBounds' contains the positions of top, left, bottom, and right corners, in that order. So geometricBounds[0] is the top y position; subtract this from your baseline, and you know how low you go.
    In this case, you would want the distance from the last line to the bottom:
    alert (app.selection[0].geometricBounds[2] - app.selection[0].lines.item(-1).baseline) ;
    w
    will show you how much space there is left. A warning is in place: blank lines are also lines! (Theoretically, if this happens a lot, you could adjust for these. Left as an exercise.)
    All you have to do is ask yourself, what amount of white space at the bottom is allowed? Then check your frames for this, and only apply vertical justification if it's inside your parameters.
    (Apologies for those weirdly cramped final paragraphs. Sorry -- tried to restore it to normal readability, failed miserably. Jive Strikes Again!)

  • How to get rid of paragraph breaks in a lengthy text instead of manually

    I have imported a large piece of text - it is very narrow and has many paragraph breaks I guess you call it - or return breaks. I started doing it manually but it is a nightmare. Is there an easier way to do it? I snooped around and tried a few things but cannot seem to get this to work. I have a lot more work to do. Thanks again.

    Position the mouse pointer after the last printed character of a paragraph. Press the mouse button and hold it while you drag down over several of the empty lines. Release the mouse button. Simultaneously press command+C keys (then release) to copy the selection to the clipboard. Simultaneously press command+F keys (then release) to open the Find&Replace dialog. Click once in the "Find:" window, then press command+V keys (then release) to paste the contents of the clipboard there. Click in the "Replace:" window then press "Return" to enter a single carriage return. Click on the "Replace & Find' button.

  • Newsletter layout, aligning columns, paragraph breaks and lines of text

    HI,
    I have never designed a newsletter before.
    It is annoying me because I am trying to be as meticulous as possible with my alignment, but I notice there are things all over the place that don't line up.
    I have a paragraph style, with space before and after. I have three columns. When I look at one line of text across all three columns, they do not line up. The WOULD line up if I had all straight text and no image wraps, but the image wraps, and the start of a new paragraph in column two, throws off alignment in column three.
    What is the best way to make stuff line up with the least amount of effort possible?
    Are there tutorials on good newsletter layout design? Grid layout?
    Thanks,
    Stan

    I just stated working with InDesign in my GA 101 class. It really was great fun but takes alot of practice. Still learning something new everyday. I  will be working with grids the next class and will be checking in the forum for help.
    Rhonda

  • Via Form using TextBox to insert a Paragraph in the place of text

    I developed a form in VBA in Word but it shows error here, actually i a beginner to macros
    The word "2Details2" to be replace with 5 to 8 line paagraph
    So by searching internet I am doing this, 
    Dim para As Paragraph
        para = TextBox23.Text
        Selection.MoveRight Unit:=wdCharacter, Count:=28, Extend:=wdExtend
        Selection.Copy
        Selection.Find.ClearFormatting
        Selection.Find.Replacement.ClearFormatting
        With Selection.Find
            .Text = "2Details2"
            .Replacement.Text = para
            .Forward = True
            .Wrap = wdFindContinue
            .Format = False
            .MatchCase = False
            .MatchWholeWord = False
            .MatchWildcards = False
            .MatchSoundsLike = False
            .MatchAllWordForms = False
        End With
        Selection.Find.Execute Replace:=wdReplaceAll
    Thanks in advance

    First, you have defined:
    Dim para As Paragraph
    yet you're trying to populate what you've defined as a paragraph object with what appears to be text:
    para = TextBox23.Text
    Second, you're doing a lot of stuff with Selection which is inefficient. In general, you should use range objects instead. Moreover, you have 'Selection.Copy', but it's not apparent that you doing anything with what you've copied to the clipboard.
    It appears your code could be reduced to:
    With ActiveDocument.Content.Find
      .ClearFormatting
      .Replacement.ClearFormatting
      .Text = "2Details2"
      .Replacement.Text = TextBox23.Text
      .Forward = True
      .Wrap = wdFindContinue
      .Format = False
      .MatchCase = False
      .MatchWholeWord = False
      .MatchWildcards = False
      .MatchSoundsLike = False
      .MatchAllWordForms = False
      .Execute Replace:=wdReplaceAll
    End With
    though, other than extending the selection, I don't know what you're trying to achieve with:
    Selection.MoveRight Unit:=wdCharacter, Count:=28, Extend:=wdExtend
    Cheers
    Paul Edstein
    [MS MVP - Word]

  • Anchoring Object to a Paragraph Style? Objects behind text

    Hello,
    I am trying to anchor an graphic object to a paragraph style that is a numbered paragraph.  I have set up my numbering and I want a single graphic to be anchored to the number so it appears behind the number each time I choose that paragrah style.
    Is this possible to do?
    Or perhaps I should ask how other people put graphics behind bullets or numbers and have them anchor to the text...
    I sure could use soem help with this; it seems like it should be easy...
    Dave.

    I found this intriguing, so I thought I'd see what I could come up with.
    I made a numbered paragraph style, to start. Then I made a Cyan filled ellipse, which I anchored in front of the first word in one of the paragraphs, and changed the positioning to custom and made sure it was relative to the anchor, and turned off keep within frame boundaries, to allow me to position it "behind" the number. As emmanuel points out, anchored objects are actually in front of the text, so so far it's not working.
    I selected the ellipse and changed it's blend mode to multiply. This will not change it's color where it is over white, but it will darken wherever it is on top of another color, creating a rich black number, for example, if you used black text. Looks pretty good now.
    Select the ellipse and create a new object style based on it. This will by default include the blend mode and anchored object parameters, and be sure the style is applied to the selected ellipse. Now cut the ellipse and paste it on the pastboard out of the way so you don't lose it.
    As long as the object is on the clipboard you can use it for a find/change operation, so you can do that now, or later, just by copying it again when it's convenient. The find/change needs to be a GREP search for ^(.) which means find any character at the beginning of a paragraph, and replace with ~c$1 which means replace with the formatted contents of the clipboard and the found character. Be sure to set the find formatting options to the numbered paragraph style.
    Because you gave the object an object style that includes the blend mode and positioning, and you pasted it as a formatted object, those attributes are preserved and the graphic will be positioned correctly for each paragraph.
    Peter

  • Paragraph style - Drop shadow on text

    Hi,
    I cannot find out how to apply a drop shadow to text in a paragraph style.
    It looks like drop shadow can only be applied to Object style.
    And object must be selected with selection tool. My text box goes up to 30 pages!
    I don't want all the text with shadow.
    Any help or cue will be appreciated.
    thanks

    Drop shadows can only be applied to all text within a Frame. You will need to separate the paragarphs you want a drop shadow from and Anchor those within the text.
    http://help.adobe.com/en_US/indesign/cs/using/WSa285fff53dea4f8617383751001ea8cb3f-6c43a.h tml

  • Horizontal paragraph rule across two-column text frame?

    Hi,
    as the title suggests, how do i get a horizontal rule to run across a two-column text frame?
    I have either had the rule just apply to the entered text; had a gap where the column gutter is;
    or I have had to set the column gutter to 0mm/px and manually set carriage returns to give the impression of a gutter.
    Surely there is a better way?
    I'll attach a jpeg of my various options.
    Hope I've been clear-enough. All help is appreciated.
    Cheers, Matt

    You can put the rule in a paragraph which is spanning a columns.
    Or you can extend the paragraph rules by inputing minus values to left and right (e.g. -5mm)
    Or you can use a table instead.
    Or you can use negative left and right intend for the text but extend the rule to the end of the frame.
    Never set a carriage return manually.

  • Missing Paragraph Level Tag from the Text drop down

    I am following the first tutorial with Katie's Cafe (written version) and I notice that when I click on Text, I am missing two things in the drop down menu; they are called the Paragraph Level tags.  I downloaded Muse only 7 days ago.  I am using a PC, not a Mac.  What do I need to know or do?  Thanks, Julie

    Hi Julie
    The icon for both fields are changed , so now in Muse you will see another icon for those two fields , "hand pointer on abc" which is text style for hyperlinks and another one is paragraph level tag which you can define selecting the text.
    Please refer to these documents which explains :
    http://www.adobepress.com/articles/article.asp?p=1925239&seqNum=3
    http://tv.adobe.com/watch/learn-adobe-muse-cc/working-with-text-styles-create-a-paragraph- style/
    http://helpx.adobe.com/muse/using/creating-using-character-paragraph-styles.html
    Thanks,
    Sanjit

  • Hard return paragraph breaks at top of text frames

    I'm learning how to do book layouts in InDesign CS4 and I have a problem I can't figure out how to solve. I'm autoflowing huge chunks of pasted text into linked text frames and when a paragraph breaks (with a double hard return) at the same place as a new page/column, there is a blank line on the top of the text frame like so:
    Is there a way to automatically make that paragraph break line go away when it comes at the top of a new text frame? My document is 400+ pages with many, many paragraphs. I don't want to get rid of the hard return spaces between all of them, just the ones that come at the top of text frames.

    To expand slightly, space before and after are ignored at the top of a column or frame, but the empty paragraph is not.
    You might want to try out the "Find/Change by List" sample script which fixes multiple returns along with leading and trailing whitespace and double space after a period (among other common problems). It's really just a chained set of Find/Change operations that can speed up the cleanup of new text.

  • Cant move paragraph from textFrame to another

    what is the problem with the move method???
    <pre>var myDoc = app.activeDocument;
    var myPStmuna = myDoc.paragraphStyles.item("תמונה");
    var myPScomment = myDoc.paragraphStyles.item("הערה");
    for(i=0;i<myDoc.pages.length;i++){
      myPage=myDoc.pages.item(i);
      tf=myPage.textFrames.item(0);
      for(g=0;g<tf.paragraphs.length;g++){
        if(tf.paragraphs.length>0){
          myPara=tf.paragraphs.item(g);
          if(myPara.appliedParagraphStyle == myPStmuna){
            newTF=myPage.textFrames.add();
            myPara.move(LocationOptions.affter,newTF.insertionPoints.item(0));
            newTF.fit(FitOptions.frameToContent);
        }else{
          break;
    }</pre>

    I tried newTF.contents="bla bla..." and it gets into the newTF.
    this is my updated code:
    <pre>var myDoc = app.activeDocument;
    var myPStmuna = myDoc.paragraphStyles.item("תמונה");
    var myPScomment = myDoc.paragraphStyles.item("הערה");
    for(i=0;i<myDoc.pages.length;i++){
      myPage=myDoc.pages.item(i);
      tf=myPage.textFrames.item(0);
      for(g=tf.paragraphs.length-1;g>=0;g--){
        if(tf.paragraphs.length>0){
          myPara=tf.paragraphs.item(g);
          if(myPara.appliedParagraphStyle == myPStmuna){
            newTF=myPage.textFrames.add();
            myBounds = myGetBounds(myDoc,myPage);
            newTF.geometricBounds = myBounds;
            newTF.contents="bla bla\r";        
            myPara.move(LocationOptions.atEnd,newTF);
        }else{
          break;
    function myGetBounds(myDocument, myPage){
    var myWidth = myDocument.documentPreferences.pageWidth;
    var myHeight = myDocument.documentPreferences.pageHeight;
    var myX1 = myPage.marginPreferences.left;
    var myY1 = myPage.marginPreferences.top;
    var myX2 = myWidth - myPage.marginPreferences.right;
    var myY2 = myHeight - myPage.marginPreferences.bottom;
    return [myY1, myX1, myY2, myX2];
    }</pre>

  • Grouping Textframe and rectangle object ID Server CS4

    Below code for simple grouping objects is not working. Since there is not selection in ID Server CS4.
    ID Server CS4
    Vb.net
    Dim FigGp As InDesignServer.Objects
    Dim obj As InDesignServer.Objects
    obj.Add(rect.Index) 'throwing exception Object reference not set to an instance of an object.
    obj.Add(CaptionFrame)
    FigGp = ParentPage.Groups.Add(obj)
    Regards,
    Suresh

    if you upload your bug query here you will get a response,
    https://www.adobe.com/cfusion/mmform/index.cfm?name=wishform
    they will then email you and ask you to send them the file to replicate it,
    have  you tried restarting illustrator or your computer,
    updated to latest version for cs3?
    just couple ideas no doubt you`ve tried,

  • Slanted rectangle behind text - any chance to automate the process?

    Hi there,
    I would like to create effect which you can see on this image:
    The black and orange rectangles behind the capitals. The source which is pictured above comes from professional studio. They put separate rectangle behind the textframe:
    Imagine, that you create a catalog of 500 products. Each product has one black and one color rectangle. There are 20 different color codes for the bottom rectangle (these rectangles vary a bit in length, depending on the size of the text above). I feel putting a square object to the bottom layer like a bit clumsy approach. It is like creating paragraph dividers by Line Tool. Could you recommend some more tidier way for this? I am almost sure, that I will put a thousand of those rectangles to the layout and the client will decide ( a day before print), that "the reversed skew would look more professional"…
    The best way for this would be a Paragraph rule, but — what a surprise — no chance to skew the ends.
    I tried to create the new stroke preset, but no skew options.
    I also skewed the line manually and try to create the Object Style from it. The skew was not inherited by the new Object Style.
    Do I really do this manually in the age of spaceflights, cellphones and even electric tea kettles?
    Thank you!

    Hi all,
    Marc Autret has confirmed me his OK to unveil this great code.
    AjustementMagique.jsx permits a horizontal "scaling", in particular for tables. It works fine with ID CS4 (a very little bug sometimes). Not tested with CS5.
    But ... it does not work under ID CS6, CC and CC 2014!
    Marc gives his blessing to the heroes who would wish to do the update! 
    Enjoy!
    /*      AjustementMagique pour InDesign CS / CS2 -- 18/01/06           */
    /*      version 2.1b (FR) -- auteur: Marc Autret                       */
    /*      Explications : http://marcautret.free.fr/geek/indd/magicfit/   */
    /*      Installation et Utilisation:                                   */
    /*      0) !! Pour InDesign CS2 seulement !!                           */
    /*         Renommez le present fichier avec l'extension .jsx           */
    /*         (afin d'activer les fonctions extend script)                */
    /*      1) Placer le present fichier dans le sous-dossier              */
    /*         Presets/Scripts/ de l'application InDesign                  */
    /*      2) Lancer InDesign, ouvrir un document et selectionner         */
    /*         le(s) elements(s) a ajuster: bloc(s), colonnes(s)           */
    /*         [a defaut, le script ajuste le conteneur du pt d'insertion] */
    /*      3) Executer le script par Fenetre>Scripts>Scripts              */
    /*         suivi d'un double-clic sur AjustementMagique.js             */
    /*         (ou affecter au script un raccourci-clavier via             */
    /*         Edition>Raccourcis-clavier>Zone:"scripts")                  */
    /*      4) Un second appel du script sous un delai de 2 secondes       */
    /*         optimise si c'est possible l'ajustement (mode "fluide")     */
    /*                  Feedbacks : [email protected]                     */
    // REGLAGES
    var LATENCE = 2; // en secondes (defaut: 2)
    var PRECISION = 0.5; // en points (defaut:0.5)
    var APP_INT_VERSION = parseInt(app.version);
    // UTILITAIRES
    /*void*/ function exitMessage(/*exception*/ ex)
    alert("Erreur:\n" + ex.toString());
    exit();
    // METHODES DE LA CLASSE DOCUMENT
    /*void*/ Document.prototype.setUnitsTo = function(/*units*/ newUnits)
    // units est soit une valeur simple (horiz=vert), soit un array(horizUnits, vertUnits)
    var arrUnits = (newUnits.length) ? newUnits : new Array(newUnits,newUnits);
    this.viewPreferences.horizontalMeasurementUnits = arrUnits[0];
    this.viewPreferences.verticalMeasurementUnits = arrUnits[1];
    /*arr2*/ Document.prototype.getUnits = function()
    return(Array(
      this.viewPreferences.horizontalMeasurementUnits,
      this.viewPreferences.verticalMeasurementUnits));
    /*bool*/ Document.prototype.withinDelay = function()
    if (this.label)
      return( (Date.parse(Date())-this.label) <= LATENCE*1000 );
    return(false);
    /*void*/ Document.prototype.storeTimeStamp = function()
    this.label = Date.parse(Date()).toString();
    // METHODES GENERIQUES (NIVEAU OBJECT)
    /*arr*/ Object.prototype.asObjsToFit = function()
    // Retourne le(s) "conteneur(s) ajustable(s)" associe(s) a THIS
    // Type de retour: array OU collection
    // NULL en cas d'echec
    switch(this.constructor.name)
      case "TextFrame" : // textframe -> singleton this
      return(Array(this));
      case "Cell" : // cells -> parent columns
      var r = new Array();
      // !! [CS1] Cell::parentColumn === Cell !!
      // !! [CS2] Cell::parentColumn === Column !!
      // !! [CS2] Cells::lastItem().parentColumn BUG !!
      var c0 = this.cells.firstItem().name.split(":")[0];
      var c1 = this.cells.lastItem().name.split(":")[0];
      for (var i=c0 ; i<=c1; i++)
      r.push(this.parent.columns[i]);
      return(r);
      case "Table" /*CS2*/ : // table -> columns
      return(this.columns);
      case "Group" : // group -> textFrames
      return((this.textFrames.length>0) ? this.textFrames : null);
      case "Text" : // Text ou InsertionPoint
      case "InsertionPoint" : // -> travailler sur le conteneur
      var textContainer = this.getTextContainer();
      return((textContainer) ? textContainer.asObjsToFit() : null);
      default:
      return(null);
    /*obj*/ Object.prototype.getTextContainer = function()
    // Renvoie le TextFrame ou la cellule (Cell) contenant THIS
    // (Text ou InsertionPoint)
    // NULL si echec
    try { // try...catch because of CS2 behaviour
      if (this.parent.constructor.name == "Cell")
      return(this.parent);
      if (this.parentTextFrames) // pluriel sous CS2
      return(this.parentTextFrames[0]);
      if (this.parentTextFrame) // sing. sous CS1
      return(this.parentTextFrame);
      return(null);
    catch(ex) {return(null);}
    /*int*/ Object.prototype.computeIncludedObjectsWidth = function()
    // Analyse les objets incorpores (tables, PageItems) pour extraire
    // la largeur maxi qu'ils occupent
    // Le tableau objsNames peut etre etendu pourvu que
    // l'objet ajoute fournisse une methode computeWidth()
    var objsNames = new Array("pageItems","tables");
    var objsWidth = 0;
    var w = 0;
    for (var j=objsNames.length-1 ; j>=0 ; j--)
      for (var i=this[objsNames[j]].length-1 ; i>=0 ; i--)
      try
      {w = this[objsNames[j]][i].computeWidth({VISIBLE:true});}
      catch(ex)
      {w=0;}
      if (w > objsWidth) objsWidth=w;
    return(objsWidth);
    /*int*/ Object.prototype.computeWidth = function(/*bool*/ VISIBLE)
    // Methode generique pour les composants possedant des Bounds
    // VISIBLE true -> largeur EXTERNE
    // VISIBLE false -> largeur INTERNE
    if (VISIBLE)
      if (this.visibleBounds)
      return(this.visibleBounds[3]-this.visibleBounds[1]);
    else
      if (this.geometricBounds)
      return(this.geometricBounds[3]-this.geometricBounds[1]);
    return(0);
    /*int*/ Table.prototype.computeWidth = function()
    // Specialise Object::computeWidth dans le cas d'une Table
    return(this.width);
    /*arr*/ Object.prototype.createLinesSizesArray = function()
    // Renvoie sous forme de tabeau la taille (en cars) des lignes de THIS
    // Tableau vide si this.lines==NULL  OU  this.lines.length==0
    r = new Array();
    if (this.lines)
      for (var i=this.lines.length-1; i>=0 ; i--)
      r.unshift(this.lines[i].characters.length);
    return(r);
    /*bool*/ Object.prototype.isoceleLines = function(/*arr*/ arrSizes)
    // Indique si THIS.lines[i].characters.length == arrSizes[i] pour tout i
    if (this.lines.length != arrSizes.length) return(false);
    for (var i=arrSizes.length-1 ; i>=0 ; i--)
      if (arrSizes[i] != this.lines[i].characters.length)
      return(false);
    return(true);
    // METHODES SPECIFIQUES A TEXTFRAME
    /*bool*/ TextFrame.prototype.isEmpty = function()
    return(this.characters.length==0);
    /*bool*/ TextFrame.prototype.isOverflowed = function()
    return(this.overflows);
    /*int*/ TextFrame.prototype.getWidth = function()
    return(this.computeWidth({VISIBLE:false}));
    /*void*/ TextFrame.prototype.resizeWidthBy = function(/*int*/ widthOffset)
    // Redimensionne la largeur de widthOffset (signe)
    this.geometricBounds = Array(
      this.geometricBounds[0],
      this.geometricBounds[1],
      this.geometricBounds[2],
      this.geometricBounds[3] + widthOffset);
    /*int*/ TextFrame.prototype.computeMinWidth = function()
    // Renvoie la largeur mini du bloc compte tenu des objets
    // incorpores et de l'espacement interne (inner space)
    var inSpace = this.textFramePreferences.insetSpacing;
    var inWidth = (inSpace.length) ?
      inSpace[1] + inSpace[3] : // inspace gauche et droit distincts
      2*inSpace; // inspace uniforme
    return(this.computeIncludedObjectsWidth() + inWidth);
    /*int*/ TextFrame.prototype.getCharsCount = function()
    return(this.characters.length);
    /*int*/ TextFrame.prototype.getLinesCount = function()
    return(this.lines.length);
    /*arr*/ TextFrame.prototype.getLinesSizes = function()
    return(this.createLinesSizesArray());
    /*int*/ TextFrame.prototype.preserveCharsCount = function(/*int*/ charsCount)
    // OUI -> -1  , NON -> 1
    return( (this.characters.length != charsCount) ? 1 : -1 );
    /*int*/ TextFrame.prototype.preserveLinesCount = function(/*int*/ linesCount)
    // Indique si:
    // - nb de chars = linesCount
    // - le bloc NE DEBORDE PAS
    // OUI -> -1  , NON -> 1
    return( ((this.overflows) || (this.lines.length != linesCount)) ? 1 : -1 );
    /*int*/ TextFrame.prototype.preserveLinesSizes = function(/*arr*/ linesSizes)
    // Indique si:
    // chaque ligne x est isocele a linesSizes[x]
    // YES -> -1  , NOT -> 1
    return( (this.isoceleLines(linesSizes)) ? -1 : 1 );
    // METHODES SPECIFIQUES A COLUMN
    /*bool*/ Column.prototype.isEmpty = function()
    for (var i=this.cells.length-1; i>=0 ; i--)
      if (this.cells[i].characters.length>0) return(false);
    return(true);
    /*bool*/ Column.prototype.isOverflowed = function()
    // Indique si au moins une cellule est saturee
    // !! ATTENTION: Column::overflows n'est pas fiable !!
    for (var i=this.cells.length-1 ; i>= 0 ; i--)
      if (this.cells[i].overflows) return(true);
    return(false);
    /*int*/ Column.prototype.getWidth = function()
    return(this.width);
    /*void*/ Column.prototype.resizeWidthBy = function(/*int*/ widthOffset)
    // Redimensionne la largeur de colonne de widthOffset (signe)
    // !! Il faut RAFRAICHIR l'affichage !!
    this.width += widthOffset;
    // rafraichissement
    if (APP_INT_VERSION > 3)
      // CS2+
      this.recompose();
    else
      // CS -- merci a Tilo pour ce hack --
      for(var i = this.cells.length - 1 ; i >= 0 ; i-- )
      // Ce test stupide provoque le rafraichissement!
      if (this.cells[i].contents == null) {}
    /*int*/ Column.prototype.computeMinWidth = function()
    // Renvoie la largeur mini de la colonne compte tenu des
    // objets incorpores et de l'espacement interne
    var iCell = null;
    var w = 0;
    var r = 0;
    for (var i=this.cells.length-1 ; i>= 0 ; i--)
      iCell = this.cells[i];
      w = iCell.computeIncludedObjectsWidth() +
      iCell.leftInset + iCell.rightInset;
      if (w > r) r = w;
    return(r);
    /*arr*/ Column.prototype.getCharsCount = function()
    // Renvoie (tableau) le nb de cars de chaque cellule
    // si la cellule est saturee, le nb de cars est signe negativement
    var r = new Array();
    var sgn = 0;
    for (var i=this.cells.length-1 ; i>= 0 ; i--)
      sgn = (this.cells[i].overflows) ? -1 : 1;
      r.unshift(sgn * this.cells[i].characters.length);
    return(r);
    /*arr*/ Column.prototype.getLinesCount = function()
    // Renvoie (tableau) le nb de lignes par cellules
    var r = new Array();
    for (var i=this.cells.length-1 ; i>= 0 ; i--)
      r.unshift(this.cells[i].lines.length);
    return(r);
    /*bi-arr*/ Column.prototype.getLinesSizes = function()
    // Renvoie le nb de chars par cellule et par ligne (matrice)
    var r = new Array();
    for (var i=this.cells.length-1 ; i>= 0 ; i--)
      r.unshift(this.cells[i].createLinesSizesArray());
    return(r);
    /*int*/ Column.prototype.preserveCharsCount = function(/*arr*/ charsCount)
    // Indique si:
    // le signe de debordement (overflow) de la cellule X egale sgn(charsCount[X])
    // OUI -> -1  , NON -> 1
    var sgn = 0;
    for (var i=this.cells.length-1 ; i>= 0 ; i--)
      sgn = (this.cells[i].overflows) ? -1 : 1;
      if (sgn * charsCount[i] < 0) return(1);
    return(-1);
    /*int*/ Column.prototype.preserveLinesCount = function(/*arr*/ linesCount)
    // Indique si:
    // - le compte de lignes de la cellule x egale linesCount[x]
    // - aucune cellule ne deborde
    // OUI -> -1  , NON -> 1
    for (var i=this.cells.length-1 ; i>= 0 ; i--)
      if (this.cells[i].overflows) return(1);
      if (this.cells[i].lines.length != linesCount[i]) return(1);
    return(-1);
    /*int*/ Column.prototype.preserveLinesSizes = function(/*bi-arr*/ linesSizes)
    // Indique si:
    // - dans chaque cellule x, chaque LIGNE y est isocele a linesSizes[x][y]
    // (si une cellule deborde, renvoie 1)
    // OUI -> -1  , NON -> 1
    for (var i=this.cells.length-1 ; i>= 0 ; i--)
      if (this.cells[i].overflows) return(1);
      if (this.cells[i].isoceleLines(linesSizes[i]) == false) return(1);
    return(-1);
    // METHODES CENTRALES
    /*void*/ Object.prototype.manageFit = function(/*bool*/ FLUIDFITTING)
    // !! Sous CS2, previent un crash sur les "grosses" selections multicolonnes !!
    // !! Thx to Tilo for this hack --
    if (APP_INT_VERSION>=4)
      $.gc();
    // ne rien faire si objet vide
    if (this.isEmpty()) return;
    // largeur mini a preserver
    var minWidth = this.computeMinWidth();
    // let's go!
    this.processFit(FLUIDFITTING, minWidth);
    /*void*/ Object.prototype.processFit = function(/*bool*/ FLUIDFITTING, /*int*/ minWidth)
    // Ajuste cet objet en largeur
    // FLUIDFITTING true -> methode fluide, sinon: methode stricte
    // minWidth fixe le seuil minimal
    if (FLUIDFITTING)
      { // AJUSTEMENT FLUIDE
      if (this.isOverflowed())
      { // NB : les cellules saturees sont "transparentes" (negligees)
      var charsCount = this.getCharsCount();
      var evalFlag = function(thisObj)
      {return(thisObj.preserveCharsCount(charsCount));}
      else
      var linesCount = this.getLinesCount();
      evalFlag = function(thisObj)
      {return(thisObj.preserveLinesCount(linesCount));}
    else
      { // AJUSTEMENT STRICT
       // NB : les colonnes contenant 1 cellule saturee sont inchangees
      if ((this.constructor.name=="Column") && (this.isOverflowed()))
      return;
      var linesSizes = this.getLinesSizes();
      var evalFlag = function(thisObj)
      {return(thisObj.preserveLinesSizes(linesSizes));}
    // BOUCLE DICHOTOMIQUE
    var sgnFLAG = -1;
    var w = ( this.getWidth() - minWidth ) / 2;
    while (w >= PRECISION)
      // redim la largeur de +/- w
      this.resizeWidthBy(sgnFLAG*w);
      // +1 = augmenter | -1 = reduire
      sgnFLAG = evalFlag(this);
      // diviser le segment
      w = w/2;
    // sortie avec sgnFLAG==+1 -> annuler la derniere reduction -> +2w
    if (sgnFLAG>0) this.resizeWidthBy(2*w);
    // PROGRAMME PRINCIPAL
    if ( app.documents.length > 0 )
      if ( app.activeWindow.selection.length > 0 )
      try {
      var thisDoc = app.activeDocument;
      var FLUIDFLAG = thisDoc.withinDelay();
      var memUnits = thisDoc.getUnits();
      thisDoc.setUnitsTo(MeasurementUnits.points);
      var selObjs = app.activeWindow.selection;
      var objsToFit = null;
      for (var i=selObjs.length-1 ; i>=0 ; i--)
      objsToFit = selObjs[i].asObjsToFit();
      if (objsToFit)
      for (var j=objsToFit.length-1 ; j>=0 ; j--)
      objsToFit[j].manageFit(FLUIDFLAG);
      thisDoc.setUnitsTo(memUnits);
      thisDoc.storeTimeStamp();
      catch(ex)
      thisDoc.setUnitsTo(memUnits);
      exitMessage(ex);
      else
      alert("Aucun objet n'est selectionne!");
    else
      alert("Aucun document n'est ouvert!");

  • Differences in Paragraph/Text Style Ranges in CS3/4

    I have code that exports the text from a frame into "block" and "inline" element. The code written for CS3 looks something like this below:
    var doc = app.activeDocument;
    var pageItems = doc.pageItems;
    for (var i = 0; i < pageItems.count(); i++) {
      var pageItem = pageItems.item(i);
      var textFrame = pageItem;
      $.writeln("Number of Paragraphs: " + textFrame.paragraphs.count());
      for (var j = 0; j < textFrame.paragraphs.count(); j++) {
        handleParagraph(textFrame.paragraphs.item(j), j);
    function handleParagraph(para, count) {
      if (para.constructor.name == "Story" ) {
        $.writeln("Paragraph is a Story");
      else {
        for (var i = 0; i < para.textStyleRanges.count(); i++) {
          var text = para.textStyleRanges.item(i);
          $.writeln("PARAGRAPH[" + (count+1) + "] has text [" + para.contents + "]" );
    When you have 2 paragraphs of text that contain a single sentence in the default text format, this outputs something like:
    Number of Paragraphs: 2
    PARAGRAPH[1] has text [Paragraph 1
    PARAGRAPH[2] has text [Paragraph 2]
    However, when I run the same code against a document in CS4, I get:
    Number of Paragraphs: 2
    PARAGRAPH[1] has text [Paragraph 1
    Paragraph 2]
    PARAGRAPH[2] has text [Paragraph 2]
    So the contents of the first text range in paragraph #1 under CS3 stops at the end of paragraph 1, while in CS4, it contains ALL of the contents of the frame (that is of the same style). The content of paragraph #2 starts with the text in paragraph #2.
    Is there a "correct" method for doing what I'm attempting here? Or at least some way of accomplishing this that should work in BOTH CS3 and CS4 (and CS5 as well I suppose)?
    Thanks!
    -Patrick

    It's because of this line
    var text = para.textStyleRanges.item(i);
    -- and, correct, it seems its behaviour has been changed somewhere along the line. Suddenly, a textStyleRange can cross over from one paragraph into the next one if (and only if) the same formatting continues.
    Try searching this forum on textStyleRanges -- I could fix my script when the same occurred to me but I can't recall how

Maybe you are looking for

  • How to export message body and data from Table to Excel from outlook 2010

    I usually get Employee announcement in emails and I need to compile excel sheet from all these emails to know change in status of employee from previous line to current line . Dear Concerned, The change in status of the following employee has been ca

  • How do I check if there is an error message?

    WIth <h:message for="something"/> I can display the (error) message for "something". How do I check if there is a error message fomr "something" in a JSF page? I am asking cause I want to use an other styleClass for an h:inputText field. Can there be

  • Please help to generate the table from column to rows

    Hello - I have one table with more than 100 columns there are 70 column start with HC1.....HC70 (they are not in sequence) and has some value 0 or 1 Table structure: HICN_ID HC1 HC2 HC4 HC5 HC6.................................HC70 1234A 0 1 1 0 1 1 3

  • How to send automated mail using Weblogic API ,,,,,, NOT Java Mail API.

    Hi All, I need to send an automated mail using BEA Weblogic API, can you please let me know how to accomplish this task, I will be heartly thankful to you, waiting for your response back naveen

  • IPad 2 charger on iPhone 4s?

    Is it okay to use the bigger more powerful iPad 2 charger to charge your iPhone 4S?  And how about the reverse?  I had my iPad connected to a Dell latitute laptop during setup (via USB) and it was in a state of "not charging".  I assume this was beca