Access FilterAILib::AIExport class in VSTA

Windows 10 Pro 64, CorelDRAW 2019 Version 21.3.0.755, Visual Studio 2017 Community v15.7.4 - VSTA 2017

I'm writing a VSTA script to export layers to Adobe Illustrator (.ai) files.  I know that I need to call the Document.ExportEx method to obtain the ExportFilter in order to set some parameters without requiring the user to deal with the dialog box.  Problem is, I can't access the AIExport class because it is not defined and I don't know what namespace to reference and assembly to load for it.

Here's my code:

            ExportFilter fltrExport;
            StructExportOptions optExport = new StructExportOptions();
            Rect rectBoundingBox = new Rect()
            string strExportFilename;
            Document theDoc = app.ActiveDocument;
            Page thePage = theDoc.ActivePage;

                 ...

                optExport.MaintainAspect = true;
                optExport.MaintainLayers = false;
                optExport.Matted = false;
                optExport.Overwrite = true;
                optExport.set_ExportArea(rectBoundingBox);
                optExport.UseColorProfile = false;

                foreach (Layer theLayer in thePage.Layers)
                {
                    if (!theLayer.IsSpecialLayer)
                    {
                        if (theLayer.Visible)
                        {
                            theLayer.Printable = true;
                            fltrExport = theDoc.ExportEx(strExportFilename + theLayer.Name + cstrExportFileExtension, cdrFilter.cdrAI, cdrExportRange.cdrCurrentPage, optExport, null);
                            if (fltrExport == null)
                            {
                                ...
                            }
                            else
                            {
                                AIExport AIExportFilter = fltrExport as AIExport;
                                if(AIExportFilter == null)
                                {
                                    ...
                                }
                                else
                                {
                                    AIExportFilter.PreserveTransparency = true;
                                    AIExportFilter.Version = AiVersion.aiVersion8;
                                    AIExportFilter.Finish();
                                }
                            }
                        }
                    }
                }

I hope I formatted my code correctly.  First time submitting code here.

I first tried accessing the AI-specific properties directly through fltrExport, but that failed, of course, because they aren't defined in ExportFilter.

Can you tell me how to reference the AIExport class, or how to correct my code to make it work?

Parents
No Data
Reply
  • 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[1];
    
                    param[0] = 2;
                    fltExport.GetType().InvokeMember("Version", BindingFlags.SetProperty, null, fltExport, param);
    
                    param[0] = true;
                    fltExport.GetType().InvokeMember("PreserveTransparency", BindingFlags.SetProperty, null, fltExport, param);
    
                    fltExport.Finish();
    

    Happy coding!

    -Shelby

Children
No Data