Quantcast
Channel: Adobe Community: Message List - InDesign Scripting
Viewing all articles
Browse latest Browse all 37788

Add Link Name Label

$
0
0

Hello All,

 

I have a script by fourAces that was adjusted to launch without dialog so that I can process multiple pages all at once. Does anyone know if or how this can be adjusted to that it is picking up [none] for character style ? For some reason if page was saved with weird character style, it will use that style for link names.

 

Any help would be appreciated.

 

thank you!

 

/*

---------------------------------------------------------------------- --------------------------------------------

AddLinkNameLabel

---------------------------------------------------------------------- --------------------------------------------

An InDesign CS/CS2/CS3 JavaScript by FourAces

© The Final Touch 2007

Version 2.0.0

Adds a name label with the link name, path, type, and status above the linked object (graphics & texts).

The link is placed in a new "Link Info" layer, and are set as nonprinting objects.

---------------------------------------------------------------------- --------------------------------------------

*/

var myScriptVer = "2.0";

var myInfoTitle = "Link Info";

var myInfoLabelFont = "Myriad Pro";

var myInfoLabelTypeface = "Regular";

var myInfoLabelSize = 6;

var myInfoLabelLeading = 6;

var myInfoLabelLanguage = "English: USA";

var myInfoLabelIndent = "8mm";

var myInfoLabelInset = "0.5mm";

var myInfoLabelFontSize = "";

var myInfoLabelColor = [0,15,100,0];

var myInfoLabelTint = 25;

var yPos = 0;

var xPos = 0;

 

 

