DraftSight COM native C++ API IPrintManager set Printer exception

Hi, I’m creating an add-in for DraftSight using the COM native C++ API, following the sample projects and the reference documentation.

In particular, I’m trying to print a drawing to a PDF file using the IPrintManager interface.

I have succeeded in getting the print manager from the application, and setting the desired options for printing, except for the following issue which is blocking me.

When I try to set the name of the printer to use by setting the Printer property to string “PDF” (or anything else than an empty string “”), the application raises an exception inside an internal function put_Printer when accessing location for writing, as if the memory for some internal member that should store the string has not been allocated.

I don’t have the same issue when setting another property that also accepts a string, like PaperSize for example which seems to work well without raising any exception.

Remark: if I try creating a C# add-in and use the printing interface like in the sample C# code provided in the documentation, everything works well. In fact, the Printer property of PrintManager appears to be set to “None” as a default value, and then I can set it to the desired printer “PDF” successfully and proceed to print the file as I wanted. I would like to keep using the COM native C++ API in production, so switching to C# would not be a viable option.

I’m using Visual Studio 2022 as IDE, and I observed the above behavior both with DraftSight API 2022 SP2 and also 2024 SP4, on both Windows 10 and 11.

What am I missing or doing wrong?

DraftSight APIC++add-inIPrintManagerprinterexception