Help with Illustrator script to embed ALL linked items
- July 14, 2025
- 3 replies
- 1977 views
Hi everyone! I'm a graphic designer trying to create a JavaScript script for Adobe Illustrator to automatically embed all linked images.
The Problem
I often work with files that contain a large number of linked images. When I need to send a PDF with everything embedded, I have to manually embed each image—sometimes clicking hundreds of times. It's extremely tedious.
I know I can Shift-click all the linked items and choose Links panel menu > Embed Image(s), but Illustrator prompts a confirmation for each individual image, which defeats the purpose.
There must be a more efficient and less painful way to do this.
The Approach
With the help of ChatGPT, I've tried several versions of a script that loop through all placedItems and call .embed() on them. However, they all produce the same issue:
Only some images (like every other one) get embedded.
Some images change size or shift position after being embedded.
I’ve attached screenshots showing the inconsistency. Any ideas why this is happening or how to fix it?
Thanks in advance!
if (app.documents.length > 0) {
var doc = app.activeDocument;
var linkedItems = doc.placedItems;
var count = 0;
for (var i = 0; i < linkedItems.length; i++) {
var item = linkedItems[i];
if (!item.embedded) {
try {
item.embed();
count++;
} catch (e) {
alert("No se pudo incrustar el elemento: " + item.file.name + "\nError: " + e);
}
}
}
alert("Se incrustaron " + count + " elementos enlazados.");
} else {
alert("No hay documentos abiertos.");
}