cart: empty [ Login ]

Problem with texts exporting dwg to png

1 
IgorK
3/14/2019 2:48 PM
Hi, For a specific drawing (see attachment test_notes.dwg) some text is being exported out of aligment (see orignal_cad.png and exported.png marked in red). Bellow is the code I am using.
C# Code:
public static void ExportToPng(string inputFile, string outPutFolder) { DxfModel model = DwgReader.Read(inputFile); foreach (DxfLayout layout in model.OrderedLayouts) { if (layout.Entities.Count > 0) { double xMin = 0; double yMin = 0; double xMax = 0; double yMax = 0; if (layout.PaperSpace) { xMin = layout.MinExtents.X; yMin = layout.MinExtents.Y; xMax = layout.MaxExtents.X; yMax = layout.MaxExtents.Y; } else { var boundsCalculator = new BoundsCalculator(); boundsCalculator.GetBounds(model); var boundsModel = boundsCalculator.Bounds; xMin = boundsModel.Min.X; yMin = boundsModel.Min.Y; xMax = boundsModel.Max.X; yMax = boundsModel.Max.Y; } if ((xMin + yMin + xMax + yMax) == 0) break; double larguraDesenho = xMax - xMin; double alturaDesenho = yMax - yMin; WW.Math.Point3D pontoATotal = new WW.Math.Point3D(xMin, yMin, 0); WW.Math.Point3D pontoBTotal = new WW.Math.Point3D(xMax, yMax, 0); Bounds3D boundsTotal = new Bounds3D(); boundsTotal.Update(pontoATotal); boundsTotal.Update(pontoBTotal); int width = 1800; int height = (int)((alturaDesenho * width) / larguraDesenho); var point1 = new WW.Math.Point3D(0, height - 1, 0); var point2 = new WW.Math.Point3D(width - 1, 0, 0); var to2DTransform = DxfUtil.GetScaleTransform(boundsTotal.Corner1, boundsTotal.Corner2, point1, point2); GraphicsConfig config = config = (GraphicsConfig)GraphicsConfig.AcadLikeWithBlackBackground.Clone(); config.DisplayLineTypeElementShapes = true; config.TryDrawingTextAsText = false; config.DisplayLineWeight = false; Bitmap bmp = ImageExporter.CreateBitmap(model, layout, null, config, System.Drawing.Color.Black, to2DTransform, new System.Drawing.Size(width, height)); using (MemoryStream stream = new MemoryStream()) { ImageExporter.EncodeImageToPng(bmp, stream); File.WriteAllBytes(string.Format("{0}{1}.png", outPutFolder, layout.Name), stream.ToArray()); } bmp.Dispose(); } } model.Dispose(); }
Any thing I can change in my code to fix it? Edit: Forgot to mention, I am using version 4.0.38.157 Thank you, Igor
exported.png
orignal_cad.png
Wout
3/19/2019 12:03 AM
Hi, The problem has been fixed in the latest CadLib version. You can download it from Your resources in your user profile. Thanks for the report! - Wout
1