2
DocumentConverter exception when converting DWG to PNG: Parameter is invalid
Problem reported by Alessandro Rossetto - 11/30/2018 at 1:40 AM
Resolved
Just got this error converting DWG Sample File downloaded from DocumentUltimate demo.
 
Here's the stack trace:
Parameter is not valid.
at System.Drawing.Bitmap..ctor(Int32 width, Int32 height, PixelFormat format)
at System.Drawing.Bitmap..ctor(Int32 width, Int32 height)
at _Jc.CreateBitmap(_YBA model, _nqA transform, _Vi graphicsConfig, SmoothingMode smoothingMode, Int32 width, Int32 height)
at _Jc.CreateAutoSizedBitmap(_YBA model, _nqA transform, _Vi graphicsConfig, SmoothingMode smoothingMode)
at _FTj._fBj(_YBA model, _Vi graphicsConfig, Stream stream, DocumentFormat format)
at _FTj._faj._fqj(Stream stream)
at _FzI._f3I(ConversionContext conversionContext, Action`1 diskSaveCallback, Action`1 streamSaveCallback)
at _FTj._f3I(OutputContext outputContext)
at GleamTech.DocumentUltimate.DocumentConverter._FLj(OutputContext outputContext, Nullable`1 engine)
at GleamTech.DocumentUltimate.DocumentConverter.ConvertTo(Stream outputStream, OutputOptions outputOptions, Nullable`1 engine)
at GleamTech.DocumentUltimate.DocumentConverter.ConvertTo(Stream outputStream, DocumentFormat outputFormat, Nullable`1 engine)
And here's the code:
using (var inputStream = await blob.OpenReadAsync())
{
    var converter = new DocumentConverter(inputStream, format.Value);
    using (var outputSream = new System.IO.MemoryStream())
    {
        converter.ConvertTo(outputSream, DocumentFormat.Png);
        outputSream.Seek(0, System.IO.SeekOrigin.Begin);

        //resize image in outputStream and upload to storage
    }
}
 
With some dwg sample files from autocad website it does work without exceptions...
Am I making something wrong?
Alessandro Rossetto

1 Reply

Reply to Thread
0
Cem Alacayir Replied
Employee Post
FYI, this is now fixed in Version 4.4.5 - December 12, 2018:
 
Fixed: "Parameter is not valid" error when converting Cad formats to image files. If the drawing is too large, the image will be limited to maximum 1123x1123 dimension to prevent this Bitmap memory related error.

Reply to Thread