Skip to main content
Mike Witherell
Community Expert
Community Expert
September 3, 2018
Answered

Script to edit PDF on page in ID into AI?

  • September 3, 2018
  • 3 replies
  • 2322 views

Is there a scriptable way to Option-Double-Click (Edit Original) a vector AI graphic and have it load into Illustrator; not Acrobat?

This topic has been closed for replies.
Correct answer Laubender

Both are the latest CC 2018 versions.


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

3 replies

Mike Witherell
Community Expert
Community Expert
September 4, 2018

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.

Mike Witherell
rob day
Community Expert
Community Expert
September 4, 2018

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

Mike Witherell
Community Expert
Community Expert
September 4, 2018

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

Mike Witherell
winterm
Legend
September 3, 2018

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?

Mike Witherell
Community Expert
Community Expert
September 3, 2018

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! )

Mike Witherell
Community Expert
September 4, 2018

Hi Michael,

what's your version of InDesign?
What's the corresponding version of Illustrator?

Regards,
Uwe