Note that there are some explanatory texts on larger screens.

plurals
  1. POExtracting InDesign CS4 Graphics using C# and COM
    text
    copied!<p>I'm trying to get details of the graphics in an InDesign file. For technical reasons I'm using COM. Not my favourite, as (discussed elsewhere in StackOverflow) you have to spend half your life casting. In Theory (!), the code snippet belwo should work. Intellisense shows <strong><em>doc.AllGraphics</em></strong> as returning <strong><em>objects</em></strong>. </p> <p>The CS3 scripting reference at <a href="http://www.indesignscriptingreference.com/CS3/JavaScript/Document.htm" rel="nofollow noreferrer">http://www.indesignscriptingreference.com/CS3/JavaScript/Document.htm</a> shows it as <strong><em>Array of Graphic</em></strong></p> <pre><code>for (int g = 1; g &lt;= doc.AllGraphics.Count; g++) { InDesign.Graphic graphic = (InDesign.Graphic) doc.AllGraphics[ g ]; .... } </code></pre> <p>However, I get this error message:</p> <blockquote> <p>Unable to cast COM object of type 'System.__ComObject' to interface type 'InDesign.Graphic'. This operation failed because the QueryInterface call on the COM component for the interface with IID '{6AE52037-9E4E-442D-ADFC-2D492B4BCBEF}' failed due to the following error: No such interface supported (Exception from HRESULT: 0x80004002 (E_NOINTERFACE)).</p> </blockquote> <p>I've tried using alternative constructs to return an object and then cast this to an <strong><em>Indesign.Graphic</em></strong>. All fail with the same error. I can't believe that Adobe missed including this interface.</p> <p>Any suggestions as to a solution so I can get the graphic content?</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload