Copy link to clipboard
Copied
Is there a scriptable way to Option-Double-Click (Edit Original) a vector AI graphic and have it load into Illustrator; not Acrobat?
Hi Michael,
do you want to open all pages of a placed PDF with Illustrator CC 2018?
If yes, try the ExtendScript ( JavaScript ) code below:
.../**
* @@@BUILDINFO@@@ OpenPlacedPDFWithAdobeIllustrator-SELECTED-GRAPHIC-FRAME.jsx !Version! Tue Sep 04 2018 02:48:33 GMT+0200
*/
/*
Script for InDesign by Uwe Laubender
Select a graphic frame with a placed PDF.
The script tries to open all pages of the placed PDF with Adobe Illustrator.
Tested with InDesign CC 2018.1 and Illustrator CC 2018 i
Copy link to clipboard
Copied
InDesign just follows OS settings, simple as that. If Illustrator is set as a default app for ai files, Edit Original in ID will open placed ai in Illustrator. What happens when you double-click ai file in a Finder?
Or I didn't get the question?
Copy link to clipboard
Copied
Oops. I meant the OTHER vector filetype: PDF (what I should have written). I wonder if it could be scriptable for the computer running ID to know that this placed vector PDF file should open in Illustrator when Opt-Dbl-Clicking it. (Please, Dov, don't remind me about editing PDF in Illustrator! )
Copy link to clipboard
Copied
Hi Michael,
what's your version of InDesign?
What's the corresponding version of Illustrator?
Regards,
Uwe
Copy link to clipboard
Copied
Both are the latest CC 2018 versions.
Copy link to clipboard
Copied
Hi Michael,
do you want to open all pages of a placed PDF with Illustrator CC 2018?
If yes, try the ExtendScript ( JavaScript ) code below:
/**
* @@@BUILDINFO@@@ OpenPlacedPDFWithAdobeIllustrator-SELECTED-GRAPHIC-FRAME.jsx !Version! Tue Sep 04 2018 02:48:33 GMT+0200
*/
/*
Script for InDesign by Uwe Laubender
Select a graphic frame with a placed PDF.
The script tries to open all pages of the placed PDF with Adobe Illustrator.
Tested with InDesign CC 2018.1 and Illustrator CC 2018 installed on Windows 10.
Code posted at:
Script to edit AI on page in ID into AI?
Michael Witherell Sep 4, 2018
https://forums.adobe.com/message/10598534#10598534
*/
( function()
{
if( app.documents.length == 0 ){ return };
if( app.selection.length != 1 ){ return };
if( app.selection[0].hasOwnProperty("baselineShift") ){ return };
if( app.selection[0].allGraphics.length == 0 ){ return };
var link = app.selection[0].allGraphics[0].itemLink ;
if( link.linkType == "Adobe Portable Document Format (PDF)" && link.name.match(/\.pdf$/i) )
{
var file = link.filePath ;
if(!File(file).exists){ alert("ERROR: Cannot find file!" ); return };
}else{ return };
var bt = new BridgeTalk;
bt.target = "illustrator";
var aiScript = 'var oldInteractionLevel = app.userInteractionLevel;\n';
aiScript += 'app.userInteractionLevel = UserInteractionLevel.DONTDISPLAYALERTS;\n';
aiScript += 'app.preferences.PDFFileOptions.pageRangeToOpen = "all";\n';
aiScript += 'app.preferences.PDFFileOptions.pDFCropToBox = PDFBoxType.PDFMEDIABOX;\n';
aiScript += 'app.preferences.PDFFileOptions.placeAsLinks = false;\n';
aiScript += 'app.open(File(\"' + file + '\"));\n';
aiScript += 'app.userInteractionLevel = oldInteractionLevel;\n';
bt.body = aiScript ;
bt.send( 30 );
}() )
Important: Before running the script select the graphic frame that is holding the placed PDF.
It will open all pages of the placed PDF with Illustrator. You will not be notified on missing fonts. You will not be asked anything. I changed the user interaction level of Illustrator to "Do Not Display Alerts". The original level is restored after opening the PDF.
You might know this:
The opened PDF file will open as unnamed in Illustrator.
You could give the script a keyboard shortcut.
Regards,
Uwe
Copy link to clipboard
Copied
Thank you, Uwe! What fun!
I copied your code and saved it as a .JSX file. I installed it under User scripts. I gave it a custom shortcut of Opt-I. When I placed a named single-artboard PDF on the ID page, I next pressed Opt-I and it immediately opened in Illustrator. It seems to retain its filename in the Illy titlebar tab. So far, all delightful. No more clumsy Open With (and InDesign cannot seem to remember to list and use Illustrator!)
Oddly, once a minor edit was made in Illustrator, and the changes Saved, the PDF immediately and unnecessarily opens in Acrobat! Two steps forward; one step back! I am testing this on my Windows 10 machine; I haven't yet tested on macOS.
What would be awesome if it could listen for an Option-Double-Click, like any bitmap filetype can do, and then load into Illustrator; not Acrobat.
BTW, this request is based on a question from a student in class, and it got my mental gears spinning... Thanks again! Tomorrow I will try it on a macOS.
Copy link to clipboard
Copied
… It seems to retain its filename in the Illy titlebar tab.…
That seems to be the case with PDFs that have only one single page.
If multipage PDFs are opened in Illustrator they will open as untitled.
… Oddly, once a minor edit was made in Illustrator, and the changes Saved, the PDF immediately and unnecessarily opens in Acrobat! …
Hm. Strange, I cannot see this behavior with one of my test files. Even after updating the placed PDF in InDesign and running the script again on the updated placed frame.
… What would be awesome if it could listen for an Option-Double-Click, like any bitmap filetype can do, and then load into Illustrator; not Acrobat.…
Hm. That would perhaps require a start-up script with an event listening mechanism.
I'm not sure, if that would work at all or is reliable.
Regards,
Uwe
Copy link to clipboard
Copied
Oddly, once a minor edit was made in Illustrator, and the changes Saved, the PDF immediately and unnecessarily opens in Acrobat! Two steps forward; one step back! I am testing this on my Windows 10 machine; I haven't yet tested on macOS.
I'm seeing that too with this AppleScript
tell application "Adobe InDesign CC 2018"
if class of selection is PDF then
set p to file path of item link of selection
tell application "Adobe Illustrator"
open p
end tell
end if
end tell
Copy link to clipboard
Copied
Very strange Rob,
tested my script on some more placed PDFs and still cannot see that the PDFs will open in Acrobat after doing some changes and saving.
Regards.
Uwe
Copy link to clipboard
Copied
https://forums.adobe.com/people/rob+day wrote
… I'm seeing that too with this AppleScripttell application "Adobe InDesign CC 2018" if class of selection is PDF then set p to file path of item link of selection tell application "Adobe Illustrator" open p end tell end if end tell
Hi Rob,
just tested your script with InDesign CC 2018.1 and Illustrator CC 2018.
Unfortunately I get an error message from Illustrator:
AppleScript Error!
Error number: -10000
Error string: "Adobe Illustrator" recieved an error: Error in AppleEvent-Routine
Note: Had selected the placed PDF inside its container frame before running the script.
The script is stored in my Dropbox account that I connected through an alias folder to InDesign's Script Folder in the Application folder of InDesign.
Regards,
Uwe
Copy link to clipboard
Copied
Laubender wrote
…
AppleScript Error!
Error number: -10000
Error string: "Adobe Illustrator" recieved an error: Error in AppleEvent-Routine
I have no problems with Rob's AppleScript if the placed PDF is located e.g. on my Desktop and not on the said external start-up disk with OS X 10.6.8 that has the same name like another external start-up disk. I booted with another disk where OS X 10.11.6 is installed.
Regards,
Uwe
Copy link to clipboard
Copied
… Tomorrow I will try it on a macOS.
Hi Michael,
just tried my code from reply 5 on Mac OS X 10.11.6 with InDesign CC 2018.1 and Illustrator CC 2018.
Will not work, because it always throws an error in line 35 that says that the PDF file does not exist. That's very strange because I can get the full path of the placed file written to the JavaScript Console of the ESTK.
Will see into this problem again later…
In the meanwhile I will test Rob's AppleScript code from reply 8.
Regards,
Uwe
Copy link to clipboard
Copied
Laubender wrote
… just tried my code from reply 5 on Mac OS X 10.11.6 with InDesign CC 2018.1 and Illustrator CC 2018.
Will not work, because it always throws an error in line 35 that says that the PDF file does not exist. That's very strange because I can get the full path of the placed file written to the JavaScript Console of the ESTK. …
Hm. Something's in the path enforced file.exists == false.
If I store the placed PDF on my Desktop my script from reply 5 is running fine.
Regards,
Uwe
Copy link to clipboard
Copied
Ah. I begin to see where my error is.
The placed PDF was stored on a non-active start-up disk which has the same name as another non-active start-up disk mounted. The disk with the PDF has an old OS X 10.6.8 system. That may also weigh in to this special case.
All tests with InDesign CC 2018.1 and Illustrator CC 2018 22.1 made on a start-up disk with OS X 10.11.6.
Regards,
Uwe
Copy link to clipboard
Copied
Hi Rob and Uwe,
I just tried Rob's AppleScript on my MacBook Pro. I could only get it to work if the graphic was directly selected rather than the frame. Can it work if the frame object is selected?
Mike
Copy link to clipboard
Copied
and...
I just tried Uwe's script on my MacBook Pro, and it works fine. After editing a PDF and saving it, it does not open in Acrobat.
Copy link to clipboard
Copied
If I select the PDF and choose Links>Edit With... Illustrator, make an edit when the PDF opens in AI, followed by a save, Acrobat opens.
Same thing happens if I use Open With, and then an Edit from the OSX Finder.
It's also happening when I use Uwe's JS. Using the latest OSX, so it doesn't seem to be related to the script
Copy link to clipboard
Copied
I just tried Uwe's script on my MacBook Pro, and it works fine.
Is it running the latest OS?
Copy link to clipboard
Copied
10.12.6