Search for page elements in a specific layer, and not in the entire document

Hello

could you please help me to modify this script, then it can look only to the elements of the page ("Date", "Time", "Version", 'Code of component Ops') in a single specific layer named "Legend" instead of all the layers?

/**********************************************************


ADOBE SYSTEMS INCORPORATED 
Copyright 2005-2006 Adobe Systems Incorporated 
All Rights Reserved 


NOTICE:  Adobe permits you to use, modify, and 
distribute this file in accordance with the terms
of the Adobe license agreement accompanying it.  
If you have received this file from a source 
other than Adobe, then your use, modification,
or distribution of it requires the prior 
written permission of Adobe. 


*********************************************************/


/** Saves every document open in Illustrator
  as a PDF file in a user specified folder.
*/


// Main Code [Execution of script begins here]
try {
  // uncomment to suppress Illustrator warning dialogs
  // app.userInteractionLevel = UserInteractionLevel.DONTDISPLAYALERTS;


  if (app.documents.length > 0 ) 
  {
  var options, i, sourceDoc, targetFile,;

  // Get the PDF options to be used
  options = this.getOptions();
  if (options != null) 
  {
  sourceDoc = app.activeDocument; // returns the document object
  var fullName = sourceDoc.fullName;
  fullName = fullName.toString();

  var destFolder = fullName.slice(0,fullName.lastIndexOf("/"))
  var dateFound = false;
  var versionFromName = fullName.slice(fullName.lastIndexOf("-")+1, fullName.lastIndexOf("_"));
  var opsFromName = fullName.slice(fullName.lastIndexOf("/")+1, fullName.lastIndexOf("-"));
  var theVersionNumber = null;
  var dateField = null;
  var timeField = null;
  var opsVersionCode = null;
  for(i=0; i<sourceDoc.pageItems.length;i++)
  {
  if (sourceDoc.pageItems[i].note == "Date") 
  {
  dateField = sourceDoc.pageItems[i];
  }
  if (sourceDoc.pageItems[i].note == "Time") 
  {
  timeField = sourceDoc.pageItems[i];
  }
  if (sourceDoc.pageItems[i].note == "Version") 
  {
  theVersionNumber = sourceDoc.pageItems[i].contents;
  }
  if (sourceDoc.pageItems[i].note == "Ops Component Code")
  {
  opsVersionCode = sourceDoc.pageItems[i].contents;
  }

  }
  if (theVersionNumber == versionFromName)
  {
  if (opsVersionCode == opsFromName)
  {
  if (dateField == null)
  {
  alert('No tagged date field found. Tag field and try again.')
  }
  else
  {
  dateField.contents = TodayDate()
  timeField.contents = TodayTime()
  OLtargetFile = this.getTargetFile(sourceDoc.name, '.pdf', destFolder);
  sourceDoc.saveAs( OLtargetFile, options)
  // alert( 'Documents saved as PDF' );
  }
  }
  else
  {
  alert('Ops component code in boiler does not match file name or is not tagged. Please correct and try again.')
  }
  }
  else
  {
                
  alert('Version number in boiler does not match file name or is not tagged. Please correct and try again.')
  }
  }
  else 
  {
  alert('User aborted')
  }

  }
  else
  {
  throw new Error('There are no document open!');
  }
}
catch(e) {
  alert( e.message, "Script Alert", true);
}


/** Returns the options to be used for the generated files.
  @return PDFSaveOptions object
*/
function getOptions()
{





  // Create the required options object
  var options = new PDFSaveOptions();
  // See PDFSaveOptions in the JavaScript Reference for available options
  options.pDFPreset = "AZ"


  // For example, uncomment to set the compatibility of the generated pdf to Acrobat 7 (PDF 1.6)
  // options.compatibility = PDFCompatibility.ACROBAT7;

  // For example, uncomment to view the pdfs in Acrobat after conversion
  // options.viewAfterSaving = true;

  return options;
}


function abortFunction(){

  modUI = null;
  dlg.hide();
  return null;
  }
