So I'm writing an application in C# that will load artwork into a template file, do some manipulations and then save that file to a printer hotfolder as a pdf.
Everything works fine up to the point where I actually do the publish. I keep getting a Com error HRESULT E_FAIL, which is of little help. I've change all my pdf settings a million different ways, wrote my file paths a million different ways, and yet i'm getting nowhere. If I do this all manually or if I do it via VBA it works fine, so i'm guessing it has something to do with the interfaces im using but I really have no idea. If anyone has some advice that would be greatly appreciated. (If anyone knows how to execute a macro via the C# api, that would be a work around I am interested in.
This is essentially what I'm doing just whittled down to the bones.
private void sample() { VGCore.Application App; VGCore.Document Doc;
//open app Type pia_type = Type.GetTypeFromProgID("CorelDRAW.Application"); App = Activator.CreateInstance(pia_type) as VGCore.Application;
//open doc Doc = App.OpenDocument(@"C:\Blank template.cdr");
//import art Doc.ActiveLayer.Import(@"C:\SomeArt.pdf");
//work with art
//set pdf settings here
//publish final product to pdf _Corel.CorelDoc.PublishToPDF(@"C:\TempHotFolder\finalproduct.pdf");
//^^this line fails everytime : Error HRESULT E_FAIL has been returned from a call to a COM component.
}