Highlighted

Scripting to allow opening of non supported file types through the file Open Dialog window

New Here ,
May 05, 2020

Copy link to clipboard

Copied

Using the Plugin SDK, we can create a custom IImportProvider to allow the user to select and import file types not generally supported by InDesign. In short, this allows the user to select our supported file types from the standard Open Dialog. InDesign then passes the file to our custom IImportProvider to process the file. Is there anything similar in the Scripting API?

We're transitioning to a stand-alone application, but still want to offer the same type of user interaction from within InDesign. I've been able to use the Scripting API to create the needed menus. The user can use the custom menu to display an Open Dialog and select file types that we support. The file paths are passed to our stand-alone application, which does the conversion and passes the converted file back to InDesign to be opened. All that works fine.

But what I'm hoping to do is to allow the user to select our supported file types from the standard Open Dialog (File -> Open, not just from our custom menu item).  I thought that I might be able to use an event listener ("beforeOpen" or "afterOpen") to get notified when a user was attempting to open one of our supported file types. But it appears that those are only called when InDesign can open the file, which it fails to do so for these specific file types.

We're trying to avoid going the Plugin SDK route and going with the JavaScript API to simplify development and delivery to end-users. Having a single Script to distribute across all supported version of InDesign and OSs, is much better than having to build Plugins for each version of InDesign across supported OSs.

 

Any insight would be helpful.

Adobe Community Professional
Correct answer by Manan Joshi | Adobe Community Professional

Hi Eddie,

 

I am afraid this does not seem to be possible using the scripting interface. In general scripting is meant to automate, adding any extensibility to the core of the application is out of its purview and needs C++ plugin. So things like import/export provider, services etc can be added only using the C++ sdk.

On another note i wanted to understand what was your plan in case you got the event handler fired notifying that a custom files is being opened, how would you have handled that event callback? If its not a supported format scripting would not be able to handling it in my opinion. I would like to listen more about your propspective workflow, maybe something comes out of the discussion

 

-Manan

TOPICS
Scripting, SDK

Views

733

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more

Scripting to allow opening of non supported file types through the file Open Dialog window

New Here ,
May 05, 2020

Copy link to clipboard

Copied

Using the Plugin SDK, we can create a custom IImportProvider to allow the user to select and import file types not generally supported by InDesign. In short, this allows the user to select our supported file types from the standard Open Dialog. InDesign then passes the file to our custom IImportProvider to process the file. Is there anything similar in the Scripting API?

We're transitioning to a stand-alone application, but still want to offer the same type of user interaction from within InDesign. I've been able to use the Scripting API to create the needed menus. The user can use the custom menu to display an Open Dialog and select file types that we support. The file paths are passed to our stand-alone application, which does the conversion and passes the converted file back to InDesign to be opened. All that works fine.

But what I'm hoping to do is to allow the user to select our supported file types from the standard Open Dialog (File -> Open, not just from our custom menu item).  I thought that I might be able to use an event listener ("beforeOpen" or "afterOpen") to get notified when a user was attempting to open one of our supported file types. But it appears that those are only called when InDesign can open the file, which it fails to do so for these specific file types.

We're trying to avoid going the Plugin SDK route and going with the JavaScript API to simplify development and delivery to end-users. Having a single Script to distribute across all supported version of InDesign and OSs, is much better than having to build Plugins for each version of InDesign across supported OSs.

 

Any insight would be helpful.

Adobe Community Professional
Correct answer by Manan Joshi | Adobe Community Professional

Hi Eddie,

 

I am afraid this does not seem to be possible using the scripting interface. In general scripting is meant to automate, adding any extensibility to the core of the application is out of its purview and needs C++ plugin. So things like import/export provider, services etc can be added only using the C++ sdk.

On another note i wanted to understand what was your plan in case you got the event handler fired notifying that a custom files is being opened, how would you have handled that event callback? If its not a supported format scripting would not be able to handling it in my opinion. I would like to listen more about your propspective workflow, maybe something comes out of the discussion

 

-Manan

TOPICS
Scripting, SDK

Views

734

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
May 05, 2020 0
Adobe Community Professional ,
May 05, 2020

Copy link to clipboard

Copied

Hi Eddie,

 

I am afraid this does not seem to be possible using the scripting interface. In general scripting is meant to automate, adding any extensibility to the core of the application is out of its purview and needs C++ plugin. So things like import/export provider, services etc can be added only using the C++ sdk.

On another note i wanted to understand what was your plan in case you got the event handler fired notifying that a custom files is being opened, how would you have handled that event callback? If its not a supported format scripting would not be able to handling it in my opinion. I would like to listen more about your propspective workflow, maybe something comes out of the discussion

 