/** Returns the file to save or export the document into.
  @param docName the name of the document
  @param ext the extension the file extension to be applied
  @param destFolder the output folder
  @return File object
*/
function getTargetFile(docName, ext, destFolder) {
  var newName = "";


  // if name has no dot (and hence no extension),
  // just append the extension
  if (docName.indexOf('.') < 0) {
  newName = docName + ext;
  } else {
  var dot = docName.lastIndexOf('.');
  newName += docName.substring(0, dot);
  newName += ext;
  }

  // Create the file object to save to
  var myFile = new File( destFolder + '/' + newName );

  // Preflight access rights
  if (myFile.open("w")) {
  myFile.close();
  }
  else {
  throw new Error('Access is denied');
  }
  return myFile;
}


function TodayDate(){
  var Dateformat = "dd mm yyyy";
  nameMonths = true;


   var monthNames = ["January","February","March","April","May","June","July","August","September","October","November","December"];
   var Today = new Date();
   var Day = Today.getDate();
   if(nameMonths == true){
   var Month = monthNames[Today.getMonth()];
   } else {
   var Month = Today.getMonth() + 1;}

   var Year = Today.getYear();
   var PreMon = ((Month < 10) ? "0" : "");
   var PreDay = ((Day < 10) ? "0" : "");
   var Hour = Today.getHours();
   var Min = Today.getMinutes();
   var Sec = Today.getSeconds();
   if(Year < 999) Year += 1900;
   var theDate = Dateformat.replace(/dd/,PreDay+Day);
   theDate = theDate.replace(/mm/,PreMon+Month);
   theDate = theDate.replace(/d/,Day);
   //theDate = theDate.replace(/m/,Month);
   theDate = theDate.replace(/yyyy/,Year);
   theDate = theDate.replace(/yy/,Year.toString().substr(2,2));
   if(Hour==0){
  Hour = "12";
  theDate = theDate.replace(/XX/,"AM");
   }else if(Hour>12){
   Hour = (Hour-12);
   theDate = theDate.replace(/XX/,"PM");
   }else{
   theDate = theDate.replace(/XX/,"AM");
   }
   var preSec = ((Sec < 10) ? "0" : "");
   var preHour = ((Hour < 10) ? "0" : "");
   var preMin = ((Min < 10) ? "0" : "");
   theDate = theDate.replace(/hr/,preHour+Hour);
   theDate = theDate.replace(/Mn/,preMin+Min);
   theDate = theDate.replace(/sc/,preSec+Sec);
   return theDate;
}


function TodayTime(){
  var Dateformat = "hr:Mn";
  nameMonths = false;


   var monthNames = ["January","February","March","April","May","June","July","August","September","October","November","December"];
   var Today = new Date();
   var Day = Today.getDate();
   if(nameMonths == true){
   var Month = monthNames[Today.getMonth()];
   } else {
   var Month = Today.getMonth() + 1;}

   var Year = Today.getYear();
   var PreMon = "";//((Month < 10) ? "0" : "");
   var PreDay = ((Day < 10) ? "0" : "");
   var Hour = Today.getHours();
   var Min = Today.getMinutes();
   var Sec = Today.getSeconds();
   if(Year < 999) Year += 1900;
   var theDate = Dateformat.replace(/dd/,PreDay+Day);
   theDate = theDate.replace(/mm/,PreMon+Month);
   theDate = theDate.replace(/d/,Day);
   theDate = theDate.replace(/m/,Month);
   theDate = theDate.replace(/yyyy/,Year);
   theDate = theDate.replace(/yy/,Year.toString().substr(2,2));
   if(Hour==0){
  Hour = "12";
  theDate = theDate.replace(/XX/);
   }else{
   theDate = theDate.replace(/XX/);
   }
   var preSec = ((Sec < 10) ? "0" : "");
   var preHour = ((Hour < 10) ? "0" : "");
   var preMin = ((Min < 10) ? "0" : "");
   theDate = theDate.replace(/hr/,preHour+Hour);
   theDate = theDate.replace(/Mn/,preMin+Min);
   theDate = theDate.replace(/sc/,preSec+Sec);
   return theDate;
}

