3 Replies Latest reply on Apr 5, 2016 10:50 AM by Laubender

    Add Metadata to JPG export pages?

    cathykka Level 1

      I have a script that exports the pages of an indesign file to a jpg.

      Is it possible to add metadata on jpg export?

       

      I have another script that will add meta to the whole doc, but I would like to add meta on a page by page basis during export.

       

      with (myDoc.metadataPreferences){

          author = "Me";

          documentTitle = docTitleText;

          keywords = docKeywords;

          description = docDescripText;

          copyrightNotice = "2005-2016 ©etc";

          copyrightInfoURL = "xx"; 

          copyrightStatus = CopyrightStatus.yes;

              }

       

       

      main ();  
        
      function main() {  
          var curDoc = app.activeDocument;  
          var docPath = curDoc.filePath;   
        
          // create a folder  
          var theFolder = new Folder(docPath + "/" + curDoc.name.replace(/\.indd$/,"") );  
          if (!theFolder.exists) {  
              theFolder.create();  
          }  
      var curPage = app.activeWindow.activePage; // Find the active page.
      var docTitleText="";
      var docDescripText="";
      var docKeywords = []; 
      
      app.findGrepPreferences = app.changeGrepPreferences = null;
      app.findGrepPreferences.findWhat = '.+';
      found = app.activeDocument.findGrep (true);
      
      for (j = found.length-1; j >=0 ; j--)
      {
          var foundText = found[j].contents;
         
          //You can define multiple Paragraph style for Document Title us else if
         
          if(found[j].texts[0].appliedParagraphStyle.name=="meta-title")
          {
              docTitleText=found[j].contents;
          }
          
      
          //You can define multiple Paragraph style for Document Description
      
          else if(found[j].texts[0].appliedParagraphStyle.name=="meta-description")
          {
              docDescripText=found[j].contents;
          }
      
      
          else if(found[j].texts[0].appliedParagraphStyle.name=="meta-key")
          {
              docKeywords= found[j].contents.split(",");
          }
      
      
      
      
      var filename= docTitleText.replace( /\s+$/ , "" ).replace( /\s+/g , "-" ).toLowerCase().replace(/\+/, '').replace(/\&-/, '').replace(/,/g, '').replace(/:/g, '').replace(/--/g, '-').replace(/\?/g, '').replace(/\./g, '');
      var myFilePath= theFolder + "/" + curDoc.name.replace(/\.indd$/,"")  + "-" + filename + ".jpg";  
      var myFile = File( myFilePath );
           
      
      
              app.jpegExportPreferences.jpegQuality = JPEGOptionsQuality.HIGH; // low medium high maximum
              app.jpegExportPreferences.jpegRenderingStyle = JPEGOptionsFormat.BASELINE_ENCODING;
              app.jpegExportPreferences.jpegColorSpace = JpegColorSpaceEnum.RGB;
              app.jpegExportPreferences. exportResolution = 72;
              app.jpegExportPreferences.jpegExportRange = ExportRangeOrAllPages.EXPORT_RANGE;
              pageString = curPage.name;
             } 
            
          curDoc.exportFile(ExportFormat.jpg, myFile, false );
          
      }