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.
Copy link to clipboard
Copied
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'));
}
}());