本方法是通过引入aspose-cad工具来把dwg转换为svg, aspose-cad的下载地址为: https://mvnrepository.com/artifact/com.aspose/aspose-cad, 我是通过本地测试来转换的, 可以成功转换 File file = new File("G:/cad"); File[] files = file.listFiles(); for (File file1 : files) { String path = file1.getAbsolutePath(); String name = file1.getName().replace(".dwg", ""); Image cadImage = Image.load(path); CadRasterizationOptions rasterizationOptions = new CadRasterizationOptions(); rasterizationOptions.setAutomaticLayoutsScaling(true); rasterizationOptions.setNoScaling (false); rasterizationOptions.setContentAsBitmap(true); rasterizationOptions.setLayouts(new String[] {"Model"}); SvgOptions svgOptions = new SvgOptions(); rasterizationOptions.getGraphicsOptions().setSmoothingMode(SmoothingMode.HighQu ality); rasterizationOptions.getGraphicsOptions().setTextRenderingHint(TextRenderingHin t.AntiAliasGridFit); rasterizationOptions.getGraphicsOptions().setInterpolationMode(InterpolationMod e.HighQualityBicubic); int width = cadImage.getWidth(); int height = cadImage.getHeight(); float zoom = 2.5f; rasterizationOptions.setPageHeight(height * zoom); rasterizationOptions.setPageWidth(width * zoom); rasterizationOptions.setDrawType(CadDrawTypeMode.UseObjectColor); svgOptions.setVectorRasterizationOptions(rasterizationOptions); cadImage.save("G:/output/" + name +".svg", svgOptions); }