DWG to PDF conversion with custom plot configuration

Hi,

As discussed privately with the Doconut team, we detected a possible inconsistency regarding the separation of Doconut into the plugin structure, separating the converter from the main package, in which the process of converting DWG to PDF, the previous CadConfig configuration options are no longer available for usage.

The previous package, with built-in converter, Doconut.NET6 version 26.6.0, had the mentioned capabilities, but the problem was replicated with the following plugin combinations:

  1. Doconut.NET6 + Doconut.NET6.Converter version 26.7.0
  2. Doconut.NET6 + Doconut.NET6.Converter version 26.8.0
  3. Doconut.NET6 + Doconut.NET6.Converter version 26.9.0
  4. Doconut.NET8 + Doconut.NET8.Converter version 26.7.0
  5. Doconut.NET8 + Doconut.NET8.Converter version 26.8.0
  6. Doconut.NET8 + Doconut.NET8.Converter version 26.9.0

In this context, on version 26.7.x and superior, when the Doconut.NETx.Converter was introduced, the ExportToPdf method is not longer publicly accessible anymore and, in the new methods available in the plugin package, we did not manage to find any configuration argument, like the mentioned CadConfig, in which would be possible to set the criteria for the PDF plot process using a DWG file as base, including layer configuration (model vs layout), color control (monochrome vs color), default render, etc.

Previous plugins example:

var config = new CadConfig
{
    DefaultRender = request.DefaultRender,
    ShowColor = request.ShowColor,
    WhiteBackground = request.WhiteBackground,
    ShowModel = request.ShowModel,
    ShowLayouts = request.ShowLayouts,
    LineWidth = 1,
    Check3DSolid = false,
    LimitMaximumSize = true,
    QualityImage = CadConfig.Quality.High,
    QualityText = CadConfig.Quality.High,
    ShowAllLayoutsDgn = true,
};

var docViewer = new Viewer(_cache, _accessor, licenseFilePath);
var token = docViewer.OpenDocument(dwgPath, config, documentOptions);

docViewer.ExportToPdf(pdfPath);

The new plugins, as mentioned, no longer expose the ExportToPdf method and present a new ConvertAsync, in which contemplates the following scenarios, without configuration options:

public Task<Stream> ConvertAsync(string filePath, ConversionTarget target, string? password = null, CancellationToken ct = default);

public Task<Stream> ConvertAsync(Stream source, string sourceExtension, ConversionTarget target, string? password = null, CancellationToken ct = default);

In the therefore mentioned talk with the Doconut team, we’re asked to open this discussion on the forum for proper verification from the support team with the communication that, if this problem is verified, this is probably due to a migration error to the plugin structure and would be addressed in a future update.

Best regards,
Profits Consulting

Hi @profitsconsulting

Due to an issue with our website, the response we previously posted in this thread was accidentally deleted. We apologize for the inconvenience and are reposting with updated info.

Thank you for your patience while we investigated this, and for the detailed report and code sample.

We have confirmed the issue. When conversion moved from the viewer into the Converter plugin (26.7.0), ConvertAsync stopped accepting configuration options. The settings you used through CadConfig with ExportToPdf are therefore not applied when converting DWG/DXF/DGN files: model vs. layouts, color vs. monochrome, background, line width, rendering quality, size limits, and PDF/A. The same limitation affects the conversion options of other source formats as well.

This will be fixed in release 26.11.0 , for all supported frameworks (.NET 8, .NET 6, .NET Standard 2.1, and .NET Framework 4.7.2).

The Converter plugin will accept a set of conversion options for each source format, passed directly to ConvertAsync , without opening the document in the viewer first. For CAD files, these options will cover the settings in your sample (ShowColor , WhiteBackground , ShowModel , ShowLayouts , LineWidth , LimitMaximumSize , QualityImage , QualityText , ShowAllLayoutsDgn ), so your configuration can be carried over with minimal changes. Calls without options will continue producing exactly the same output as today.

Until 26.11.0 is available, you can continue using Doconut.NET6 26.6.0 for your CAD-to-PDF conversions, since that version applies these settings.

We will update this thread when 26.11.0 is published, including a code example for the CAD conversion scenario.

1 Like