I want to read InDesign(.indd) file in c#. I have installed adobe InDesignCS6.
I have added COM reference of 'Adobe InDesign CS6 Type Library' in my c# application.
Code snippet is as follows.
[STAThread]
static void Main(string[] args)
{
InDesign.Application app = (InDesign.Application)COMCreateObject("InDesign.Application");
Document doc = app.ActiveDocument;
Page page = doc.Pages[1];
TextFrame frame = page.TextFrames[1];
Console.WriteLine(frame.Contents.ToString());
}
public static object COMCreateObject(string sProgID)
{
// We get the type using just the ProgID
Type oType = Type.GetTypeFromProgID(sProgID);
if (oType != null)
{
return Activator.CreateInstance(oType);
}
return null;
}
But the first line itself throwing an following error while type casting output of COMCreateObject method into InDesign.Application type.
Error :
Unable to cast COM object of type 'System.__ComObject' to interface type 'InDesign.Application'. This operation failed because the QueryInterface call on the COM component for the interface with IID '{ABD4CBB2-0CFE-11D1-801D-0060B03C02E4}' failed due to the following error: No such interface supported (Exception from HRESULT: 0x80004002 (E_NOINTERFACE)).
Kindly help me. Its urgent.