2 Replies Latest reply: Mar 27, 2012 3:16 AM by kuyseng RSS

    how to exportfile fileformat.jpg with metadataPreferences?

    kuyseng

      Hello everyone!!

      I'm newbie to Indesign script and I want to write script to export activeDocument to JPG with its metadataPreferences? I don't know it's possible or not? or have any way to do it?

      Below is my code:

      -----

      var exportJpg = function() {

          var saveFile = File.saveDialog("Save your files","*.jpg");

          var mydoc = app.activeDocument;

          app.jpegExportPreferences.jpegQuality = JPEGOptionsQuality.MAXIMUM;           

          mydoc.metadataPreferences.description = "It's description to write";   

          mydoc.exportFile(ExportFormat.JPG, saveFile, false);

      }

      exportJpg();

      ----

      I wish anyone know and share their knowledge or give comments. Thank you in advance!!

       

      Best Regards;

      kuyseng.

        • 1. Re: how to exportfile fileformat.jpg with metadataPreferences?
          Muppet Mark Community Member

          I don't see any options for passing any metadata to the exported *.jpeg You should probably look at adding this later using the XMP library ( covered in the toolkit guide )… If I recall correctly *.pdf will inherit document metadata but that may be it…

          • 2. Re: how to exportfile fileformat.jpg with metadataPreferences?
            kuyseng Community Member

            Great Thank for your Guide!! Now I can find the code:

            ----

            var exportJpg = function() {

                var saveFile = File.saveDialog("Save your files","*.jpg");

                var mydoc = app.activeDocument;

                app.jpegExportPreferences.jpegQuality = JPEGOptionsQuality.MAXIMUM;           

                mydoc.metadataPreferences.description = "It's description to write";   

                mydoc.exportFile(ExportFormat.JPG, saveFile, false);

             

               if (ExternalObject.AdobeXMPScript == undefined)

                    ExternalObject.AdobeXMPScript = new ExternalObject('lib:AdobeXMPScript');

                

               var xmpFile = new XMPFile(saveFile.fsName, XMPConst.UNKNOWN, XMPConst.OPEN_FOR_UPDATE);

               var xmp = xmpFile.getXMP();

              

               xmp.deleteProperty(XMPConst.NS_DC, "description"); 

               xmp.setLocalizedText( XMPConst.NS_DC, "description", null, "x-default", "It's description to write");

               

               if (xmpFile.canPutXMP(xmp)) {

                      xmpFile.putXMP(xmp);

                } 

                xmpFile.closeFile(XMPConst.CLOSE_UPDATE_SAFELY); 

            }

             

            exportJpg();

            ---