if(app.documents.length != 0){

          app.scriptPreferences.enableRedraw = false;

          var myDocument = app.activeDocument;

          var myOrgDocHUnits = myDocument.viewPreferences.horizontalMeasurementUnits;

          var myOrgDocVUnits = myDocument.viewPreferences.verticalMeasurementUnits;

          var myOrgDocOrigin = myDocument.viewPreferences.rulerOrigin;

          myDocument.viewPreferences.horizontalMeasurementUnits = MeasurementUnits.millimeters;

          myDocument.viewPreferences.verticalMeasurementUnits = MeasurementUnits.millimeters;

          myDocument.viewPreferences.rulerOrigin = RulerOrigin.spreadOrigin;

          var myLinks = myDocument.links;

          if(myLinks.length != 0){

                    //Clear previous layer, color, and styles

                    for(i = 0;i < myDocument.layers.length;i++){

                              var myLayer = myDocument.layers[i];

                              if(myLayer.name == myInfoTitle){

                                        myLayer.remove();

                              }

                    }

                    for(i = 0;i < myDocument.colors.length;i++){

                              var myColor = myDocument.colors[i];

                              if(myColor.name == myInfoTitle){

                                        myColor.remove();

                              }

                    }

                    for(i = 0;i < myDocument.paragraphStyles.length;i++){

                              var myPStyle = myDocument.paragraphStyles[i];

                              if(myPStyle.name == myInfoTitle){

                                        myPStyle.remove();

                              }

                    }

                    //Create the link info layer

                    var myLinkInfoLayer = myDocument.layers.add();

                    myLinkInfoLayer.name = myInfoTitle;

                    //Create the link info color

                    var myLinkInfoColor = myDocument.colors.add();

                    myLinkInfoColor.name = myInfoTitle;

                    myLinkInfoColor.colorValue = myInfoLabelColor;

                    //Create the link info Paragraph Style

                    var myLinkInfoPStyle = myDocument.paragraphStyles.add();

                    myLinkInfoPStyle.name = myInfoTitle;

                    try{

                              myLinkInfoPStyle.paragraphDirection = ParagraphDirection.leftToRightDirection;

                    }

                    catch(e){}

                    myLinkInfoPStyle.justification = Justification.leftAlign;

                    try{

                              myLinkInfoPStyle.appliedFont = myInfoLabelFont;

                              myLinkInfoPStyle.fontStyle = myInfoLabelTypeface;

                    }

                    catch(e){}

                    myLinkInfoPStyle.pointSize = myInfoLabelSize;

                    myLinkInfoPStyle.leading = myInfoLabelLeading;

                    myLinkInfoPStyle.appliedLanguage = myInfoLabelLanguage;

                    myLinkInfoPStyle.hyphenation = false;

                    myLinkInfoPStyle.leftIndent = myInfoLabelIndent;

                    myLinkInfoPStyle.firstLineIndent = "-" + myInfoLabelIndent;

                    var myLink, myLinkPos, myLinkName, myLinkParent, myLinkSpread, myLinkStatus, myLinkInfoFrame;

 

                    for(l = 0;l < myLinks.length;l++){

                              myLink = myLinks[l];

                              if(myLink.parent.parent.itemLayer.visible == true){

                                        myLinkPos = myLink.parent.parent.geometricBounds;

                                        myLinkWidth = myLinkPos[3] - myLinkPos[1];

                                        myLinkHeight = myLinkPos[2] - myLinkPos[0];

                                        myLinkParent = myLink.parent;

                                        do{

                                                  if(myLinkParent.constructor.name != "Character"){

                                                            myLinkParent = myLinkParent.parent;

                                                  }

                                                  else{

                                                            if(app.version.split(".")[0] >= 4){

                                                                      myLinkParent = myLinkParent.parentTextFrames[0];

                                                            }

                                                            else{

                                                                      myLinkParent = myLinkParent.parentTextFrame;

                                                            }

                                                  }

                                        }while((myLinkParent.constructor.name != "Spread")&&(myLinkParent.constructor.name != "MasterSpread"))

                                        if(myLinkParent.constructor.name == "Spread"){

                                                  myLinkSpread = myDocument.spreads[myLinkParent.index];

                                        }

                                        else{

                                                  myLinkSpread = myDocument.masterSpreads[myLinkParent.index];

                                        }

                                        myLinkInfoFrame = myLinkSpread.textFrames.add();

                                        myLinkInfoFrame.geometricBounds = [myLinkPos[0],myLinkPos[1],myLinkPos[0]+10,myLinkPos[1]+50];

                                        myLinkInfoFrame.textFramePreferences.insetSpacing = [myInfoLabelInset,myInfoLabelInset,myInfoLabelInset,myInfoLabelInset] ;

                                        myLinkInfoFrame.textFramePreferences.ignoreWrap = true;

                                        myLinkInfoFrame.fillColor = myInfoTitle;

                                        myLinkInfoFrame.fillTint = myInfoLabelTint;

                                        myLinkInfoFrame.strokeColor = myInfoTitle;

                                        myLinkInfoFrame.strokeWeight = 1;

                                        myLinkInfoFrame.nonprinting = false;

                                        myLinkInfoFrame.contents = myLink.name;

                                        myLinkInfoFrame.parentStory.paragraphs[0].applied ParagraphStyle = myInfoTitle;

                                        myLinkInfoFrame.fit(FitOptions.frameToContent);

                                        myLabelBounds = myLinkInfoFrame.geometricBounds;

                                        myLabelWidth = myLabelBounds[3] - myLabelBounds[1];

                                        myLabelHeight = myLabelBounds[2] - myLabelBounds[0];

                                        myLinkInfoFrame.move(undefined,[(myLinkWidth/2)-( myLabelWidth/2), (myLinkHeight/2)-(myLabelHeight/2)]);

                              }

                    }

          }

          myDocument.viewPreferences.horizontalMeasurementUnits = myOrgDocHUnits;

          myDocument.viewPreferences.verticalMeasurementUnits = myOrgDocVUnits;

          myDocument.viewPreferences.rulerOrigin = myOrgDocOrigin;

          app.scriptPreferences.enableRedraw = false;

}


Viewing all articles
Browse latest Browse all 37788

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>