Aspose.CAD to PDF 100%CPU load leads to server crash

When converting this CAD file to PDF, “cadImage.save(dataDir, pdfOptions);” costs too long and seems it will never stop, along with constantly Newing threads. As a result, our server collapsed because of 100%cpu load and OOM.

After we compared this CAD with others, we found out the border may be the reason. After changing the border of the cad file, it works fine.

I am wondering if it’s possible to find out the the cause of the problem and how to prevent it happening in the future, or is there any way to pause and ruturn once it costs too long? Thanks in advance and below are codes and environment details.

public static void CADFileToPDF(String srcFile, String dataDir, String pageSize, String pageOrientation, boolean isColor) {

	try {
		Image objImage = Image.load(srcFile);
		CadImage cadImage = (CadImage) objImage;
		cadImage.updateSize();
		cadImage.setDefaultFont("仿宋");
		CadRasterizationOptions cadRasterizationOptions = new CadRasterizationOptions();
		cadRasterizationOptions.setExportAllLayoutContent(true);
		if (isColor)
			cadRasterizationOptions.setDrawType(CadDrawTypeMode.UseObjectColor);
		float width = "A3".equals(pageSize) ? PageSize.A3.getWidth() : PageSize.A4.getWidth();

		float height = "A3".equals(pageSize) ? PageSize.A3.getHeight() : PageSize.A4.getHeight();

		// 设置纸张方向,默认纵向,
		SizeF size = "landscape".equals(pageOrientation) ? new SizeF(height, width) : new SizeF(width, height);
		cadRasterizationOptions.setPageSize(size);
		cadRasterizationOptions.setAutomaticLayoutsScaling(false);
		cadRasterizationOptions.setNoScaling(false);
		
		PdfOptions pdfOptions = new PdfOptions();
		pdfOptions.setVectorRasterizationOptions(cadRasterizationOptions);
		cadImage.save(dataDir, pdfOptions);
	}
	catch (Throwable t) {
		logger.info(getThrowableDetail(t));
	}
}

aspose-cad-23.5.jar
Windows 10
RAM : 8G
JDK : 1.8
local VM arguments :-ea
remote server VM arguments : -Xmx8550m -Xms8550m
dwg file:
DZ-010.zip (1015.6 KB)
errorLog:
errorlog.zip (2.0 KB)

@Neil717,
the source of the issue is the hatch pointed in the red circle (HatchFarAway.png (13.9 KB)). We will investigate reasons of hanging and fix this. You can try to use InterruptionToken (Set timeout on save|Documentation) to prevent such cases.

@Neil717
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): CADJAVA-11301

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.

Thank you very much!

1 Like