Back

If your email is not recognized and you believe it should be, please contact us.

  • You must be logged in to reply to this topic.Login

Exporting InDesign Pages to pngs with different file names.

Return to Member Forum

  • Author
    Posts
    • #14406536
      Mary Boland
      Participant

      Hi I found this script for exporting InDesign Pages to jpgs with different files names and it works great. I thought if I replaced jpeg/jpg with png it would do the same for png files but it doesn’t work. Does anybody have a suggestion!!!

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

      var myDoc = app.activeDocument;

      MakeJPEGfile();

      } else {

      alert(“Please open a document and try again.”);

      }

      function myPS() {

      try {

      return myDoc.selection[0].appliedParagraphStyle;

      } catch (e) {

      alert(“Place cursor to text with paragraph style for filenames”);

      exit();

      }

      }

      function MakeJPEGfile() {

      app.jpegExportPreferences.jpegQuality = JPEGOptionsQuality.maximum;

      app.jpegExportPreferences.exportResolution = 72;

      app.jpegExportPreferences.jpegExportRange = ExportRangeOrAllPages.exportRange;

      app.findGrepPreferences = null;

      app.findGrepPreferences.appliedParagraphStyle = myPS();

      var f = myDoc.findGrep();

      for (var myCounter = 0; myCounter < f.length; myCounter++) {

      try {

      var curPage = f[myCounter].parentTextFrames[0].parentPage;

      if (curPage.appliedSection.name != “”) {

      curPage.appliedSection.name = “”;

      }

      var objName = f[myCounter].contents.replace(/ /g,””).toLowerCase();

      app.jpegExportPreferences.pageString = curPage.name;

      //var myFilePath = “~/C:\output/” + myPageName + “.jpg”;

      var myFilePath = myDoc.filePath + “/” + objName + “.jpg”; //export to a folder of the current document

      var myFile = new File(myFilePath);

      myDoc.exportFile(ExportFormat.jpg, myFile, false);

      } catch(e) {

      //pasteboard?

      }

      }

      }

    • #14406537
      Steve
      Member

      Where did you get the script from?
      There are many lines in it that have jpg in them.
      I think you should check the syntax and makeup of your script, it’s like changing a word in a foreign language and hoping it will be OK.

    • #14406539
      Mary Boland
      Participant

      I got the script online. Works great on both the Mac and PC.

      I thought must changing jpg/jpeg to png would work because they have basically the same export box.. quality, etc.

      But it won’t work when I change it to png.

    • #14406541
      David Blatner
      Keymaster

      I agree with Steve… editing scripts can be tricky! :-)
      One thing to remember: always be sure to change curly quotes to straight quotes everywhere.

      I know that Keith Gilbert has written scripts to export PNG here: https://www.gilbertconsulting.com/scripts

      You might also take a look at Mike Rankin’s post here:

      Fixing a Broken JavaScript (and How To Avoid Breaking It in the First Place)


      and Colin’s here:

      Improving Scripts

    • #14406555
      Mary Boland
      Participant

      If I can’t figure out is there a scripter out there who doesn’t cost an arm and a leg that could help me fix the script.

      Most of my co-workers design in Illustrator and export with the names attached. InDesign should have that capability!

      I am the only one who thinks layout should be done in InDesign. It drives me crazy when people do their layouts in Illustrator.

      I think Illustrator elements should be placed in InDesign.

      So if I could get this png export script working it might help me in persuading them (maybe).

Viewing 4 reply threads
  • The forum ‘General InDesign Topics (CLOSED)’ is closed to new topics and replies.
Forum Ads