• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
0

How to use document Export function from MATLAB

New Here ,
Apr 11, 2022 Apr 11, 2022

Copy link to clipboard

Copied

I am manipulating an InDesign docment from MATLAB:

a = actxserver('InDesign.Application');
doc = a.Open('C:\TEMP\Test-3.indd');
 % make changes then export
 
I've tried different ways to export (example below), but none of them work, because I can't find a way to specify the export format.
b = doc.Export('InDesign.idExportFormat.idInteractivePDF', 'C:\TEMP\Test-2.pdf', false)
 
Any ideas would be appreciated.
 
 
TOPICS
How to , Scripting

Views

475

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
community guidelines
Community Expert ,
Apr 12, 2022 Apr 12, 2022

Copy link to clipboard

Copied

Which language is this?

 

Votes

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
community guidelines
New Here ,
Apr 13, 2022 Apr 13, 2022

Copy link to clipboard

Copied

MATLAB is the language.  It makes use of the COM Interface for InDesign.

 

Votes

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
community guidelines
Community Expert ,
Apr 12, 2022 Apr 12, 2022

Copy link to clipboard

Copied

The method to export is called exportFile for the JS interface, I am not sure if it's named Export for the COM interface. You can check this out

https://www.indesignjs.de/extendscriptAPI/indesign-latest/#Document.html#d1e49413__d1e53790

Another thing that I see could be a potential issue is that according to the link below

https://www.mathworks.com/help/matlab/ref/actxserver.html

It says that "The MATLAB COM Interface does not support invoking functions with optional parameters". So if this means that we need to explicitly pass on all the params then you seem to be lacking some parameters, try passing them on.

-Manan

Votes

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
community guidelines
New Here ,
Apr 13, 2022 Apr 13, 2022

Copy link to clipboard

Copied

Thanks for the input. For the COM interface (and Visual Basic Script) the funciton is Export. Even when I add all the optional parameters, there is still an issue with the first parameter: idExportFormat.idInteractivePDF.

 

Votes

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
community guidelines
Community Expert ,
Apr 13, 2022 Apr 13, 2022

Copy link to clipboard

Copied

I don't have anything setup to test it out personally. But what is the error message that you get, maybe that provides us with a hint. Try doing the same thing using VB, probably the syntax and the constants are the same in both.

-Manan

Votes

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
community guidelines
New Here ,
Apr 14, 2022 Apr 14, 2022

Copy link to clipboard

Copied

This form of the Export function, below, works in VBScript, but gives this error in MATLAB: "Unable to resolve the name idExportFormat.idInteractivePDF."

 

b = doc.Export(idExportFormat.idInteractivePDF, 'C:\TEMP\Test-2.indd', false)

 

The form below, with single quotes, should work similarly to the VBScript version, but errors.

 

b = doc.Export('idExportFormat.idInteractivePDF', 'C:\TEMP\Test-2.indd', false)
Error using Interface.1A5E8DB4_3443_11D1_803C_0060B03C02E4/Export
Invoke Error, Dispatch Exception:
Source: C:\Program Files\Adobe\Adobe InDesign 2022\InDesign.exe
Description: The specified object does not support the desired export format.

 

I get the same error when specifying all the arguments.

 b = doc.Export('idExportFormat.idInteractivePDF', To, showingOptions, 'InDesign.Document.PDFExportPresets', 'InDesign.Document.PDFComments', false)

These arguments are okay: 'InDesign.Document.PDFExportPreset',  'InDesign.Document.PDFComments'. Accessing objects under Documents is not a problem. But accessing the idExportFormat enum in the InDesign namespace doesn't work.

 

I also tried variations of the above with 'InDesign.idExportFormat.idInteractivePDF' as the first argument, but get the same error: "The specified object does not support the desired export format.".

 

Thanks

Votes

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
community guidelines
Community Expert ,
Apr 14, 2022 Apr 14, 2022

Copy link to clipboard

Copied

Ok, that is interesting. Just use that constant to assign it to a variable, to see if the constant is the issue or method call. I now doubt that maybe the call of the function is not at all possible because it's defined with optional arguments, this could be verified if we are able to assign the constant to a variable but not use it in this method call.

-Manan

Votes

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
community guidelines
New Here ,
Oct 12, 2022 Oct 12, 2022

Copy link to clipboard

Copied

The following code works for me:

doc.Export('Adobe PDF', 'C:\TEMP\Test-2.pdf', false);
But I don't know which string I have to use for an Interattive PDF.
Any ideas?

Votes

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
community guidelines
LEGEND ,
Oct 12, 2022 Oct 12, 2022

Copy link to clipboard

Copied

The choice of "interactive PDF" is not a different format to export. It is a choice in your PDF export settings. If you can't specify settings programmatically, then try changing them first in the UI.

Votes

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
community guidelines
New Here ,
Oct 12, 2022 Oct 12, 2022

Copy link to clipboard

Copied

I believe that they are different. Infact, InDesign UI has two different set of export settings, one for PDF and one for interattive PDF.

Anyway after many attempts I found the code that works (if you have italian version of InDesign):

doc.Export('Adobe PDF (interattivo)', 'C:\TEMP\Test-2.pdf', false);

I think that for the English version it is:

doc.Export('Adobe PDF (interactive)', 'C:\TEMP\Test-2.pdf', false);

Votes

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
community guidelines
Community Expert ,
Oct 12, 2022 Oct 12, 2022

Copy link to clipboard

Copied

LATEST

That's correct. They are two distinct export methods. Each has its own type in the scripting DOM.

Votes

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
community guidelines