I am trying to convert dxf to svg using the java library. The converted svg is very big. Are there any options to set the scaling parameters, additionally the colors should be retained in the svg.
public static void main(String[] args) throws Exception {
// Replace these paths with your actual file locations
String inputDxfFilePath = "dxftoconvert.dxf";
String outputSvgFilePath = "output.svg";
// Load the DXF file
try (CadImage image = (CadImage)Image.load(inputDxfFilePath)) {
// Create SvgOptions for desired output format (optional)
SvgOptions svgOptions = new SvgOptions();
// Set layer to export (optional)
SvgOptions svgOpts = new SvgOptions();
CadRasterizationOptions rasterizationOptions = new CadRasterizationOptions();
rasterizationOptions.setLayouts(null);
svgOpts.setUseAbsoluteRescaling(false);
svgOpts.setTextAsShapes(false);
svgOpts.setPalette(image.getPalette());
svgOpts.setVectorRasterizationOptions(rasterizationOptions);
// Convert to SVG and save
image.save(outputSvgFilePath, svgOptions);
System.out.println("DXF file converted to SVG successfully!");
}
}
Is there any documentation for advanced conversion.
Rectangle-layers.zip (33.3 KB)