本方法是通过引入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); }
服务器托管,北京服务器托管,服务器租用,机房机柜带宽租用
咨询:董先生
电话13051898268 QQ/微信93663045!
上一篇: Zend Framework 入门(1)—快速上手Hello, World!
下一篇: 「高频必考」Docker&K8S面试题和答案