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)