We need to count all kinds of different images and do something (inject them in a database / give them to an webapi).
What is the best way to do this?- Read the file, make distinction in the objects programmaticly?- Using VBA in CorelDraw, and listen to the events?- Write a macro in VBA , CorelDraw that counts everything?- ... other strategies?
What is the best strategy in CorelDraw to count objects?
KristofR,
Leverage what you know. :-) Since you know C# use it. You didn't mention which version of CorelDRAW you wished to use but you will have the most success with X7 and C#, although you can get most features also in X6.
If you want an example of something written in C# check out the Border and Grommet Feature in X7 Update 3. You may also write dockers for X7 in C#. I can give you some examples of dockers also if you wish.
Now for your question to open a document in C#, certainly. Just remember, for X7 you don't need to import COM type libraries anymore. It comes with pre-built assemblies for .NET. Just expand "Assemblies > Extensions" in Reference Manager in Visual Studio. And also all you need to add the reference to is Corel.Interop.VGCore assembly.
Here is a simple VB.NET Example. Of course if you wanted to know all the shapes in the document you would also want to loop the pages.
Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click Dim app As Corel.Interop.VGCore.Application app = CreateObject("CorelDRAW.Application.17") app.Visible = True Dim doc As Corel.Interop.VGCore.Document = app.OpenDocument("D:\Temp\Test.cdr") MsgBox(doc.ActivePage.Shapes.Count) End Sub
Hopefully that helps get you started. If you have questions, feel free to ask.
-Shelby