我正在尝试使用Adobe InDesign CC进行自动页面设计。
这是我在C#中的代码:
public class HomeController : Controller
{
public ActionResult Index()
{
object missing = Type.Missing;
Type type = Type.GetTypeFromProgID("InDesign.Application");
if (type == null)
{
throw new Exception("Adobe InDesign CC is not installed");
}
_Application app = (_Application)Activator.CreateInstance(type);
Document document = (Document)app.Documents.Add(true, missing);
Page page = (Page)document.Pages[1];
TextFrame textFrame = page.TextFrames.Add(missing,
idLocationOptions.idUnknown, missing);
textFrame.GeometricBounds = new string[] { "6p", "6p", "24p", "24p" };
textFrame.Contents = "Hello from .Net!";
return View();
}
现在当我运行它时会给我这个错误:
An exception of type 'System.Runtime.InteropServices.COMException' occurred in mscorlib.dll but was not handled in user code
Additional information: Retrieving the COM class factory for component with CLSID {FB6F0F4B-0467-4F63-88EC-3960B8E1B3EE} failed due to the following error: 80080005 Server execution failed (Exception from HRESULT: 0x80080005 (CO_E_SERVER_EXEC_FAILURE)).
错误发生在行中:
_Application app = (_Application)Activator.CreateInstance(type);
这是截图:
另外,当我运行此代码时,Adobe Indesign会被打开,但在出现错误之前不会发生任何事情。