You can target the layer to search, add a line before you right pageitems loop, and then change the new target in your loop

  var targetLayer = sourceDoc.layers['Legend']; // ** added

  for(i=0; i 
         

Tags: Illustrator

Similar Questions

  • How to reset the settings for spell check in word - it will not check the entire document and ignores the parts of it

    When press comes out to check for a new document, it is not highlight any misspellings or grammar and reading - 'Spelling and grammar verification.»  Has been ignored, text marked with "do not check spelling or grammar"".»  Actually, it checks the document and I don't know how to cancel it?

    Please repost on MS Office Word forum:
    http://answers.Microsoft.com/en-us/Office/Forum/word?page=1&tab=no

  • How can I use windows search to search for pdf files containing a specific word?

    I have a folder with several pdf files. When I use windows search for a word that I know exists in one of the files, I get no results. It does not work when I use the content: either.

    How can I use windows search to search for pdf files containing a specific word?

    Do I need to install something to activate search within .pdf?

    If you use Win7 32 bit, the iFilter is bundled with Acrobat Reader 9. On Win7 64-bit, you will need to install it separately.

    http://www.Adobe.com/support/downloads/detail.jsp?ftpID=4025

    Peter

  • How to get the phone and messages back in my dock apps? And for some reason, I discover now all my app pages from the middle of my phone and not at the top?

    How can I get the phone and messages apps in my dock? And for some reason, I discover now all my app pages from the middle of my phone and not at the top?

    Try

    Settings > general > reset > reset home screen presentation.

    Note: All other applications will be organised by alphabetical order.

  • Toolbox for Pages only opens in PDF format and does not directly open from documents Pages.

    How do 'Toolbox for Pages' to open directly from a Pages document (I use ' menu Insertion, but that does not help) and get the spare in PDF formats since I can not insert in my documents Pages?

    You have answered your concerns with Jumsoft, the vendor providing the third party package? It is an Apple product, or probably something that much/all have installed us.

    The Insert on Pages menu is set by Apple and not usable by third-party applications. You get PDF page content in the Pages just by drag and drop.

  • Create a shortcut on the desktop the icon comes back to a 'globe' for any shortcut, I create. It does not cover the actual icon as shown in the url or web page. Any ideas?

    Create a shortcut on the desktop the icon comes back to a 'globe' for any shortcut, I create. It does not cover the actual icon as shown in the url or web page. Any ideas?

    Hi Ronnie,.

    I see that you can not create a shortcut on the desktop. I'll help you with this problem.

    1. What is the brand and model of the computer?

    2. what operating system is installed on the computer?

    3. what security software is installed on the computer?

    4. have you made changes on the computer recently?

    5 is the issue limited to the creation of shortcuts on the desktop?

    6. How do you try to create a shortcut on the desktop?

    Please provide us with more information to continue troubleshooting as a result.

    See the link on how to ask questions or help on the Forums.

    Suggestions for a question on help forums: http://support.microsoft.com/kb/555375

    Thank you.

  • OFFICE 2003 UPDATES NOT INSTALLi WILL have carried out a search for the KB numbers is not found has tried to find where the updates have been downloaded, not at the office and not in the section windows software, then

    4 updates for office 2003 will not install update for the junk e-mail in Microsoft Office Outlook 2003 (KB974771) filter
    Update of security for Microsoft Office 2003 (KB972580)
    Update of security for Microsoft Office 2003 (KB974554)
    Update of security for Microsoft Office Outlook 2003 (KB973705) I searched the KB numbers, not found tried to find where the updates have been downloaded, not at the office and not in the software section windows, so I am at a loss, the small yellow shield keeps saying updates are ready for download
    I am at a loss of what everything else is fine, that I have set for automatic notification of updates, then let me chose to download.
    for any help or suggestion would be greatly appreciated.
    Thank you very much * address email is removed from the privacy *.

    Download the 4 four updates and install them manually.

    IE: http://www.microsoft.com/downloads/en/results.aspx?freetext=KB974771&displaylang=en&stype=s_basic

    Just look for the other 3 three, download to a place you can find and install manually the same.

    Taursie TaurArian [MVP] 2005-2010 - Update Services

  • Just updated for first elements 13 took a film and tried to apply instant film. I get a dialog box called "Adobe first Elements.exe - no disc. I have not all discs, because I downloaded this update. A ran the same film and feature on Eleme

    Just updated for first elements 13 took a film and tried to apply instant film. I get a dialog box called "Adobe first Elements.exe - no disc. I have not all discs, because I downloaded this update. A ran the same film and function on 12 items, it has worked well. I reinstalled the 13 items that was no help. Note it is very difficult to get rid of this box, it crashes the program elements sometimes

    mnicolett4

    What operating system is involved? Assuming that Windows 7, 8 or 8.1 64-bit for now.

    There is a known No Disc error associated with the elements first 13/13.1. The Adobe fix is the removal or disabling of the OldFilm.AEX file. Let us determine if this applies to your situation.

    The file OldFilm.AEX that you remove or disable renaming in OldFIlm.AEXOLD is located in the path of 64-bit Windows 7, 8 or 8.1 of

    Local disk C

    Program Files

    Adobe

    Adobe Premiere Elements 13

    Plug-ins

    Commune

    NewBlue

    and in NewBlue folder is the file OldFilm.AEX that you remove or disable renaming in OldFilm.AEXOLD.

    Please let us know if it works for you.

    Thank you.

    RTA

    Add on... Have you updated 13 to 13.1 still using Help Menu/updates to date of an open project? If this isn't the case, please do.

  • Turn the page on the entire document in vbscript

    Hello

    I know how to do it manually:

    in an open PDF file, I press on "Ctrl + A" to select all elements in the document, then I choose Edition/transformation/rotation... 90 degrees.

    now, I would do the same thing with a vbscript.

    the best thing I have found is:

    ************************************

    Rotate (90)

    Void rotate (degree)

    Dim appRef, argument, element

    Dim changePositions, changeFillPatterns, changeFillGradients, changeStrokePattern, rotateAbout

    Set appRef = CreateObject ("Illustrator.Application")

    changePositions = true

    changeFillPatterns = false

    changeFillGradients = false

    changeStrokePattern = False

    rotateAbout = 1 ' aiTransformDocumentOrigin

    For each item in appRef.ActiveDocument.PathItems

    element. Rotate the degree, changePositions, changeFillPatterns, changeFillGradients, changeStrokePattern, rotateAbout

    Next

    appRef.Redraw

    End Sub

    ************************************

    not all, but all the elements, by that I am interested rotation - it would be better if you really all the elements would be rotated

    the elements are turned around "aiTransformDocumentOrigin"... I would prefer if they rotate around 'document '.

    Does anyone have an idea for a better solution?

    THX and greetings

    Soletti

    loop through PageItems instead of PathItems in each layer instead of the entire Document, which would take care of everything.

    to rotate around the center of the page, move the origin (0,0) at the center of the page before you turn.

  • How to lift a picture in a document to print it without printing the entire document, and when I ask to print at 400%, how to tell me how many pages there are, and what's on them

    I have a pix of a quilt in a document. I would like to print the page of the document to 400% to allow me to see the quilt better. When I put in my percent effects, it prints the entire document and will not allow me to move to other pages. He says his p1 1. I take a class to make this quilt. I need this pix for the class.

    Have you tried to open the image in a new tab via the context menu and a middle - click on the Image of the view and the zoom of the image (Ctrl +)?

  • Firefox is not fully load site Barclaycard of authentication. It load regarding the demand for certain letters in my password but does not load the button 'Submit', so I can't continue with my purchase and I switch to IE8 browser to buy whatever it is ov

    Firefox is not fully load site Barclaycard of authentication. It load regarding the demand for certain letters in my password but does not load the button 'Submit', so I can't continue with my purchase and I switch to IE8 browser to buy anything on the internet. Clues?

    This has happened

    A few times a week

    Is a few weeks ago

    Your UserAgent string in Firefox is totally messed up by another program that you have installed and Barclays does not know you use Firefox 3.6.6 - it is probably similar to IE 6.0 on this site.
    http://en.Wikipedia.org/wiki/USER_AGENT

    type of topic: config in the URL bar and press ENTER.
    If you see the warning, you can confirm that you want to access this page.
    Filter = general.useragent.
    Preferences are "BOLD", a line at a time, and then select reset, right click
    Then restart Firefox

  • Can I apply changes in tone to a layer and not only some cut of my film?

    I can't explain it properly, I'm eager to apply the same color to my whole film correction and not only the edited part of my film that I would need to do this for all the clips, and that feels like a marathon task.

    So I want to affect blacks and shadows for all "Video 1"and not just the clip cut as shown below."

    Thank you in advance...

    Screen Shot 2016-10-01 at 22.48.53.pngScreen Shot 2016-10-01 at 22.49.03.png

    Remove the Lumetri effect on the first clip.

    Go to the menu sequence > add tracks.

    Set it to add a video track after track 1 and 0 audio tracks. Click OK.

    Go to the file menu > New > adjustment layer and create an appropriate adjustment layer.

    Once it is created in your program Panel, drag it to the new video track (empty), you just create and stretch the length of the clip it so that it covers all the video clips on track 1.

    Click on the adjustment layer to select it, go to the color workspace and make the desired settings. Everything below the adjustment layer will receive the same treatment of color.

    MtD

  • How to detect the Collision layer or the layer is not in the display?

    Hi guys,.

    my script should detect if a portion of a layer is not in the display window.

    I found Dan´s article on the collision, but don t know if it helps with my needs. (sampleImage()? maybe)

    KLICK: Collision

    The second idea I had was ee . sourceRectAtTime() method, but it may possible to give a false positive.

    (for example a textlayer with a huge but bounding box a few letters that are visible in the view).


    You have ideas or advice for me check this behavior?



    I hope that my explanations are comprehensible.

    To detect if part of a layer is not in the window display (by which I assume you mean not within the limits of the model) you can calculate the current dimensions of your layer by first finding its width and its height and multiplying by (scale/100); then using the layer position and anchor point, you could say if the layer has been moved. Such as:

    layerWidthPostScale = layerWidth * (scale.x / 100)

    layerHeightPostScale = layerHeight * (scale.x / 100)

    If (abs (Position.x - AnchorPoint.x) > ((compWidth-layerWidthPostScale) / 2) |)   ABS (Position.y - AnchorPoint.y) > ((compHeight-layerHeightPostScale) / 2)) {}

    Part of the layer is outside the limits of the model

    }

    This will work with solids and the layers of images. Not sure about the text or the shape of fine layers, or a layer hidden unless you can find the bounding boxes. Even in this case it may not be enough if you are looking for a pixel solid being inside or outside.

  • How to duplicate a layer and then change the adjustment layer?

    This used to be easy to PS7, but he is evasive in CS4. Sometimes we need to duplicate a layer, then change the adjustment layer. For example, we may have selected a portion of an image and used the brightness contrast and then we need to create a new layer using the same section using selective correction. What we have done in the past, is to duplicate the layer, and then change the adjustment layer. Any ideas?

    Create your new adjustment layer. Option drag the mask layer on the new original setting, and then choose replace.

    Beware of the many similar masks:

    http://www.teddillard.com/2008/10/Geekzone-rosenholtz-Sanchez-effect.html

  • I installed 5.6.2 Pages but all my old documents will open with ' 08 how can I delete the Pages ' 08 and update all the old documents

    I installed 5.6.2 Pages but all my old documents will open with ' 08 v.3.03 How can I remove the Pages ' 08 and update all the old documents

    5 pages is located in your Applications folder.

    Pages ' 08 is located in your Applications/iWork ' 08 folder.

    If you open your old documents Pages ' 08 with 5 Pages it will convert and if not damage, remove a large number of useful features.

    You will probably regret upgrading to 5 Pages which Apple has made extremely inconsistent and keeps changing its file format.

    Peter

Maybe you are looking for

  • Presario 2195US original audio driver freeze all the computer in Win7

    Hello friends! I'm new to the forum, and I am here because everything could not solve my problem. My Compaq Presario 2195US has an upgrade of RAM 1 GB in total and I installed Win7 on it. In the adaptation of the drivers, everything goes very well wi

  • unlock the security &amp; privacy

    How can I unlock the security and privacy settings in El Capitan.  I thought I had the correct password, but apparently not.  Thank you very much for your answers.

  • end of timed loop

    My request is for a closed loop system where I control current that warms a resistive load.  I want to ramp the current until a specified temperature is measured, live at this temperature (with a tolerance) for a while and then put an end to the VI. 

  • FrostWire - bad Image and can not download Limewire

    Original title : frostwire I just downloaded the windows version of frost wire. However, after its installation, windows blocks it opens a window which describes as follows title of window - FrostWire.exe - Bad Image. Pop - up window - C:\Program bod

  • free update of cpt5910a vista driver

    I just upgraded my laptop xp-vista hp510 I can't find the vista driver for... audio conexant ac-link cpt5910a can u help