5 Replies Latest reply on Mar 31, 2016 10:44 AM by subieguy2

    Create a report or log file

    subieguy2 Level 1
      #target illustrator
      var doc = app.activeDocument;
      var allText = doc.textFrames;
      var boldText = app.textFonts.getByName("Arial-Black")
      
      
      var d = new Date();
      var currentYear = d.getFullYear();
      var currentMonth = ("0"+(d.getMonth()+1)).slice(-2);
      var currentDay = ("0" + (d.getDate())).slice(-2)
      
      
      for (var i = 0; i < allText.length; i++) {
          //alert(allText[i].contents.substr(0,4));
          if (allText[i].contents == "Electrical System") {
              //alert("This is an Electrical Schematic");
              var mediaType = allText[i].contents;
          }
          if (allText[i].contents.substr(0, 4) == "UENR") {
              //alert("Media Number " + allText[i].contents);
              var mediaNumber = allText[i].contents;
          }
          var textFieldRange = allText[i].textRange;
          var textProps = textFieldRange.characterAttributes;
          if (allText[i].contents != "Electrical System" && textProps.textFont == "[TextFont Arial-Black]") {
              //alert("Your Title is: " + allText[i].contents);
              var mediaTitle = allText[i].contents;
          }
      }
      
      
      var emailAddress = "someone@myemail.com";
      var dateFormat = currentYear + "" + currentMonth + "" + currentDay; 
      
      
      //alert("Media #: " + mediaNumber + "\nMedia Type: " + mediaType + "\nTitle: " + mediaTitle + "\nEmail report to: " + emailAddress + "\nSubmitted on: " + dateFormat);
      
      
      
      
      
      
      
      
      
      
      

       

      So I am wanting to take the information from the above script I wrote and have a text file of sorts in a certain format. For example I would like this format

      <meta name="Internet E-Mail Address" content="emailAddress">

      <meta name="Media No Rev" content="mediaNumber">

      <meta name="Publication Date" content="dateFormat">

       

      so a finished report would look like this for example:

       

      <meta name="Internet E-Mail Address" content="someone@myemail.com">

      <meta name="Media No Rev" content="UENR1234">

      <meta name="Publication Date" content="20160226">