We're sorry Aspose doesn't work properply without JavaScript enabled.

Free Support Forum - aspose.com

PNG Line widths

I’m working on a project with Aspose.CAD for .NET 3.0. While it is mostly functional, I’m having some trouble with the line widths.

While the pdf and png scaled to 1700x1100 have acceptable line widths, the text is unacceptably low resolution on the png. Increasing the resolution to 3400x2200 makes the text legible, but the line widths are now too small: in fact, it seems the lines are 1 pixel wide in both sizes.

Is there any way to increase the line widths? I’ve tried this procedure:
foreach (Aspose.CAD.FileFormats.Cad.CadTables.CadLayerTable layer in DXF.Layers)
System.Console.WriteLine(layer.Name + " " + layer.LineWeight);
// -3 means default linewidth set by LWDEFAULT, may be processed separately
//if (layer.LineWeight > 0)
layer.LineWeight *= 50;

And have thrown various scaling related settings into the rasterization process:

Aspose.CAD.ImageOptions.CadRasterizationOptions rasterizationOptions = new Aspose.CAD.ImageOptions.CadRasterizationOptions();
rasterizationOptions.PageWidth = 3400 / mcpType.ScaleFactor;
rasterizationOptions.PageHeight = 2200 / mcpType.ScaleFactor;
//rasterizationOptions.Zoom = 2;
//rasterizationOptions.RelativeScale = 2;
//rasterizationOptions.NoScaling = true;

        // Add desired layers
        rasterizationOptions.Layers = Layers.ToArray();

        // This one allows the drawing to be in COLOR
        rasterizationOptions.DrawType = Aspose.CAD.FileFormats.Cad.CadDrawTypeMode.UseObjectColor;

        // Create an instance of PdfOptions
        Aspose.CAD.ImageOptions.PdfOptions pdfOptions = new Aspose.CAD.ImageOptions.PdfOptions();
        // Set the VectorRasterizationOptions property
        pdfOptions.VectorRasterizationOptions = rasterizationOptions;

        string MyDir = dinfo + "..\\" + order.DealerName + "\\" + mcpType.SubfolderType;//"temporary_out.pdf";
        MyDir = MyDir + "\\" + SerialNum + ".pdf";
        //Export the DXF to PDF
        image.Save(MyDir, pdfOptions);

        Aspose.CAD.ImageOptions.PngOptions pngOptions = new Aspose.CAD.ImageOptions.PngOptions();
        //Aspose.CAD.ImageOptions.Jpeg2000Options pngOptions = new Aspose.CAD.ImageOptions.Jpeg2000Options();
        pngOptions.VectorRasterizationOptions = rasterizationOptions;
        //pngOptions.ResolutionSettings = new (9.0, 9.0);
        //pngOptions.CompressionLevel = 0;
        System.IO.Stream imageStream = new System.IO.MemoryStream();
        System.Drawing.Image pic;
        image.Save(imageStream, pngOptions);
        image.Save("test.png", pngOptions);

PDF.png (66.7 KB)
1700.png (141.0 KB)
3400.png (103.7 KB)

Hello, could you please also attach initial drawing (dxf/dwg) file so we can look at it in details?

DXF.zip (609.9 KB)

could you please test whether this change helps (instead of multiplication):
layer.LineWeight = 200;

@Oleksii.Gorokhovatskyi Thank you, that does make a difference

1 Like