I have observed the issue shared by you and request you to please share the working VS Solution reproducing the issue on your end along with machine specification and memory profile snapshot. We will be able to investigate the issue further on our end on provision of requested information.
Can you please give this a try and let us know what you see?
We will follow with more data, sure, but this pretty obvious on our side and most likely it will be on your side as well.
The DWF file contains a lot of small items.
Here is a full working solution CadToPdf-20-3.zip (1.0 MB) that includes the input file as well.
The CadPageSizesForA4 is just a function based on code that you guys suggested in your free forum or in documentation.
We just want to understand if there is a faster/less consuming way to convert CAD files to PDF. It could involve flattening for what is worth.
Thank you for sharing the information with us. An issue with ID CADNET-1102 has been created in our issue tracking system to further investigate and resolve the issue w.r.t performance aspects. This thread has been linked with the issue so that you may be notified once the issue will be fixed.
After analysis of the shared DWF file it has been observed that the sample file contains many entities (91195956 items). By default, PDF rasterization is a vector, and every entity written into a result file. So, the resultant PDF size is too large, also it consumes more time to render it.
In order to improve the speed at the cost of losing the quality, it’s possible to set ContentAsBitmap = true option in CadRasterizationOptions. As a result, the rendered PDF will contain an image inside except each separate entity, also for an attached sample it will be more than 2 times faster.
I have checked the output, its extremely tiny. Can you please provide the sample project used on your end to obtain this so that we proceed further from there.
I have tested the sample project on my end as it is and it took 77 seconds to render the PDF.
However, when I added following modification in your project, the rendering time reduced to 40 seconds. The following is what we have suggested to you and it shows notable improvement.
using (var image = Image.Load(inputFileName))
{
var cadPageSizes = CadPageSizesForA4(image.UnitType);
var rasterizationOptions = new CadRasterizationOptions
{
PageWidth = cadPageSizes.PageWidth,
PageHeight = cadPageSizes.PageHeight,
UnitType = cadPageSizes.UnitType,
DrawType = CadDrawTypeMode.UseObjectColor
,ContentAsBitmap = true
};
image.Save(outputFileName, new PdfOptions
{
VectorRasterizationOptions = rasterizationOptions
});
}
I tested the same sample project and used the same DWF file that you have shared with me without any other change then suggested modification and it produced a 22 MB PDF file. Can you please confirm that the garbage PDF that you are referring has been generated from same source file for which a 22 MB PDF has been generated on my end using same code or is there a different file or code used.
If that is a different file and producing garbage result using same sample project, then please share that file with us.
Using latest sample project, I am able to reproduce issue of 2 KB generated PDF. I have associated the information in our issue tracking system so that we my share feedback with you as soon as the issue will be fixed.