I'm writing a C# script using VSTA to export each layer in a drawing as its own Adobe Illustrator file (.ai). That much is straightforward and I've been able to do that. The trick, though, and what I'm having trouble with, is that I have to set the version of the AI file, and that's done in the dialog box that appears to they user as a part of the export process. However, since this is, essentially, a batch process, I don't want to make the user have to deal with the dialog each time one of these files is exported; thus, I need to be able to set the AI version programmatically. I am able to do this in a VBA macro, but I cannot get my code to compile in my C# script.
The algorithm is the same in both languages: For each file to export, set your output options, call the document's ExportEx method, then use the ExportFilter object it returns to set any remaining options, including those for the specific file type, ending up with a call to ExportFilter.Finish to actually perform the export.
This works as described in the Corel documentation in VBA, but not in C#, as (I believe) ExportFilter is a Variant and, therefore, recognizes the Version property that is specific to the .ai files. However, C# is more strongly typed and, therefore, ExportFilter does not expose the file type-specific properties. Therefore, I'm using AIExport instead, which is class that is described in the Corel API for my version of CorelDRAW, that does expose the Version property. The problem is that AIExport is not recognized at compile time, so my compile fails.
The normal way this is resolved is to provide the namespace in the code and add a reference to the assembly in the project properties. The problem is that the Corel API documentation does not provide that information, nor have I been able to find it anywhere. And that includes Corel Technical Support, which has literally REFUSED to provide me with that information, referring me to this forum instead. My previous posting regarding this problem has been viewed 69 times with 0 responses.
I'm at a dead end and could really use some help here. My specific questions are:
1. Is AIExport the correct class to use here?
2. If so, how/where can I get the namespace and assembly file so that I can use it?
3. If not, what is the proper way to do what I'm trying to do?
Here's an excerpt of my code showing the relevant parts:
I hope the code snippet made it here - I don't see it in the preview.
Apparently, the code snippet didn't make it. Here's a screenshot:
I know this thread is old, but I needed to do this yesterday and saw the question but no answer. So here is how I ended up getting it to work.
corel.StructExportOptions optExport = corelApp.CreateStructExportOptions();
optExport.UseColorProfile = false;
corel.ExportFilter fltExport = d.ExportEx(Path.GetTempPath() + "MyTestFile.ai", corel.cdrFilter.cdrAI, corel.cdrExportRange.cdrAllPages, optExport);
object param = new Object;
param = 2;
fltExport.GetType().InvokeMember("Version", BindingFlags.SetProperty, null, fltExport, param);
param = true;
fltExport.GetType().InvokeMember("PreserveTransparency", BindingFlags.SetProperty, null, fltExport, param);
Deep, deep wisdom.