" X " line in the picture

"I am displaying .dwg and .dxf files in a PictureBox in my .NET project using GroupDocs.Viewer. However, there is an extra ‘x’ shape appearing at the center of the image. This ‘x’ shape consists of a line from the top left to the bottom right, and another line from the top right to the bottom left of the image. How can I remove this line? Thank you."x.png (2.1 KB)

1 Like

@nestougur

Please share following details:

  • API version that you are using
  • Source file
  • Do you have API subscription/license?
  • Is this issue file specific or happens for all drawings?

API version : 23.4.0
API license : no
all drawings
source code :

 private void pictureBox1_DragDrop(object sender, DragEventArgs e)
    {
        // Sürükle ve bırak işlemiyle gelen dosyaları al
        string[] files = (string[])e.Data.GetData(DataFormats.FileDrop);
        // Dosyaları döngüyle işle
        foreach (string file in files)
        {
            // Dosya uzantısını al
            string extension = Path.GetExtension(file);
            // Dosya uzantısını kontrol et
            if (extension.Equals(".dwg", StringComparison.OrdinalIgnoreCase) || extension.Equals(".dxf", StringComparison.OrdinalIgnoreCase))
            {
                // DWG veya DXF dosyası bulunduğunda
                isPrivateFile = true;
                // Listbox'a dosya adını ekle
                listBox1.Items.Add(Path.GetFileName(file));
                label1.Text = "Yüklenen Dosyalar / " + listBox1.Items.Count;
                // Dosya adını parçalara ayır
                string fileName = Path.GetFileName(file);
                string[] parts = fileName.Split(' ', '-', '.', '*', '_');
                string mmValue = "";
                string adetValue = "";
                // Parçaları filtrele ve ilgili değerleri al
                foreach (string part in parts)
                {
                    string upperPart = part.ToUpper();

                    if (upperPart.Contains("MM") || upperPart.Contains("M"))
                    {
                        mmValue = new string(part.Where(char.IsDigit).ToArray());
                    }
                    else if (upperPart.Contains("ADET") || upperPart.Contains("ADE") || upperPart.Contains("AD"))
                    {
                        adetValue = new string(part.Where(char.IsDigit).ToArray());
                    }
                }
                using (Viewer viewer = new Viewer(file))
                {
                    string outputDirectory = Path.Combine(Path.GetDirectoryName(file), "output");
                    Directory.CreateDirectory(outputDirectory);
                    ViewInfoOptions viewInfoOptions = ViewInfoOptions.ForHtmlView();
                    viewInfoOptions.CadOptions.RenderLayouts = true;
                    ViewInfo viewInfo = viewer.GetViewInfo(viewInfoOptions) as CadViewInfo;
                    if (viewInfo != null)
                    {
                        int pageNumber = 1;
                        foreach (var layout in viewInfo.Pages)
                        {
                            string outputPngPath = Path.Combine(outputDirectory, "output.png");
                            PngViewOptions viewOptions = new PngViewOptions(outputPngPath);
                            viewOptions.Width = 200;
                            viewOptions.Height = 200;
                            viewOptions.CadOptions.LayoutName = layout.Name;
                            viewer.View(viewOptions);
                            // Oluşturulan resmi PictureBox'a ekleyin
                            using (PictureBox pictureBox = new PictureBox())
                            {
                                pictureBox.BackgroundImage = Image.FromFile(outputPngPath);
                                pictureBox.BackgroundImageLayout = ImageLayout.Zoom;
                                Image resizedImage = ResizeImage(pictureBox.BackgroundImage, 200, 200);
                                // DataGridView'e verileri ekleyin
                                dataGridView1.Rows.Add(extension, mmValue, layout.Width, layout.Height, adetValue, pageNumber.ToString(), resizedImage);
                                //dataGridView1.Size = new System.Drawing.Size((int)(210 / 25.4 * dataGridView1.DeviceDpi), (int)(297 / 25.4 * dataGridView1.DeviceDpi));
                                // PictureBox ve dosyayı temizleyin
                                pictureBox.BackgroundImage.Dispose();
                                pictureBox.BackgroundImage = null;
                                // Delete the file outside the using block
                                File.Delete(outputPngPath);
                                pageNumber++;
                            }
                        }
                    }
                }

            }
        }
        if (!isPrivateFile)
        {
            MessageBox.Show("Herhangi bir dwg veya dxf uzantılı dosya bulunamadı.");
        }
    }
    private Image ResizeImage(Image image, int width, int height)
    {
        var destRect = new Rectangle(0, 0, width, height);
        var destImage = new Bitmap(width, height);
        destImage.SetResolution(image.HorizontalResolution, image.VerticalResolution);
        using (var graphics = Graphics.FromImage(destImage))
        {
            graphics.CompositingMode = System.Drawing.Drawing2D.CompositingMode.SourceCopy;
            graphics.CompositingQuality = System.Drawing.Drawing2D.CompositingQuality.HighQuality;
            graphics.InterpolationMode = System.Drawing.Drawing2D.InterpolationMode.HighQualityBicubic;
            graphics.SmoothingMode = System.Drawing.Drawing2D.SmoothingMode.HighQuality;
            graphics.PixelOffsetMode = System.Drawing.Drawing2D.PixelOffsetMode.HighQuality;

            using (var wrapMode = new ImageAttributes())
            {
                wrapMode.SetWrapMode(System.Drawing.Drawing2D.WrapMode.TileFlipXY);
                graphics.DrawImage(image, destRect, 0, 0, image.Width, image.Height, GraphicsUnit.Pixel, wrapMode);
            }
        }

        return destImage;
    }
1 Like

@nestougur
We have opened the following new ticket(s) in our internal issue tracking system and will deliver their fixes according to the terms mentioned in Free Support Policies.

Issue ID(s): VIEWERNET-4366

You can obtain Paid Support Services if you need support on a priority basis, along with the direct access to our Paid Support management team.

@nestougur

The lines are added in trial mode. You can request a temporary license at Get a Temporary License to evaluate the product without trial limitations.