• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
0

Export indesign linked files as pdf files?

Community Expert ,
Nov 17, 2016 Nov 17, 2016

Copy link to clipboard

Copied

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.

TOPICS
Scripting

Views

242

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Nov 20, 2016 Nov 20, 2016

Copy link to clipboard

Copied

LATEST

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.filePath) === false) {

        if (links.status === LinkStatus.NORMAL) {

          listOk.push (links.filePath);

        } else {

          listNotOk.push (links.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), [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.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'));

  }

}());

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines