Issue with Image Shifting/Distortion when Embedding Linked Files via Scripting & Save Options
Hello everyone,
I am writing to inquire about a persistent issue regarding embedding linked images in Illustrator.
I work in the large-format printing industry, and my role involves preparing client files for production. Over 90% of our workflow relies on Illustrator. To ensure file portability across different workstations, I typically check "Include Linked Files" in the Save dialog options. However, I have discovered that this standard method causes certain images to shift position or distort after saving.
To address this, I attempted to use ExtendScript to automate the embedding process (specifically using the placedItem.embed() method). While the script successfully fixed the images that were failing during the standard save process, it paradoxically caused similar shifting/distortion issues in other images that previously worked fine. In some cases, both methods fail.
Precision is critical in our industry. We simply do not have the manpower to manually inspect every single file for errors in a process that should ideally be reliable and automatic.
Technical Observations: I have analyzed the problematic files and noticed a pattern:
The shifting/distortion usually occurs with multi-layer files or images with transparent backgrounds (e.g., PSD, TIFF).
These images are often nested within Groups or Clipping Masks.
It appears that when embed() is executed, the linked PlacedItem is converted into a GroupItem or a complex structure. During this conversion, Illustrator seems to fail to correctly recalculate the relative position and dimensions (transformation matrix) of the object within its parent hierarchy, resulting in the shift.
Current Workaround & Limitations: I tried a workaround script that copies the linked item to a temporary "isolation" document, embeds it there, and then copies it back to the original file. While this method solves the coordinate shifting issue, it has significant drawbacks:
It is extremely time-consuming for high-resolution large-format files.
The script relies on app.doScript() (or executeAction) to handle complex Copy/Paste/Ungroup operations via Actions. Due to Illustrator's limitation where a script called by an Action cannot call another Action, I cannot integrate this script into my main automation Action set. This makes the workflow inefficient.
My Question: Is there a known solution or a more robust scripting method to embed these complex, nested linked files without altering their visual appearance (position/scale)?
Note: Using "Package" or keeping external links (e.g., in a "Links" folder) are not viable options for our specific automated workflow. We require the files to be fully embedded.
Any advice or insights would be greatly appreciated.
Thank you.
my script