Skip to content

Instantly share code, notes, and snippets.

@aspose-com-kb
Last active November 4, 2022 15:33
How to Convert DWG to SVG using Java. For more details:https://kb.aspose.com/cad/java/how-to-convert-dwg-to-svg-in-java/
import com.aspose.cad.Image;
import com.aspose.cad.License;
import com.aspose.cad.imageoptions.SvgOptions;
import com.aspose.cad.imageoptions.svgoptionsparameters.SvgColorMode;
public class CadToSVGConvertor {
public static void main2(String[] args) throws Exception { // main method to convert DWG to SVG image using Java
String filePath= " C:/Test_Data/";
// Set the license to convert DWG to SVG
License licenseDWGtoSVG = new License();
licenseDWGtoSVG.setLicense(filePath + "Conholdate.Total.Product.Family.lic");
// Load the sample DWG file from the disk
Image cadImage = Image.load(filePath + "sample.dwg");
// Set the SVG export options
SvgOptions svgOpts = new SvgOptions();
svgOpts.setColorType(SvgColorMode.Grayscale);
svgOpts.setTextAsShapes(true);
// Save exported SVG on the disk
cadImage.save(filePath + "OutputFile.svg", svgOpts);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment