Use C++ to export svg error

I export svg with COM interface in C++. Hear's my codes:

try
{
app->Visible = VARIANT_TRUE;
VGCore::IVGDocumentPtr doc = app->ActiveDocument;
if (!doc)
{
QMessageBox::warning(nullptr, tr("No active document"), tr("No active document in CorelDRAW!"));
return nullptr;
}

qDebug() << "selection count:" << doc->Selection()->Shapes->Count;
VGCore::cdrExportRange range = VGCore::cdrExportRange::cdrCurrentPage;
if (doc->Selection()->Shapes->Count > 0)
{
range = VGCore::cdrExportRange::cdrSelection;
}

tmpSvgFilename = utils::createUUID() + ".svg";
tmpSvgFilename = tmpDir.absoluteFilePath(tmpSvgFilename);
//QString tmpSvgFilename("d:/tmp.svg");

qDebug().noquote() << "export corel draw active document to" << tmpSvgFilename;

VGCore::IVGStructExportOptionsPtr opt = app->CreateStructExportOptions();
VGCore::IVGStructPaletteOptionsPtr pal = app->CreateStructPaletteOptions();
opt->AntiAliasingType = VGCore::cdrNormalAntiAliasing;
opt->ImageType = VGCore::cdrRGBColorImage;
opt->ResolutionX = 72;
opt->ResolutionY = 72;
pal->PaletteType = VGCore::cdrPaletteOptimized;
pal->NumColors = 16;
pal->DitherType = VGCore::cdrDitherNone;
VGCore::ICorelExportFilterPtr filter = doc->ExportEx(typeUtils::qStringToBstr(tmpSvgFilename), VGCore::cdrSVG, range, opt, pal);
if (filter->HasDialog)
{
if (filter->ShowDialog(0))
{
hr = filter->Finish();
if (FAILED(hr))
{
qDebug() << hr;
QString errorMessage = QString::fromLocal8Bit(std::system_category().message(hr).c_str());
qWarning() << errorMessage;
}
}
}
}
catch (_com_error& ex)
{
//QString errorMsg = (LPTSTR)ex.ErrorMessage();
//wprintf(L"Error occurred: 0x%08X (%s)\n", ex.Error(), ex.ErrorMessage());
QString errorMessage = QString::fromLocal8Bit(std::system_category().message(ex.Error()).c_str());
qDebug() << errorMessage;
}

And I got an error information: "The remote procedure call failed."

How to fix this error. Thanks.

  • Hi,

    Warm Greetings & welcome, happy to have you here.

    Some non-Adobe programs that can open an SVG record incorporate Microsoft Visio, CorelDRAW, Corel PaintShop Pro, and CADSoftTools ABViewer. Inkscape and GIMP are sans two projects that can work with SVG documents, however, you should download them so as to open the SVG record.

    I hope the above information helped you

    Please feel free to post if you have any further queries!

     

    Regards,
    Mika Hawkins