1 Reply Latest reply on Nov 20, 2016 8:44 AM by Peter Kahrel

    Export indesign linked files as pdf files?

    Eugene Tyson Adobe Community Professional & MVP

      Anyone have a script that will export all linked files in an indesign document as a pdf at the size they are in Indesign?

       

      I need to start moving a lot of links from lots of files to another platform for web deployment and the only format it accepts is PDF.

        • 1. Re: Export indesign linked files as pdf files?
          Peter Kahrel Adobe Community Professional & MVP

          Here's a script that exports all linked files in the active document as PDF except those that are already PDF and those whose link is invalid. It uses the [Press Quality] PDF preset, you can change that in line 21.

           

          Peter

           

          (function () {
            function getLinks () {
              var listOk = [];
              var listNotOk = [];
              var links = app.documents[0].links.everyItem().getElements();
              for (var i = 0; i < links.length; i++) {
                if (/\.pdf$/i.test(links[i].filePath) === false) {
                  if (links[i].status === LinkStatus.NORMAL) {
                    listOk.push (links[i].filePath);
                  } else {
                    listNotOk.push (links[i].filePath);
                  }
                }
              }
              return {listOk: listOk, listNotOk: listNotOk}
            }
          
          
            function exportLinksAsPdf (list) {
              var placed;
              var preset = app.pdfExportPresets.item ('[Press Quality]');
              app.documents.add();
              for (var i = 0; i < list.length; i++) {
                placed = app.documents[0].pages[0].place (File(list[i]), [0,0], undefined, false)[0];
                app.documents[0].pages[0].resize (CoordinateSpaces.INNER_COORDINATES, 
                                      AnchorPoint.TOP_LEFT_ANCHOR, 
                                      ResizeMethods.REPLACING_CURRENT_DIMENSIONS_WITH, 
                                      [placed.geometricBounds[3], placed.geometricBounds[2]]);
                app.documents[0].exportFile (ExportFormat.PDF_TYPE, File (list[i].replace (/^(.+\.).+/, '$1pdf')), false, preset);
                placed.parent.remove();
              }
              app.documents[0].close (SaveOptions.NO);
            }
          
          
            var lists = getLinks();
            exportLinksAsPdf (lists.listOk);
            if (lists.listNotOk.length > 0) {
              alert ('Unable to export the following links: \r' + lists.listNotOk.join('\r'));
            }
          }());