-Manan

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
May 05, 2020 0
New Here ,
May 06, 2020

Copy link to clipboard

Copied

Thanks for the reply Manan,

 

I need first to say that I didn't look very deep into the event listeners, but I assumed that I'd be able to get to the file path of the file being opened when receiving the "beforeOpen" event. I thought I'd be able to use that path to determine if it was a file that our stand-alone application could handle, and InDesign natively can't. I could then call our stand-alone application to convert the file and pass the converted file back to InDesign to open as an IDML. Possibly add some logic to make sure that the "afterOpen" wasn't fired for the same file before passing to our stand-alone application, to make sure that InDesign itself didn't somehow handle the file. Or possibly prompt the user with the option to have our application convert the file before proceeding.

 

What would be really useful in this situation would be an event "failedToOpen" that would fire when a file couldn't be opened.

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
May 06, 2020 0
Advisor ,
May 06, 2020

Copy link to clipboard

Copied

You can create an own "Open Whatever ..." scripted menu item straight below the regular "Open ..." that invokes ExtendScript's File.openDialog(prompt,filter,multiSelect) method.

The second "filter" argument in that dialog can be a callback function where you validate/filter the offered files, for example by looking at the extension or at file contents.

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
May 06, 2020 0
Most Valuable Participant ,
May 06, 2020

Copy link to clipboard

Copied

> .. If its not a supported format scripting would not be able to handling it in my opinion

 

It is possible to write an entire import-and-translate to InDesign in Javascript – see for example my markdownid.

I also experimented with "manually" parsing and importing Word .DOC files, entirely circumventing InDesign's at times flaky import. Unfortunately, ExtendScript turned out to be way, waaa-y to slow for this to be a viable alternative solution – but the basic principle worked just fine.

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
May 06, 2020 2
Adobe Community Professional ,
May 06, 2020

Copy link to clipboard

Copied

So as per Eddie's question how can we bypass the import functionality and call our own handler code instead of it. I think the place dialog would not allow you to place anything that is not a supported format. If we can get to the point of triggering our own custom code on the file format of interest then i suppose the problem can be solved as according to Eddies they already have a mechanism in place to handle parsing of the file.

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
May 06, 2020 0
Adobe Community Professional ,
May 06, 2020

Copy link to clipboard

Copied

Hi,

 

Would it not be possible to add scripting functionality to your plugin, so you could add myOwnOpen ( File ( "")); type object.

 

This could use the same code as your open dialog, but bypass that in the script.

 

In the Adobe InDesign CC Plugin SDK document - "Adobe InDesign CC Products Programming Guide Volume 1: Fundamentals"

Section 10 - "Scriptable Plug-in Fundamentals" , this section shows how to add scripting to any custom built plugin.



Regards

Malcolm

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
May 06, 2020 0
New Here ,
May 06, 2020

Copy link to clipboard

Copied

We were hoping to handle this through the JavaScript API. I understand that this could be handled through the Plugin SDK, but we're trying to avoid using that. The JavaScript API is much better for us as we'd be able to create, maintain, and distribute a single Script. With the Plugin SDK, we need to build a specific Plugin for each version of InDesign and platform. If we want to support the two latest versions of InDesign and CS6 (Mac and Win), we would have six Plugins to build, distribute, and maintain.

 

This isn't a deal-breaker as we still can offer the custom menu item. I was hoping for deeper integration, but it seems that's not possible. If a feature request could be created for a new event type "failedToOpen" that would be great, and maybe I could extend our Script in the future.

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
May 06, 2020 0
New Here ,
May 06, 2020

Copy link to clipboard

Copied

That's interesting about handling the import-and-translate entirely in JavaScript. But to be clear, that's not what we're doing. The Script is pretty lightweight. It adds a custom menu item that allows the user to select a supported file type through an Open Dialog. The Script then uses app.doScript to invoke our custom URL Scheme, which launches our application with the arguments needed to do the conversion. Upon completion of the conversion, our application opens the converted file back in InDesign.

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
May 06, 2020 0
Adobe Community Professional ,
May 06, 2020

Copy link to clipboard

Copied

You can post a feature request at the following

https://indesign.uservoice.com/forums/913162-adobe-indesign-sdk-scripting-bugs-and-features

 

This is the best place to catch the attention of InDesign project managers. Once you make a request, post it's link here so people can upvote the request

 

-Manan

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
May 06, 2020 0
New Here ,
May 06, 2020

Copy link to clipboard

Copied

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
May 06, 2020 0