java dwg转svg
package com.example.demo.dxf2svg;

import com.aspose.cad.InterpolationMode;
import com.aspose.cad.SmoothingMode;
import com.aspose.cad.TextRenderingHint;
import com.aspose.cad.imageoptions.CadRasterizationOptions;
import com.aspose.cad.imageoptions.SvgOptions;

/**
 * Created by Administrator on 2019/9/10.
 */
public class Test {

    public static void main(String[] args) {
        //加载PDF
//        String absParsingFile = "D:/dfx/暖气位置建议图.dwg";
        String absParsingFile = "C:/file/dfx/暖气位置建议图.dwg";
        com.aspose.cad.Image cadImage = com.aspose.cad.Image.load(absParsingFile);
        CadRasterizationOptions rasterizationOptions = new CadRasterizationOptions();
        rasterizationOptions.setPageWidth(1600);
        rasterizationOptions.setPageHeight(1600);
        rasterizationOptions.setAutomaticLayoutsScaling(true);
        rasterizationOptions.setNoScaling (false);
        rasterizationOptions.setContentAsBitmap(true);
        rasterizationOptions.setLayouts(new String[] {"Model"});
        rasterizationOptions.setDrawType(1);

        SvgOptions svgOptions = new SvgOptions();
        svgOptions.setVectorRasterizationOptions(rasterizationOptions);

        // Set Graphics options
        rasterizationOptions.getGraphicsOptions().setSmoothingMode(SmoothingMode.HighQuality);
        rasterizationOptions.getGraphicsOptions().setTextRenderingHint(TextRenderingHint.AntiAliasGridFit);
        rasterizationOptions.getGraphicsOptions().setInterpolationMode(InterpolationMode.HighQualityBicubic);

        // Export to PDF by calling the Save method
        cadImage.save("C:/file/dfx/暖气位置建议图.svg", svgOptions);
    }

}

  

posted on 2019-09-16 09:05  james-roger  阅读(3195)  评论(2编辑  收藏  举报