I am having issues with two Curve methods that does not agree with API documentation and I don't know how to work aroundas as they show stoppers for me ..
Using CorelDRAW X6 (yeah, I know it is old, but still works)
namespace Corel.Interop.CorelDRAW{ [Guid("398C000F-8583-4382-B9A1-4BDF347594AC")] [TypeLibType(4176)] public interface IDrawCurve
[DispId(1610743823)] CurveElement[] GetCurveInfo(); [DispId(1610743824)] int PutCurveInfo(ref CurveElement[] Source, int NumElements = -1);
Now using CorelDRAW Standard 2021 ...
namespace VGCore{ [Guid("B0580019-9AA4-44FD-9547-4F91EB757AC4")] [TypeLibType(4160)] public interface IVGCurve {
[DispId(1610743823)] Array GetCurveInfo(); [DispId(1610743824)] int PutCurveInfo(ref Array Source, int NumElements = -1);
As you can see, it has changes using CurveElement[] type to System.Array which does not match the C# API documentation?
CorelDRAW Graphics Suite 2023
Here is code sample showing the issue, using C#
using System;
using VGCore;
namespace CorelDRAWTest{ class Program { static void CreateTextInCorelDRAW(string text, string fontName, float fontSize) { Type pia_type = Type.GetTypeFromProgID("CorelDRAWStandard.Application.23"); Application app = Activator.CreateInstance(pia_type) as Application; app.Visible = true; Document doc = app.ActiveDocument; if (doc == null) doc = app.CreateDocument(); Shape shape = doc.ActiveLayer.CreateArtisticText( 0.0, 0.0, text, cdrTextLanguage.cdrLanguageMixed, cdrTextCharSet.cdrCharSetMixed, fontName, fontSize, cdrTriState.cdrUndefined, cdrTriState.cdrUndefined, cdrFontLine.cdrMixedFontLine, cdrAlignment.cdrLeftAlignment);
CurveElement[] ce = new CurveElement[4];
ce[0].ElementType = cdrCurveElementType.cdrElementStart; ce[0].PositionX = 0; ce[0].PositionY = 0; ce[1].ElementType = cdrCurveElementType.cdrElementLine; ce[1].PositionX = 2; ce[1].PositionY = 0; ce[2].ElementType = cdrCurveElementType.cdrElementLine; ce[2].PositionX = 1; ce[2].PositionY = 2; ce[3].ElementType = cdrCurveElementType.cdrElementLine; ce[3].PositionX = 0; ce[3].PositionY = 0;
app.ActiveShape.Curve.PutCurveInfo(ref ce, ce.Length);
} static void Main(string[] args) { try { CreateTextInCorelDRAW("Hello, world", "Arial", 24.0f); } catch (Exception ex) { Console.WriteLine("Error occurred: {0}", ex.Message); } } }}
The issue with your code is that your shape is text and not a curve. PutCurveInfo only works on a Curve.
I took your example code and put it into a docker I created with CorelDraw Addons Templates addon for Visual Studio 2022. Changed the few lines I needed and then added a line to convert your shape (text) to curves.
Its not of course that useful because the text just gets transformed into a triangle. Which will also not have an outline color because text does not have an outline color. You basically get an invisable triangle. :-)
Anyway, the point is the code works as long as you are using a curve. Here is the full code if your are interested.
using System; using System.Windows; using System.Windows.Controls; using Corel.Interop.VGCore; using corel = Corel.Interop.VGCore; namespace SampleDockerCSharp { public partial class DockerUI : UserControl { private corel.Application corelApp; private Styles.StylesController stylesController; public DockerUI(object app) { InitializeComponent(); try { this.corelApp = app as corel.Application; stylesController = new Styles.StylesController(this.Resources, this.corelApp); } catch { global::System.Windows.MessageBox.Show("VGCore Erro"); } } private void UserControl_Loaded(object sender, RoutedEventArgs e) { stylesController.LoadThemeFromPreference(); } private void Button_Click(object sender, RoutedEventArgs e) { try { CreateTextInCorelDRAW("Hello, world", "Arial", 24.0f); } catch (Exception ex) { Console.WriteLine("Error occurred: {0}", ex.Message); } } private void CreateTextInCorelDRAW(string text, string fontName, float fontSize) { Document doc = corelApp.ActiveDocument; if (doc == null) doc = corelApp.CreateDocument(); Shape shape = doc.ActiveLayer.CreateArtisticText( 0.0, 0.0, text, cdrTextLanguage.cdrLanguageMixed, cdrTextCharSet.cdrCharSetMixed, fontName, fontSize, cdrTriState.cdrUndefined, cdrTriState.cdrUndefined, cdrFontLine.cdrMixedFontLine, cdrAlignment.cdrLeftAlignment); shape.ConvertToCurves(); CurveElement[] ce = new CurveElement[4]; ce[0].ElementType = cdrCurveElementType.cdrElementStart; ce[0].PositionX = 0; ce[0].PositionY = 0; ce[1].ElementType = cdrCurveElementType.cdrElementLine; ce[1].PositionX = 2; ce[1].PositionY = 0; ce[2].ElementType = cdrCurveElementType.cdrElementLine; ce[2].PositionX = 1; ce[2].PositionY = 2; ce[3].ElementType = cdrCurveElementType.cdrElementLine; ce[3].PositionX = 0; ce[3].PositionY = 0; corelApp.ActiveShape.Curve.PutCurveInfo(ref ce, ce.Length); } } }